lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240123102728.239147-1-james.clark@arm.com>
Date: Tue, 23 Jan 2024 10:27:27 +0000
From: James Clark <james.clark@....com>
To: linux-perf-users@...r.kernel.org,
	irogers@...gle.com,
	kan.liang@...ux.intel.com
Cc: mark.rutland@....com,
	James Clark <james.clark@....com>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Changbin Du <changbin.du@...wei.com>,
	Yang Jihong <yangjihong1@...wei.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU

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 <irogers@...gle.com>
Reviewed-by: Ian Rogers <irogers@...gle.com>
Tested-by: Kan Liang <kan.liang@...ux.intel.com>
Signed-off-by: James Clark <james.clark@....com>
---
 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;
 }
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ