Message ID | 20240122155436.185089-1-james.clark@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-33637-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2710706dyb; Mon, 22 Jan 2024 09:09:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmWbUyd/bh6sxlzciSu/NbiGcL2LfzctZtw6wArvm0xahPYpWcXAQmwSrKehhLIs7xuRN5 X-Received: by 2002:a7b:c4c6:0:b0:40e:6ca1:b0d0 with SMTP id g6-20020a7bc4c6000000b0040e6ca1b0d0mr2832641wmk.53.1705943362844; Mon, 22 Jan 2024 09:09:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705943362; cv=pass; d=google.com; s=arc-20160816; b=IL47z/NORVI6b8nM5f0cfdVUSsJ4MRVjh7+y0xZwMzk+YXwaTgCLUePb0Izf+pPa12 1lFQ9zrReDqR/jFk83Dwq+d0r7FaTxpbWKLRF53biTVhjdhELMsGStcoFDcjCd92wACh lmeK1hcnO3mInGzT0AqFq1pk0kbelOarPMRO/M9hn4fxvWc1GalOXFtJ64mUGDQpgOlI qmw4u+bAk7LSZqeAMpeUc/1e7YwB5Y8RynUIHZoI7eXKS6YDVYlGNqogeTyw+OWou+QM PsUQSXrt6/QFkQZwEQADT8GtwaTuylI8gDT7rxObB2M7o79G/4ko+pPsA/pKcbMFGdmT 5NFw== 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:message-id:date:subject:cc:to :from; bh=BU0nId26cQCyS7E/qrEIoGSvhTL1Fm5y4vFcwcqFGVE=; fh=HQ7tqpBBxAO7WYiNNhtc/xfuwytu/Ky67mYPO9CWnNM=; b=TTxZ/7Alx9i3+771D5OJ2DRr32RdZ+x/4PcB7t6swAFNbfrP5CPDr/Ae7bEDiNEyo9 9Ahyow8YzAeqa6C7z8bicWkNF8iQzcNHyjjK06WSqfgUbZOg+AJckcptotnKBckbaKjZ m1an/bJ9UPYe9dtQXfXSj/LJSh0S5qhMPqVSaU6RLlXfdlLD7p1Z7+vwlodNa2JSGBPf esrl6/T0SCHIQn5LZ0ajgJUFVgHpEersFxhEEI9hd+BTnkJ7dtO1jTj5sLyN4s7Uh16y UoHuTGRpc/qQ/km+pPeaFwuj+H8FwCS8iZncT+kCRsU4+54cxXWvCmMWxDiPb+a3Ax4V 6WUg== 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-33637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33637-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m27-20020a170906581b00b00a2fba12f3aasi2749609ejq.8.2024.01.22.09.09.22 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:09:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-33637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33637-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7595B1F2687A for <ouuuleilei@gmail.com>; Mon, 22 Jan 2024 17:09:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4629661669; Mon, 22 Jan 2024 15:55:38 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 305CB3D3A2; Mon, 22 Jan 2024 15:55:33 +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=1705938936; cv=none; b=nhpJ6u0LM2aqh1S6VTsM86Up0g3ycLnjbyOlOtWsczrZxkW4bmGvaKaEbm4cB7Wr0U6vhEueeHRIREvuCEuMmaMQdqUbeuq9Et9susA8dcTCIgMCs2IWkdviL7izhd4//Vgo2O7rjBlRO2Tawh12od5d3oc1RT1XAHaz4lbucGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705938936; c=relaxed/simple; bh=kUXfghoiFBjltNJTwIw7DiTy00z9/3VXv1D/1k0n6CI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Jx7b3xjgxxiUZUxrDwnhyZ+iWOWOAbFCBbEkK5VXlkCssZdNJ+ic/LkTbM+Y2s16A/EcyntEUH4J67RwSURJmY361jk77ZprN77Lq/TPAbcDtbZ9QOtSDs1nZJ8pJ11fAbAUoL1vFHj7HvkA56YlVRJ9uNUamSA58P3jISUOs1o= 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 573CD1FB; Mon, 22 Jan 2024 07:56:19 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 337963F5A1; Mon, 22 Jan 2024 07:55:31 -0800 (PST) From: James Clark <james.clark@arm.com> To: linux-perf-users@vger.kernel.org, mark.rutland@arm.com, irogers@google.com Cc: James Clark <james.clark@arm.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Adrian Hunter <adrian.hunter@intel.com>, Kan Liang <kan.liang@linux.intel.com>, Yang Jihong <yangjihong1@huawei.com>, Changbin Du <changbin.du@huawei.com>, linux-kernel@vger.kernel.org Subject: [PATCH] perf test: Fix session topology test on heterogeneous systems Date: Mon, 22 Jan 2024 15:54:35 +0000 Message-Id: <20240122155436.185089-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788811267405073882 X-GMAIL-MSGID: 1788811267405073882 |
Series |
perf test: Fix session topology test on heterogeneous systems
|
|
Commit Message
James Clark
Jan. 22, 2024, 3:54 p.m. UTC
The 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 session 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 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")
Signed-off-by: James Clark <james.clark@arm.com>
---
tools/perf/util/evlist.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On 22/01/2024 15:54, James Clark wrote: > The 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 session ID session ID -> sample ID
On 2024-01-22 10:54 a.m., James Clark wrote: > The 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 session 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 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") > Signed-off-by: James Clark <james.clark@arm.com> Verified on an Intel hybrid machine. Tested-by: Kan Liang <kan.liang@linux.intel.com> Thanks, Kan > --- > tools/perf/util/evlist.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 95f25e9fb994..56db37fac6f6 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void) > struct evlist *evlist = evlist__new(); > bool can_profile_kernel; > int err; > + struct evsel *evsel; > > if (!evlist) > return NULL; > @@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void) > evlist = NULL; > } > > + if (evlist->core.nr_entries > 1) > + evlist__for_each_entry(evlist, evsel) > + evsel__set_sample_id(evsel, false); > + > return evlist; > } >
Hi James, I think the subject should be something like "perf evlist: Fix new_default for >1 core PMU" as the change will apply more widely than just the test. The test failure fix can be in the subject. You could add a: Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/ On Mon, Jan 22, 2024 at 7:55 AM James Clark <james.clark@arm.com> wrote: > > The 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 session 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 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") > Signed-off-by: James Clark <james.clark@arm.com> > --- > tools/perf/util/evlist.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 95f25e9fb994..56db37fac6f6 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void) > struct evlist *evlist = evlist__new(); > bool can_profile_kernel; > int err; > + struct evsel *evsel; > > if (!evlist) > return NULL; > @@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void) > evlist = NULL; > } > > + if (evlist->core.nr_entries > 1) > + evlist__for_each_entry(evlist, evsel) > + evsel__set_sample_id(evsel, false); > + nit: the if should have curlies, with them we can reduce the scope of evsel like below. It is also nice for constants to name the arguments [1]. if (evlist->core.nr_entries > 1) { struct evsel *evsel; evlist__for_each_entry(evlist, evsel) evsel__set_sample_id(evsel, /*can_sample_identifier=*/false); } Tested-by: Ian Rogers <irogers@google.com> (also Reviewed-by) When testing with this with Mark's change [2] I see on alderlake two failures: ``` irogers@alderlake:~$ perf test 74 -vv Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc 74: daemon operations : --- start --- test child forked, pid 553821 test daemon list test daemon reconfig test daemon stop test daemon signal signal 12 sent to session 'test [554082]' signal 12 sent to session 'test [554082]' FAILED: perf data no generated test daemon ping test daemon lock test child finished with -1 ---- end ---- daemon operations: FAILED! irogers@alderlake:~$ perf test 76 -vv Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc 76: perf list tests : --- start --- test child forked, pid 554167 Json output test Expecting ',' delimiter: line 4971 column 2 (char 243497) test child finished with -1 ---- end ---- perf list tests: FAILED! ``` So I think this patch may be exposing other latent issues. I'll try to take a look. Another thought, rather than having an evlist validate we should just assert the evlist is always in a good shape whenever it is mutated. That would have avoided this bug as the code would have blown up early. Thanks, Ian [1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html [2] https://lore.kernel.org/lkml/20240116170348.463479-1-mark.rutland@arm.com/ > return evlist; > } > > -- > 2.34.1 >
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 95f25e9fb994..56db37fac6f6 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void) struct evlist *evlist = evlist__new(); bool can_profile_kernel; int err; + struct evsel *evsel; if (!evlist) return NULL; @@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void) evlist = NULL; } + if (evlist->core.nr_entries > 1) + evlist__for_each_entry(evlist, evsel) + evsel__set_sample_id(evsel, false); + return evlist; }