From patchwork Tue Jan 23 10:27:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 190834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp239609dyi; Tue, 23 Jan 2024 02:27:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFU8iviEq6uJ/b9CjnmwLz7SINV82A+eb5swTw6PQeAs5fNEz/rdsobaxnIeBVhASfmxzyJ X-Received: by 2002:a05:6808:1186:b0:3bd:5a62:494a with SMTP id j6-20020a056808118600b003bd5a62494amr5822384oil.95.1706005676198; Tue, 23 Jan 2024 02:27:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706005676; cv=pass; d=google.com; s=arc-20160816; b=lFoV+f/pKoxQlaf5Axf3mhFPg7OHyUHLhAnUmikBLS2+1Y+nzOphqjA0iJ6JTvpvwX +QmN83wyf81iT2v5Xzm5+lgopTCAhH6bs+psmmM3h/Ey8vQLH1V3Bpoc7heWNqxBGi/e sFi+eq3IdGMisncudzDz3JgBcuD/j7OYuaX79d8LLKSKPscqvsG1hqITB3MJvKEoR31z KRgW+ZWnjzyjeDXxOLV0Erq53FN7U60pHB+8vKyLAE0TAQupeP/I3hDwaHFSDaIbgE9M hI7cdq0V5/49X1bBOwBHxY4v3q/g5zFvVV9qvePHIBUZZMVf9Cx5ksj0B/95+gT306uZ FM6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=cq0leUO0kVAyqMutMyfja5ajzzNnb+6cNsHeyDymi38=; fh=7PWocB/3HGs48JdmiX26v8c5qGPYjA3jeyJQwCZd7s0=; b=jdKdg3YyluoF6EB2A9sMhhmOElRcPHoS6CPSaTR7T5wZx1NER8VO7SDBdZ/RK5P+iW BwP2/wUF9jmOFOMPPhiqC9aNwoXxe6U6UW1zhOsJ6oLLL81C7PINZRhiC3noJlwej5Vu 4Gleg/rIkwurMZzNsE5h160t009WCeyaCDIQ/tRrjqmxVbUUWsFKJyWtdTfMIf09Q6IE fU6RapNKikP9cd1KfzK06JaKCrz7MyalNBODU7nxM5b47YPAMfCqSux2NtYYp18Q0zuk k6E7hO24/61fe3FG7wak9Pg2Eb3b/z2xO+IxA6fPCIX8Ads9JRPF2KOCyz0QM6jqo05h zvQw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-35088-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35088-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h14-20020a056a00170e00b006dbd3d8081asi4884089pfc.160.2024.01.23.02.27.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 02:27:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35088-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-35088-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35088-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DEE49280F34 for ; Tue, 23 Jan 2024 10:27:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4C365C5E9; Tue, 23 Jan 2024 10:27:41 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31CC65C5E0; Tue, 23 Jan 2024 10:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706005660; cv=none; b=a1c1Hqigh79kiLydpUA8yOsST90MqJuLEFg9DOQiHKzugqGcT3ZHd76MuyQmMw44d8a25NMFH43bUpI6J9p//5WfjvYm4OQZ04WsFGlFcVZiMnbJq0qtD0ZJOpNt4wzG7ZGof/GD4dUFc+HLkNjUV5WN90u+xWGi1oQho/ZZyzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706005660; c=relaxed/simple; bh=WHiIvVOL1WIlDzJWq+Wu1bVs6mBOGVTd3NVo6oCnJbQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ayLEICAnNgkCY1xc9W9PN/OTy47VwR4s3uwJUb2nch0hHwZ92n+2AclKarLJvNnaTfH8ktp+GsEamr7E/+frp7Ps4qOy8ufyl4D4RzfrGC7/cSMiDaandaZ1nBbH3dTtbhAuZKrzs3g+5D9cJheZuosb4LJqMWG8ajOjZJJW+Ts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E10731FB; Tue, 23 Jan 2024 02:28:22 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 745813F5A1; Tue, 23 Jan 2024 02:27:35 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org, irogers@google.com, kan.liang@linux.intel.com Cc: mark.rutland@arm.com, James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Changbin Du , Yang Jihong , linux-kernel@vger.kernel.org Subject: [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU Date: Tue, 23 Jan 2024 10:27:27 +0000 Message-Id: <20240123102728.239147-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122155436.185089-1-james.clark@arm.com> References: <20240122155436.185089-1-james.clark@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788876608005504723 X-GMAIL-MSGID: 1788876608005504723 The 'Session topology' test currently fails with this message when evlist__new_default() opens more than one event: 32: Session topology : --- start --- templ file: /tmp/perf-test-vv5YzZ Using CPUID 0x00000000410fd070 Opening: unknown-hardware:HG ------------------------------------------------------------ perf_event_attr: type 0 (PERF_TYPE_HARDWARE) config 0xb00000000 disabled 1 ------------------------------------------------------------ sys_perf_event_open: pid 0 cpu -1 group_fd -1 flags 0x8 = 4 Opening: unknown-hardware:HG ------------------------------------------------------------ perf_event_attr: type 0 (PERF_TYPE_HARDWARE) config 0xa00000000 disabled 1 ------------------------------------------------------------ sys_perf_event_open: pid 0 cpu -1 group_fd -1 flags 0x8 = 5 non matching sample_type FAILED tests/topology.c:73 can't get session ---- end ---- Session topology: FAILED! This is because when re-opening the file and parsing the header, Perf expects that any file that has more than one event has the sample ID flag set. Perf record already sets the flag in a similar way when there is more than one event, so add the same logic to evlist__new_default(). evlist__new_default() is only currently used in tests, so I don't expect this change to have any other side effects. The other tests that use it don't save and re-open the file so don't hit this issue. The session topology test has been failing on Arm big.LITTLE platforms since commit 251aa040244a ("perf parse-events: Wildcard most "numeric" events") when evlist__new_default() started opening multiple events for 'cycles'. Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events") Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/ Tested-by: Ian Rogers Reviewed-by: Ian Rogers Tested-by: Kan Liang Signed-off-by: James Clark --- tools/perf/util/evlist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) Changes since v1: * Reduce scope of evsel variable * Add argument label * Change summary to be less specific about the failing test * Add the closes: tag diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 56db37fac6f6..979a6053a84d 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -95,7 +95,6 @@ struct evlist *evlist__new_default(void) struct evlist *evlist = evlist__new(); bool can_profile_kernel; int err; - struct evsel *evsel; if (!evlist) return NULL; @@ -107,9 +106,12 @@ struct evlist *evlist__new_default(void) evlist = NULL; } - if (evlist->core.nr_entries > 1) + if (evlist->core.nr_entries > 1) { + struct evsel *evsel; + evlist__for_each_entry(evlist, evsel) - evsel__set_sample_id(evsel, false); + evsel__set_sample_id(evsel, /*can_sample_identifier=*/false); + } return evlist; }