All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU
@ 2021-07-08  1:36 Jin Yao
  2021-07-08  1:36 ` [PATCH v2 1/4] perf pmu: Skip invalid hybrid pmu Jin Yao
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jin Yao @ 2021-07-08  1:36 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

On hybrid platform, such as Alderlake, if atom CPUs are offlined,
the kernel still exports the sysfs path '/sys/devices/cpu_atom/' for
'cpu_atom' pmu but the file '/sys/devices/cpu_atom/cpus' is empty,
which indicates this is an invalid pmu. So we need to check and skip
the invalid hybrid pmu.

Also we need to update some perf test cases for core-only system.

Jin Yao (4):
  perf pmu: Skip invalid hybrid pmu
  perf tests: Fix 'Parse event definition strings' on core-only system
  perf tests: Fix 'Roundtrip evsel->name' on core-only system
  perf tests: Fix 'Convert perf time to TSC' on core-only system

 tools/perf/tests/evsel-roundtrip-name.c |  3 ++-
 tools/perf/tests/parse-events.c         | 16 ++++++++++------
 tools/perf/tests/perf-time-to-tsc.c     |  3 ++-
 tools/perf/util/pmu.c                   |  9 ++++++++-
 4 files changed, 22 insertions(+), 9 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/4] perf pmu: Skip invalid hybrid pmu
  2021-07-08  1:36 [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jin Yao
@ 2021-07-08  1:36 ` Jin Yao
  2021-07-08  1:36 ` [PATCH v2 2/4] perf tests: Fix 'Parse event definition strings' on core-only system Jin Yao
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jin Yao @ 2021-07-08  1:36 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

On hybrid platform, such as Alderlake, if atom CPUs are offlined,
the kernel still exports the sysfs path '/sys/devices/cpu_atom/' for
'cpu_atom' pmu but the file '/sys/devices/cpu_atom/cpus' is empty,
which indicates this is an invalid pmu.

Need to check and skip the invalid hybrid pmu.

Before:

  # perf list
  ...
  branch-instructions OR cpu_atom/branch-instructions/ [Kernel PMU event]
  branch-instructions OR cpu_core/branch-instructions/ [Kernel PMU event]
  branch-misses OR cpu_atom/branch-misses/           [Kernel PMU event]
  branch-misses OR cpu_core/branch-misses/           [Kernel PMU event]
  bus-cycles OR cpu_atom/bus-cycles/                 [Kernel PMU event]
  bus-cycles OR cpu_core/bus-cycles/                 [Kernel PMU event]
  ...

The cpu_atom events are still displayed even if atom CPUs are offlined.

After:

  # perf list
  ...
  branch-instructions OR cpu_core/branch-instructions/ [Kernel PMU event]
  branch-misses OR cpu_core/branch-misses/           [Kernel PMU event]
  bus-cycles OR cpu_core/bus-cycles/                 [Kernel PMU event]
  ...

Now only cpu_core events are displayed.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/util/pmu.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 88c8ecdc60b0..cb20a9f69a04 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -927,6 +927,13 @@ static struct perf_pmu *pmu_lookup(const char *name)
 	LIST_HEAD(format);
 	LIST_HEAD(aliases);
 	__u32 type;
+	bool is_hybrid = perf_pmu__hybrid_mounted(name);
+
+	/*
+	 * Check pmu name for hybrid and the pmu may be invalid in sysfs
+	 */
+	if (!strncmp(name, "cpu_", 4) && !is_hybrid)
+		return NULL;
 
 	/*
 	 * The pmu data we store & need consists of the pmu
@@ -955,7 +962,7 @@ static struct perf_pmu *pmu_lookup(const char *name)
 	pmu->is_uncore = pmu_is_uncore(name);
 	if (pmu->is_uncore)
 		pmu->id = pmu_id(name);
-	pmu->is_hybrid = perf_pmu__hybrid_mounted(name);
+	pmu->is_hybrid = is_hybrid;
 	pmu->max_precise = pmu_max_precise(name);
 	pmu_add_cpu_aliases(&aliases, pmu);
 	pmu_add_sys_aliases(&aliases, pmu);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/4] perf tests: Fix 'Parse event definition strings' on core-only system
  2021-07-08  1:36 [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jin Yao
  2021-07-08  1:36 ` [PATCH v2 1/4] perf pmu: Skip invalid hybrid pmu Jin Yao
@ 2021-07-08  1:36 ` Jin Yao
  2021-07-08  1:37 ` [PATCH v2 3/4] perf tests: Fix 'Roundtrip evsel->name' " Jin Yao
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jin Yao @ 2021-07-08  1:36 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

If the atom CPUs are offlined, the 'cpu_atom' is not valid.
We don't need the test case for 'cpu_atom'.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/tests/parse-events.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 0f113b2b36a3..3ca515fb141f 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -6,6 +6,7 @@
 #include "tests.h"
 #include "debug.h"
 #include "pmu.h"
+#include "pmu-hybrid.h"
 #include <dirent.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -1596,6 +1597,13 @@ static int test__hybrid_raw1(struct evlist *evlist)
 {
 	struct evsel *evsel = evlist__first(evlist);
 
+	if (!perf_pmu__hybrid_mounted("cpu_atom")) {
+		TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
+		TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
+		TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
+		return 0;
+	}
+
 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
 	TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
@@ -1620,13 +1628,9 @@ static int test__hybrid_cache_event(struct evlist *evlist)
 {
 	struct evsel *evsel = evlist__first(evlist);
 
-	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
+	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
 	TEST_ASSERT_VAL("wrong config", 0x2 == (evsel->core.attr.config & 0xffffffff));
-
-	evsel = evsel__next(evsel);
-	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
-	TEST_ASSERT_VAL("wrong config", 0x10002 == (evsel->core.attr.config & 0xffffffff));
 	return 0;
 }
 
@@ -2028,7 +2032,7 @@ static struct evlist_test test__hybrid_events[] = {
 		.id    = 7,
 	},
 	{
-		.name  = "cpu_core/LLC-loads/,cpu_atom/LLC-load-misses/",
+		.name  = "cpu_core/LLC-loads/",
 		.check = test__hybrid_cache_event,
 		.id    = 8,
 	},
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/4] perf tests: Fix 'Roundtrip evsel->name' on core-only system
  2021-07-08  1:36 [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jin Yao
  2021-07-08  1:36 ` [PATCH v2 1/4] perf pmu: Skip invalid hybrid pmu Jin Yao
  2021-07-08  1:36 ` [PATCH v2 2/4] perf tests: Fix 'Parse event definition strings' on core-only system Jin Yao
@ 2021-07-08  1:37 ` Jin Yao
  2021-07-08  1:37 ` [PATCH v2 4/4] perf tests: Fix 'Convert perf time to TSC' " Jin Yao
  2021-07-11 15:52 ` [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jiri Olsa
  4 siblings, 0 replies; 7+ messages in thread
From: Jin Yao @ 2021-07-08  1:37 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

If the atom CPUs are offlined, the 'cpu_atom' is not valid.
Perf will not create two events for one hw event, so the
evsel->idx doesn't need to be divided by 2 before comparing.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/tests/evsel-roundtrip-name.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index b74cf80d1f10..26c49dc3e01e 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -5,6 +5,7 @@
 #include "tests.h"
 #include "debug.h"
 #include "pmu.h"
+#include "pmu-hybrid.h"
 #include <errno.h>
 #include <linux/kernel.h>
 
@@ -102,7 +103,7 @@ int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused, int
 {
 	int err = 0, ret = 0;
 
-	if (perf_pmu__has_hybrid())
+	if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom"))
 		return perf_evsel__name_array_test(evsel__hw_names, 2);
 
 	err = perf_evsel__name_array_test(evsel__hw_names, 1);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/4] perf tests: Fix 'Convert perf time to TSC' on core-only system
  2021-07-08  1:36 [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jin Yao
                   ` (2 preceding siblings ...)
  2021-07-08  1:37 ` [PATCH v2 3/4] perf tests: Fix 'Roundtrip evsel->name' " Jin Yao
@ 2021-07-08  1:37 ` Jin Yao
  2021-07-11 15:52 ` [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jiri Olsa
  4 siblings, 0 replies; 7+ messages in thread
From: Jin Yao @ 2021-07-08  1:37 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

If the atom CPUs are offlined, the 'cpu_atom' is not valid.
We don't need the test case for 'cpu_atom'.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/tests/perf-time-to-tsc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index 85d75b9b25a1..7c56bc1f4cff 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -21,6 +21,7 @@
 #include "mmap.h"
 #include "tests.h"
 #include "pmu.h"
+#include "pmu-hybrid.h"
 
 #define CHECK__(x) {				\
 	while ((x) < 0) {			\
@@ -93,7 +94,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	 * For hybrid "cycles:u", it creates two events.
 	 * Init the second evsel here.
 	 */
-	if (perf_pmu__has_hybrid()) {
+	if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom")) {
 		evsel = evsel__next(evsel);
 		evsel->core.attr.comm = 1;
 		evsel->core.attr.disabled = 1;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU
  2021-07-08  1:36 [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jin Yao
                   ` (3 preceding siblings ...)
  2021-07-08  1:37 ` [PATCH v2 4/4] perf tests: Fix 'Convert perf time to TSC' " Jin Yao
@ 2021-07-11 15:52 ` Jiri Olsa
  2021-07-12 18:08   ` Arnaldo Carvalho de Melo
  4 siblings, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2021-07-11 15:52 UTC (permalink / raw)
  To: Jin Yao
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

On Thu, Jul 08, 2021 at 09:36:57AM +0800, Jin Yao wrote:
> On hybrid platform, such as Alderlake, if atom CPUs are offlined,
> the kernel still exports the sysfs path '/sys/devices/cpu_atom/' for
> 'cpu_atom' pmu but the file '/sys/devices/cpu_atom/cpus' is empty,
> which indicates this is an invalid pmu. So we need to check and skip
> the invalid hybrid pmu.
> 
> Also we need to update some perf test cases for core-only system.
> 
> Jin Yao (4):
>   perf pmu: Skip invalid hybrid pmu
>   perf tests: Fix 'Parse event definition strings' on core-only system
>   perf tests: Fix 'Roundtrip evsel->name' on core-only system
>   perf tests: Fix 'Convert perf time to TSC' on core-only system

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> 
>  tools/perf/tests/evsel-roundtrip-name.c |  3 ++-
>  tools/perf/tests/parse-events.c         | 16 ++++++++++------
>  tools/perf/tests/perf-time-to-tsc.c     |  3 ++-
>  tools/perf/util/pmu.c                   |  9 ++++++++-
>  4 files changed, 22 insertions(+), 9 deletions(-)
> 
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU
  2021-07-11 15:52 ` [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jiri Olsa
@ 2021-07-12 18:08   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-07-12 18:08 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jin Yao, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel,
	ak, kan.liang, yao.jin

Em Sun, Jul 11, 2021 at 05:52:48PM +0200, Jiri Olsa escreveu:
> On Thu, Jul 08, 2021 at 09:36:57AM +0800, Jin Yao wrote:
> > On hybrid platform, such as Alderlake, if atom CPUs are offlined,
> > the kernel still exports the sysfs path '/sys/devices/cpu_atom/' for
> > 'cpu_atom' pmu but the file '/sys/devices/cpu_atom/cpus' is empty,
> > which indicates this is an invalid pmu. So we need to check and skip
> > the invalid hybrid pmu.
> > 
> > Also we need to update some perf test cases for core-only system.
> > 
> > Jin Yao (4):
> >   perf pmu: Skip invalid hybrid pmu
> >   perf tests: Fix 'Parse event definition strings' on core-only system
> >   perf tests: Fix 'Roundtrip evsel->name' on core-only system
> >   perf tests: Fix 'Convert perf time to TSC' on core-only system
> 
> Acked-by: Jiri Olsa <jolsa@redhat.com>

Thanks, applied to perf/urgent.

- Arnaldo


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-12 18:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08  1:36 [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jin Yao
2021-07-08  1:36 ` [PATCH v2 1/4] perf pmu: Skip invalid hybrid pmu Jin Yao
2021-07-08  1:36 ` [PATCH v2 2/4] perf tests: Fix 'Parse event definition strings' on core-only system Jin Yao
2021-07-08  1:37 ` [PATCH v2 3/4] perf tests: Fix 'Roundtrip evsel->name' " Jin Yao
2021-07-08  1:37 ` [PATCH v2 4/4] perf tests: Fix 'Convert perf time to TSC' " Jin Yao
2021-07-11 15:52 ` [PATCH v2 0/4] perf tool: Skip invalid hybrid PMU Jiri Olsa
2021-07-12 18:08   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.