* [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
@ 2024-11-21 0:09 Ian Rogers
2024-11-21 5:49 ` Namhyung Kim
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ian Rogers @ 2024-11-21 0:09 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, linux-perf-users,
linux-kernel
Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
address issue with hwmon_pmu__config_terms needing to load events - a
load bearing assert fired. Also fix missing list deletion when putting
the hwmon test PMU and lower some debug warnings to make the hwmon PMU
less spammy in verbose mode.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/hwmon_pmu.c | 5 +++--
tools/perf/util/hwmon_pmu.c | 16 ++++++++++------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/tools/perf/tests/hwmon_pmu.c b/tools/perf/tests/hwmon_pmu.c
index d8bc71b51599..b4656529146e 100644
--- a/tools/perf/tests/hwmon_pmu.c
+++ b/tools/perf/tests/hwmon_pmu.c
@@ -41,6 +41,7 @@ static int test_pmu_put(const char *dir, struct perf_pmu *hwm)
if (ret)
pr_err("Failure to \"%s\"\n", buf);
+ list_del(&hwm->list);
perf_pmu__delete(hwm);
return ret;
}
@@ -147,7 +148,7 @@ static int do_test(size_t i, bool with_pmu, bool with_alias)
}
if (with_pmu)
- snprintf(str, sizeof(str), "/%s/", test_event);
+ snprintf(str, sizeof(str), "hwmon_a_test_hwmon_pmu/%s/", test_event);
else
strlcpy(str, test_event, sizeof(str));
@@ -230,7 +231,7 @@ static int test__hwmon_pmu_without_pmu(struct test_suite *test __maybe_unused,
static int test__hwmon_pmu_with_pmu(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
- return test__hwmon_pmu(/*with_pmu=*/false);
+ return test__hwmon_pmu(/*with_pmu=*/true);
}
static int test__parse_hwmon_filename(struct test_suite *test __maybe_unused,
diff --git a/tools/perf/util/hwmon_pmu.c b/tools/perf/util/hwmon_pmu.c
index 4d9d6f405434..e61429b38ba7 100644
--- a/tools/perf/util/hwmon_pmu.c
+++ b/tools/perf/util/hwmon_pmu.c
@@ -197,13 +197,13 @@ bool parse_hwmon_filename(const char *filename,
}
}
if (fn_item == NULL || fn_type[0] == '\0' || (item != NULL && fn_item[0] == '\0')) {
- pr_debug("hwmon_pmu: not a hwmon file '%s'\n", filename);
+ pr_debug3("hwmon_pmu: not a hwmon file '%s'\n", filename);
return false;
}
elem = bsearch(&fn_type, hwmon_type_strs + 1, ARRAY_SIZE(hwmon_type_strs) - 1,
sizeof(hwmon_type_strs[0]), hwmon_strcmp);
if (!elem) {
- pr_debug("hwmon_pmu: not a hwmon type '%s' in file name '%s'\n",
+ pr_debug3("hwmon_pmu: not a hwmon type '%s' in file name '%s'\n",
fn_type, filename);
return false;
}
@@ -223,7 +223,7 @@ bool parse_hwmon_filename(const char *filename,
elem = bsearch(fn_item, hwmon_item_strs + 1, ARRAY_SIZE(hwmon_item_strs) - 1,
sizeof(hwmon_item_strs[0]), hwmon_strcmp);
if (!elem) {
- pr_debug("hwmon_pmu: not a hwmon item '%s' in file name '%s'\n",
+ pr_debug3("hwmon_pmu: not a hwmon item '%s' in file name '%s'\n",
fn_item, filename);
return false;
}
@@ -281,7 +281,7 @@ static int hwmon_pmu__read_events(struct hwmon_pmu *pmu)
continue;
if (!parse_hwmon_filename(ent->d_name, &type, &number, &item, &alarm)) {
- pr_debug("Not a hwmon file '%s'\n", ent->d_name);
+ pr_debug3("Not a hwmon file '%s'\n", ent->d_name);
continue;
}
key.num = number;
@@ -653,10 +653,14 @@ int hwmon_pmu__config_terms(const struct perf_pmu *pmu,
struct parse_events_terms *terms,
struct parse_events_error *err)
{
- const struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
+ struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
struct parse_events_term *term;
+ int ret;
+
+ ret = hwmon_pmu__read_events(hwm);
+ if (ret)
+ return ret;
- assert(pmu->sysfs_aliases_loaded);
list_for_each_entry(term, &terms->terms, list) {
if (hwmon_pmu__config_term(hwm, attr, term, err))
return -EINVAL;
--
2.47.0.371.ga323438b13-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 0:09 [PATCH v1] perf tests: Fix hwmon parsing with PMU name test Ian Rogers
@ 2024-11-21 5:49 ` Namhyung Kim
2024-11-21 17:04 ` Arnaldo Carvalho de Melo
2024-11-22 22:17 ` Namhyung Kim
2 siblings, 0 replies; 9+ messages in thread
From: Namhyung Kim @ 2024-11-21 5:49 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
Kan Liang, linux-perf-users, linux-kernel
On Wed, Nov 20, 2024 at 04:09:55PM -0800, Ian Rogers wrote:
> Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> address issue with hwmon_pmu__config_terms needing to load events - a
> load bearing assert fired. Also fix missing list deletion when putting
> the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> less spammy in verbose mode.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/tests/hwmon_pmu.c | 5 +++--
> tools/perf/util/hwmon_pmu.c | 16 ++++++++++------
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/tests/hwmon_pmu.c b/tools/perf/tests/hwmon_pmu.c
> index d8bc71b51599..b4656529146e 100644
> --- a/tools/perf/tests/hwmon_pmu.c
> +++ b/tools/perf/tests/hwmon_pmu.c
> @@ -41,6 +41,7 @@ static int test_pmu_put(const char *dir, struct perf_pmu *hwm)
> if (ret)
> pr_err("Failure to \"%s\"\n", buf);
>
> + list_del(&hwm->list);
> perf_pmu__delete(hwm);
> return ret;
> }
> @@ -147,7 +148,7 @@ static int do_test(size_t i, bool with_pmu, bool with_alias)
> }
>
> if (with_pmu)
> - snprintf(str, sizeof(str), "/%s/", test_event);
> + snprintf(str, sizeof(str), "hwmon_a_test_hwmon_pmu/%s/", test_event);
> else
> strlcpy(str, test_event, sizeof(str));
>
> @@ -230,7 +231,7 @@ static int test__hwmon_pmu_without_pmu(struct test_suite *test __maybe_unused,
> static int test__hwmon_pmu_with_pmu(struct test_suite *test __maybe_unused,
> int subtest __maybe_unused)
> {
> - return test__hwmon_pmu(/*with_pmu=*/false);
> + return test__hwmon_pmu(/*with_pmu=*/true);
> }
>
> static int test__parse_hwmon_filename(struct test_suite *test __maybe_unused,
> diff --git a/tools/perf/util/hwmon_pmu.c b/tools/perf/util/hwmon_pmu.c
> index 4d9d6f405434..e61429b38ba7 100644
> --- a/tools/perf/util/hwmon_pmu.c
> +++ b/tools/perf/util/hwmon_pmu.c
> @@ -197,13 +197,13 @@ bool parse_hwmon_filename(const char *filename,
> }
> }
> if (fn_item == NULL || fn_type[0] == '\0' || (item != NULL && fn_item[0] == '\0')) {
> - pr_debug("hwmon_pmu: not a hwmon file '%s'\n", filename);
> + pr_debug3("hwmon_pmu: not a hwmon file '%s'\n", filename);
> return false;
> }
> elem = bsearch(&fn_type, hwmon_type_strs + 1, ARRAY_SIZE(hwmon_type_strs) - 1,
> sizeof(hwmon_type_strs[0]), hwmon_strcmp);
> if (!elem) {
> - pr_debug("hwmon_pmu: not a hwmon type '%s' in file name '%s'\n",
> + pr_debug3("hwmon_pmu: not a hwmon type '%s' in file name '%s'\n",
> fn_type, filename);
> return false;
> }
> @@ -223,7 +223,7 @@ bool parse_hwmon_filename(const char *filename,
> elem = bsearch(fn_item, hwmon_item_strs + 1, ARRAY_SIZE(hwmon_item_strs) - 1,
> sizeof(hwmon_item_strs[0]), hwmon_strcmp);
> if (!elem) {
> - pr_debug("hwmon_pmu: not a hwmon item '%s' in file name '%s'\n",
> + pr_debug3("hwmon_pmu: not a hwmon item '%s' in file name '%s'\n",
> fn_item, filename);
> return false;
> }
> @@ -281,7 +281,7 @@ static int hwmon_pmu__read_events(struct hwmon_pmu *pmu)
> continue;
>
> if (!parse_hwmon_filename(ent->d_name, &type, &number, &item, &alarm)) {
> - pr_debug("Not a hwmon file '%s'\n", ent->d_name);
> + pr_debug3("Not a hwmon file '%s'\n", ent->d_name);
> continue;
> }
> key.num = number;
> @@ -653,10 +653,14 @@ int hwmon_pmu__config_terms(const struct perf_pmu *pmu,
> struct parse_events_terms *terms,
> struct parse_events_error *err)
> {
> - const struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
> + struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
> struct parse_events_term *term;
> + int ret;
> +
> + ret = hwmon_pmu__read_events(hwm);
> + if (ret)
> + return ret;
>
> - assert(pmu->sysfs_aliases_loaded);
> list_for_each_entry(term, &terms->terms, list) {
> if (hwmon_pmu__config_term(hwm, attr, term, err))
> return -EINVAL;
> --
> 2.47.0.371.ga323438b13-goog
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 0:09 [PATCH v1] perf tests: Fix hwmon parsing with PMU name test Ian Rogers
2024-11-21 5:49 ` Namhyung Kim
@ 2024-11-21 17:04 ` Arnaldo Carvalho de Melo
2024-11-21 17:22 ` Arnaldo Carvalho de Melo
2024-11-22 22:17 ` Namhyung Kim
2 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-21 17:04 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Wed, Nov 20, 2024 at 04:09:55PM -0800, Ian Rogers wrote:
> Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> address issue with hwmon_pmu__config_terms needing to load events - a
> load bearing assert fired. Also fix missing list deletion when putting
> the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> less spammy in verbose mode.
After applying this, with this series of patches on a Fedora 40 system,
I get output from -v where before I needed, IIRC, to use -vv:
f8244bb9bfa66f79 (HEAD -> perf-tools-next, x1/perf-tools-next) perf tests: Fix hwmon parsing with PMU name test
9ae6c7a4bd02acbd perf hwmon_pmu: Ensure hwmon key union is zeroed before use
3e37de098af38179 perf tests hwmon_pmu: Remove double evlist__delete()
0565017a0ac824c2 perf test: Correct hwmon test PMU detection
85c60a01b85ee956 (perf-tools-next/tmp.perf-tools-next, perf-tools-next/perf-tools-next) perf: Remove unused del_perf_probe_events()
⬢ [acme@toolbox perf-tools-next]$
root@number:~# perf -vv
perf version 6.12.rc6.gf8244bb9bfa6
aio: [ on ] # HAVE_AIO_SUPPORT
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
bpf_skeletons: [ on ] # HAVE_BPF_SKEL
debuginfod: [ on ] # HAVE_DEBUGINFOD_SUPPORT
dwarf: [ on ] # HAVE_LIBDW_SUPPORT
dwarf_getlocations: [ on ] # HAVE_LIBDW_SUPPORT
dwarf-unwind: [ on ] # HAVE_DWARF_UNWIND_SUPPORT
auxtrace: [ on ] # HAVE_AUXTRACE_SUPPORT
libaudit: [ OFF ] # HAVE_LIBAUDIT_SUPPORT
libbfd: [ OFF ] # HAVE_LIBBFD_SUPPORT
libcapstone: [ on ] # HAVE_LIBCAPSTONE_SUPPORT
libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT
libdw-dwarf-unwind: [ on ] # HAVE_LIBDW_SUPPORT
libelf: [ on ] # HAVE_LIBELF_SUPPORT
libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT
libopencsd: [ on ] # HAVE_CSTRACE_SUPPORT
libperl: [ on ] # HAVE_LIBPERL_SUPPORT
libpfm4: [ on ] # HAVE_LIBPFM
libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT
libslang: [ on ] # HAVE_SLANG_SUPPORT
libtraceevent: [ on ] # HAVE_LIBTRACEEVENT
libunwind: [ OFF ] # HAVE_LIBUNWIND_SUPPORT
lzma: [ on ] # HAVE_LZMA_SUPPORT
numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT
syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT
zlib: [ on ] # HAVE_ZLIB_SUPPORT
zstd: [ on ] # HAVE_ZSTD_SUPPORT
root@number:~#
root@number:~# perf test -v 11
11: Hwmon PMU :
11.1: Basic parsing test : Ok
--- start ---
test child forked, pid 1823259
Testing 'temp_test_hwmon_event1'
Using CPUID GenuineIntel-6-B7-1
FAILED tests/hwmon_pmu.c:159 failed to parse event 'temp_test_hwmon_event1', err 1
event syntax error: 'temp_test_hwmon_event1'
\___ Bad event name
Unable to find event on a PMU of 'temp_test_hwmon_event1'
---- end(-1) ----
11.2: Parsing without PMU name : FAILED!
--- start ---
test child forked, pid 1823260
Testing 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
Using CPUID GenuineIntel-6-B7-1
FAILED tests/hwmon_pmu.c:159 failed to parse event 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/', err 1
event syntax error: 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
\___ Bad event or PMU
Unable to find PMU or event on a PMU of 'hwmon_a_test_hwmon_pmu'
---- end(-1) ----
11.3: Parsing with PMU name : FAILED!
root@number:~#
⬢ [acme@toolbox perf-tools-next]$ ls -la /sys/class/hwmon/
total 0
drwxr-xr-x. 2 nobody nobody 0 Nov 21 14:03 .
drwxr-xr-x. 80 nobody nobody 0 Nov 15 11:43 ..
lrwxrwxrwx. 1 nobody nobody 0 Nov 15 11:43 hwmon0 -> ../../devices/virtual/thermal/thermal_zone0/hwmon0
lrwxrwxrwx. 1 nobody nobody 0 Nov 15 11:43 hwmon1 -> ../../devices/pci0000:00/0000:00:06.0/0000:02:00.0/nvme/nvme0/hwmon1
lrwxrwxrwx. 1 nobody nobody 0 Nov 20 16:36 hwmon2 -> ../../devices/platform/PNP0C14:02/wmi_bus/wmi_bus-PNP0C14:02/DEADBEEF-2001-0000-00A0-C90629100000/hwmon/hwmon2
lrwxrwxrwx. 1 nobody nobody 0 Nov 20 16:36 hwmon3 -> ../../devices/pci0000:00/0000:00:1f.4/i2c-16/16-0053/hwmon/hwmon3
lrwxrwxrwx. 1 nobody nobody 0 Nov 20 16:36 hwmon4 -> ../../devices/platform/coretemp.0/hwmon/hwmon4
⬢ [acme@toolbox perf-tools-next]$
⬢ [acme@toolbox perf-tools-next]$ uname -a
Linux toolbox 6.11.7-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 8 19:21:57 UTC 2024 x86_64 GNU/Linux
⬢ [acme@toolbox perf-tools-next]$
- Arnaldo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 17:04 ` Arnaldo Carvalho de Melo
@ 2024-11-21 17:22 ` Arnaldo Carvalho de Melo
2024-11-21 18:55 ` Ian Rogers
0 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-21 17:22 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Thu, Nov 21, 2024 at 02:04:45PM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Nov 20, 2024 at 04:09:55PM -0800, Ian Rogers wrote:
> > Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> > address issue with hwmon_pmu__config_terms needing to load events - a
> > load bearing assert fired. Also fix missing list deletion when putting
> > the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> > less spammy in verbose mode.
> After applying this, with this series of patches on a Fedora 40 system,
> I get output from -v where before I needed, IIRC, to use -vv:
>
> f8244bb9bfa66f79 (HEAD -> perf-tools-next, x1/perf-tools-next) perf tests: Fix hwmon parsing with PMU name test
> 9ae6c7a4bd02acbd perf hwmon_pmu: Ensure hwmon key union is zeroed before use
> 3e37de098af38179 perf tests hwmon_pmu: Remove double evlist__delete()
> 0565017a0ac824c2 perf test: Correct hwmon test PMU detection
> 85c60a01b85ee956 (perf-tools-next/tmp.perf-tools-next, perf-tools-next/perf-tools-next) perf: Remove unused del_perf_probe_events()
> ⬢ [acme@toolbox perf-tools-next]$
<SNIP>
> root@number:~# perf test -v 11
> 11: Hwmon PMU :
> 11.1: Basic parsing test : Ok
> --- start ---
> test child forked, pid 1823259
> Testing 'temp_test_hwmon_event1'
> Using CPUID GenuineIntel-6-B7-1
> FAILED tests/hwmon_pmu.c:159 failed to parse event 'temp_test_hwmon_event1', err 1
> event syntax error: 'temp_test_hwmon_event1'
> \___ Bad event name
>
> Unable to find event on a PMU of 'temp_test_hwmon_event1'
In gdb it fails on the first call to do_test() from the first test__hwmon_pmu()
Starting program: /root/bin/perf test -F -vv 11
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
--- start ---
---- end ----
11.1: Basic parsing test : Ok
--- start ---
Breakpoint 1, test__hwmon_pmu (with_pmu=false) at tests/hwmon_pmu.c:203
203 {
(gdb) n
205 struct perf_pmu *pmu = test_pmu_get(dir, sizeof(dir));
(gdb) n
206 int ret = TEST_OK;
(gdb) p pmu
$2 = (struct perf_pmu *) 0xf50450
(gdb) p *pmu
$3 = {name = 0xf50ac0 "hwmon_a_test_hwmon_pmu", alias_name = 0xf50aa0 "hwmon1234", id = 0x0, type = 4294902994, selectable = false, is_core = false, is_uncore = false, auxtrace = false,
formats_checked = false, config_masks_present = false, config_masks_computed = false, max_precise = 0, perf_event_attr_init_default = 0x0, cpus = 0xf4fbf0, format = {next = 0xf50488,
prev = 0xf50488}, aliases = {next = 0xf50498, prev = 0xf50498}, events_table = 0x0, sysfs_aliases = 0, cpu_json_aliases = 0, sys_json_aliases = 0, sysfs_aliases_loaded = false,
cpu_aliases_added = false, caps_initialized = false, nr_caps = 0, caps = {next = 0xf504c8, prev = 0xf504c8}, list = {next = 0xedc090 <other_pmus>, prev = 0xedc090 <other_pmus>},
config_masks = {0, 0, 0, 0}, missing_features = {exclude_guest = false, checked = false}, mem_events = 0x0}
(gdb) s
208 if (!pmu)
(gdb) s
211 for (size_t i = 0; i < ARRAY_SIZE(test_events); i++) {
(gdb) s
212 ret = do_test(i, with_pmu, /*with_alias=*/false);
(gdb) s
do_test (i=0, with_pmu=false, with_alias=false) at tests/hwmon_pmu.c:136
136 {
(gdb) n
137 const char *test_event = with_alias ? test_events[i].alias : test_events[i].name;
(gdb) n
138 struct evlist *evlist = evlist__new();
(gdb) n
143 bool found = false;
(gdb) n
145 if (!evlist) {
(gdb) n
150 if (with_pmu)
(gdb) n
153 strlcpy(str, test_event, sizeof(str));
(gdb) n
155 pr_debug("Testing '%s'\n", str);
(gdb) p str
$4 = "temp_test_hwmon_event1\000\000\004\000\000\000\000\000\000\000\274\204z\000\000\000\000\000΄z\000\000\000\000\000\021\000\000\000\000\000\000\000 \305\377\377\377\177\000\000߄z\000\000\000\000\000\353\204z\000\000\000\000\000\376\204z\000\000\000\000\000\n\205z\000\000\000\000\000\021\205z\000\000\000\000\000\035\205z\000\000\000\000\0000\205z\000\000\000\000\000<\205z\000\000\000\000"
(gdb) n
Testing 'temp_test_hwmon_event1'
156 parse_events_error__init(&err);
(gdb) n
157 ret = parse_events(evlist, str, &err);
(gdb) n
Using CPUID GenuineIntel-6-B7-1
158 if (ret) {
(gdb) p ret
$5 = 1
(gdb) n
159 pr_debug("FAILED %s:%d failed to parse event '%s', err %d\n",
(gdb)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 17:22 ` Arnaldo Carvalho de Melo
@ 2024-11-21 18:55 ` Ian Rogers
2024-11-21 20:58 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 9+ messages in thread
From: Ian Rogers @ 2024-11-21 18:55 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Thu, Nov 21, 2024 at 9:22 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Thu, Nov 21, 2024 at 02:04:45PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Wed, Nov 20, 2024 at 04:09:55PM -0800, Ian Rogers wrote:
> > > Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> > > address issue with hwmon_pmu__config_terms needing to load events - a
> > > load bearing assert fired. Also fix missing list deletion when putting
> > > the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> > > less spammy in verbose mode.
>
> > After applying this, with this series of patches on a Fedora 40 system,
> > I get output from -v where before I needed, IIRC, to use -vv:
> >
> > f8244bb9bfa66f79 (HEAD -> perf-tools-next, x1/perf-tools-next) perf tests: Fix hwmon parsing with PMU name test
> > 9ae6c7a4bd02acbd perf hwmon_pmu: Ensure hwmon key union is zeroed before use
> > 3e37de098af38179 perf tests hwmon_pmu: Remove double evlist__delete()
> > 0565017a0ac824c2 perf test: Correct hwmon test PMU detection
> > 85c60a01b85ee956 (perf-tools-next/tmp.perf-tools-next, perf-tools-next/perf-tools-next) perf: Remove unused del_perf_probe_events()
> > ⬢ [acme@toolbox perf-tools-next]$
>
> <SNIP>
>
> > root@number:~# perf test -v 11
> > 11: Hwmon PMU :
> > 11.1: Basic parsing test : Ok
> > --- start ---
> > test child forked, pid 1823259
> > Testing 'temp_test_hwmon_event1'
> > Using CPUID GenuineIntel-6-B7-1
> > FAILED tests/hwmon_pmu.c:159 failed to parse event 'temp_test_hwmon_event1', err 1
> > event syntax error: 'temp_test_hwmon_event1'
> > \___ Bad event name
> >
> > Unable to find event on a PMU of 'temp_test_hwmon_event1'
>
> In gdb it fails on the first call to do_test() from the first test__hwmon_pmu()
>
> Starting program: /root/bin/perf test -F -vv 11
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> --- start ---
> ---- end ----
> 11.1: Basic parsing test : Ok
> --- start ---
>
> Breakpoint 1, test__hwmon_pmu (with_pmu=false) at tests/hwmon_pmu.c:203
> 203 {
> (gdb) n
> 205 struct perf_pmu *pmu = test_pmu_get(dir, sizeof(dir));
> (gdb) n
> 206 int ret = TEST_OK;
> (gdb) p pmu
> $2 = (struct perf_pmu *) 0xf50450
> (gdb) p *pmu
> $3 = {name = 0xf50ac0 "hwmon_a_test_hwmon_pmu", alias_name = 0xf50aa0 "hwmon1234", id = 0x0, type = 4294902994, selectable = false, is_core = false, is_uncore = false, auxtrace = false,
> formats_checked = false, config_masks_present = false, config_masks_computed = false, max_precise = 0, perf_event_attr_init_default = 0x0, cpus = 0xf4fbf0, format = {next = 0xf50488,
> prev = 0xf50488}, aliases = {next = 0xf50498, prev = 0xf50498}, events_table = 0x0, sysfs_aliases = 0, cpu_json_aliases = 0, sys_json_aliases = 0, sysfs_aliases_loaded = false,
> cpu_aliases_added = false, caps_initialized = false, nr_caps = 0, caps = {next = 0xf504c8, prev = 0xf504c8}, list = {next = 0xedc090 <other_pmus>, prev = 0xedc090 <other_pmus>},
> config_masks = {0, 0, 0, 0}, missing_features = {exclude_guest = false, checked = false}, mem_events = 0x0}
Thanks for helping, I'm not able to repro this, so extra debugging
would be useful for me. Here sysfs_aliases_loaded is false as we'll
load the PMU aliases when there is a request to pmu__have_event. This
looks pretty ordinary.
> (gdb) s
> 208 if (!pmu)
> (gdb) s
> 211 for (size_t i = 0; i < ARRAY_SIZE(test_events); i++) {
> (gdb) s
> 212 ret = do_test(i, with_pmu, /*with_alias=*/false);
> (gdb) s
> do_test (i=0, with_pmu=false, with_alias=false) at tests/hwmon_pmu.c:136
> 136 {
> (gdb) n
> 137 const char *test_event = with_alias ? test_events[i].alias : test_events[i].name;
> (gdb) n
> 138 struct evlist *evlist = evlist__new();
> (gdb) n
> 143 bool found = false;
> (gdb) n
> 145 if (!evlist) {
> (gdb) n
> 150 if (with_pmu)
> (gdb) n
> 153 strlcpy(str, test_event, sizeof(str));
> (gdb) n
> 155 pr_debug("Testing '%s'\n", str);
> (gdb) p str
> $4 = "temp_test_hwmon_event1\000\000\004\000\000\000\000\000\000\000\274\204z\000\000\000\000\000΄z\000\000\000\000\000\021\000\000\000\000\000\000\000 \305\377\377\377\177\000\000߄z\000\000\000\000\000\353\204z\000\000\000\000\000\376\204z\000\000\000\000\000\n\205z\000\000\000\000\000\021\205z\000\000\000\000\000\035\205z\000\000\000\000\0000\205z\000\000\000\000\000<\205z\000\000\000\000"
> (gdb) n
> Testing 'temp_test_hwmon_event1'
> 156 parse_events_error__init(&err);
So there was no parse event output like the expected:
```
Attempt to add: hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
..after resolving event: hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
```
The wildcard PMU lookup will call perf_pmu__have_event trying to find
a PMU with the event:
```
Breakpoint 1, perf_pmu__have_event (pmu=0x555556157f90,
name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
1816 {
(gdb) bt
#0 perf_pmu__have_event (pmu=0x555556157f90, name=0x5555560ce470
"temp_test_hwmon_event1")
at util/pmu.c:1816
#1 0x00005555557ab143 in parse_events_multi_pmu_add
(parse_state=0x7fffffffbf00,
event_name=0x5555560ce470 "temp_test_hwmon_event1", hw_config=10,
const_parsed_terms=0x0,
listp=0x7fffffffa270, loc_=0x7fffffffb120) at util/parse-events.c:1592
#2 0x00005555558108cc in parse_events_parse
(_parse_state=0x7fffffffbf00, scanner=0x555556138aa0)
at util/parse-events.y:293
#3 0x00005555557abdc2 in parse_events__scanner (str=0x7fffffffc000
"temp_test_hwmon_event1",
input=0x0, parse_state=0x7fffffffbf00) at util/parse-events.c:1870
#4 0x00005555557ac735 in __parse_events (evlist=0x55555613ca40,
str=0x7fffffffc000 "temp_test_hwmon_event1", pmu_filter=0x0,
err=0x7fffffffbff0,
fake_pmu=false, warn_if_reordered=true, fake_tp=false) at
util/parse-events.c:2139
#5 0x00005555557448ca in parse_events (evlist=0x55555613ca40,
str=0x7fffffffc000 "temp_test_hwmon_event1", err=0x7fffffffbff0)
at /home/irogers/kernel.org2/tools/perf/util/parse-events.h:41
#6 0x0000555555744f6e in do_test (i=0, with_pmu=false,
with_alias=false) at tests/hwmon_pmu.c:156
#7 0x00005555557452dd in test__hwmon_pmu (with_pmu=false) at
tests/hwmon_pmu.c:212
#8 0x000055555574538d in test__hwmon_pmu_without_pmu
(test=0x5555560a3740 <suite.hwmon_pmu>,
subtest=1) at tests/hwmon_pmu.c:229
#9 0x00005555556fc935 in start_test (test=0x5555560a3740
<suite.hwmon_pmu>, i=10, subi=1,
child=0x55555613c528, width=64, pass=1) at tests/builtin-test.c:424
#10 0x00005555556fd014 in __cmd_test (suites=0x55555613c0f0, argc=1,
argv=0x7fffffffd9c0,
skiplist=0x0) at tests/builtin-test.c:571
#11 0x00005555556fdb29 in cmd_test (argc=1, argv=0x7fffffffd9c0) at
tests/builtin-test.c:773
#12 0x000055555568043a in run_builtin (p=0x55555608f950 <commands+624>, argc=4,
argv=0x7fffffffd9c0) at perf.c:351
#13 0x00005555556806e1 in handle_internal_command (argc=4,
argv=0x7fffffffd9c0) at perf.c:404
#14 0x000055555568083a in run_argv (argcp=0x7fffffffd7bc,
argv=0x7fffffffd7b0) at perf.c:448
#15 0x0000555555680b83 in main (argc=4, argv=0x7fffffffd9c0) at perf.c:560
(gdb) p pmu->name
$1 = 0x5555560ce940 "cpu"
```
Repeating this the test hwmon_a_test_hwmon_pmu test PMU should be tested:
```
(gdb) c
Continuing.
(gdb) p pmu->name
$2 = 0x5555560d6b20 "breakpoint"
(gdb) c
Continuing.
Breakpoint 1, perf_pmu__have_event (pmu=0x555556158060,
name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
1816 {
(gdb) p pmu->name
$3 = 0x5555560d7ec0 "cstate_core"
(gdb) c
Continuing.
Breakpoint 1, perf_pmu__have_event (pmu=0x555556158610,
name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
1816 {
(gdb) p pmu->name
$4 = 0x5555560c84b0 "cstate_pkg"
(gdb) c
Continuing.
Breakpoint 1, perf_pmu__have_event (pmu=0x5555561360b0,
name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
1816 {
(gdb) p pmu->name
$5 = 0x5555560d46a0 "hwmon_a_test_hwmon_pmu"
```
which should then go into the hwmon_pmu__have_event:
```
(gdb) n
1817 if (!name)
(gdb)
1819 if (perf_pmu__is_tool(pmu) && tool_pmu__skip_event(name))
(gdb)
1821 if (perf_pmu__is_hwmon(pmu))
(gdb) n
1822 return hwmon_pmu__have_event(pmu, name);
(gdb) s
hwmon_pmu__have_event (pmu=0x5555561360b0, name=0x5555560ce470
"temp_test_hwmon_event1")
at util/hwmon_pmu.c:559
```
hwmon_pmu__have_event should return true but it is either not getting
called in your case or it is returning false. Not getting called I
find hard to understand as your output shows the test PMU was created.
It seems more likely reading the "events" and then doing the hashmap
lookup in hwmon_pmu__have_event fails. This was failing for me with
undefined behavior sanitizer because of the under initialized unions.
But that should be fixed by: "perf hwmon_pmu: Ensure hwmon key union
is zeroed before use". The particular event "temp_test_hwmon_event1"
is going to search all events as it uses the "label" name, so that
makes me think the bug is here:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n584
but I can't eye ball an issue and the test works for me even when
trying to be aggressive with sanitizers. If you could help me look I'd
appreciate it.
Thanks,
Ian
> (gdb) n
> 157 ret = parse_events(evlist, str, &err);
> (gdb) n
> Using CPUID GenuineIntel-6-B7-1
> 158 if (ret) {
> (gdb) p ret
> $5 = 1
> (gdb) n
> 159 pr_debug("FAILED %s:%d failed to parse event '%s', err %d\n",
> (gdb)
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 18:55 ` Ian Rogers
@ 2024-11-21 20:58 ` Arnaldo Carvalho de Melo
2024-11-21 21:08 ` Arnaldo Carvalho de Melo
2024-11-22 6:59 ` Ian Rogers
0 siblings, 2 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-21 20:58 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Thu, Nov 21, 2024 at 10:55:00AM -0800, Ian Rogers wrote:
> On Thu, Nov 21, 2024 at 9:22 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > On Thu, Nov 21, 2024 at 02:04:45PM -0300, Arnaldo Carvalho de Melo wrote:
> > > On Wed, Nov 20, 2024 at 04:09:55PM -0800, Ian Rogers wrote:
> > > > Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> > > > address issue with hwmon_pmu__config_terms needing to load events - a
> > > > load bearing assert fired. Also fix missing list deletion when putting
> > > > the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> > > > less spammy in verbose mode.
> >
> > > After applying this, with this series of patches on a Fedora 40 system,
> > > I get output from -v where before I needed, IIRC, to use -vv:
> > >
> > > f8244bb9bfa66f79 (HEAD -> perf-tools-next, x1/perf-tools-next) perf tests: Fix hwmon parsing with PMU name test
> > > 9ae6c7a4bd02acbd perf hwmon_pmu: Ensure hwmon key union is zeroed before use
> > > 3e37de098af38179 perf tests hwmon_pmu: Remove double evlist__delete()
> > > 0565017a0ac824c2 perf test: Correct hwmon test PMU detection
> > > 85c60a01b85ee956 (perf-tools-next/tmp.perf-tools-next, perf-tools-next/perf-tools-next) perf: Remove unused del_perf_probe_events()
> > > ⬢ [acme@toolbox perf-tools-next]$
> >
> > <SNIP>
> >
> > > root@number:~# perf test -v 11
> > > 11: Hwmon PMU :
> > > 11.1: Basic parsing test : Ok
> > > --- start ---
> > > test child forked, pid 1823259
> > > Testing 'temp_test_hwmon_event1'
> > > Using CPUID GenuineIntel-6-B7-1
> > > FAILED tests/hwmon_pmu.c:159 failed to parse event 'temp_test_hwmon_event1', err 1
> > > event syntax error: 'temp_test_hwmon_event1'
> > > \___ Bad event name
> > >
> > > Unable to find event on a PMU of 'temp_test_hwmon_event1'
> >
> > In gdb it fails on the first call to do_test() from the first test__hwmon_pmu()
> >
> > Starting program: /root/bin/perf test -F -vv 11
> > [Thread debugging using libthread_db enabled]
> > Using host libthread_db library "/lib64/libthread_db.so.1".
> > --- start ---
> > ---- end ----
> > 11.1: Basic parsing test : Ok
> > --- start ---
> >
> > Breakpoint 1, test__hwmon_pmu (with_pmu=false) at tests/hwmon_pmu.c:203
> > 203 {
> > (gdb) n
> > 205 struct perf_pmu *pmu = test_pmu_get(dir, sizeof(dir));
> > (gdb) n
> > 206 int ret = TEST_OK;
> > (gdb) p pmu
> > $2 = (struct perf_pmu *) 0xf50450
> > (gdb) p *pmu
> > $3 = {name = 0xf50ac0 "hwmon_a_test_hwmon_pmu", alias_name = 0xf50aa0 "hwmon1234", id = 0x0, type = 4294902994, selectable = false, is_core = false, is_uncore = false, auxtrace = false,
> > formats_checked = false, config_masks_present = false, config_masks_computed = false, max_precise = 0, perf_event_attr_init_default = 0x0, cpus = 0xf4fbf0, format = {next = 0xf50488,
> > prev = 0xf50488}, aliases = {next = 0xf50498, prev = 0xf50498}, events_table = 0x0, sysfs_aliases = 0, cpu_json_aliases = 0, sys_json_aliases = 0, sysfs_aliases_loaded = false,
> > cpu_aliases_added = false, caps_initialized = false, nr_caps = 0, caps = {next = 0xf504c8, prev = 0xf504c8}, list = {next = 0xedc090 <other_pmus>, prev = 0xedc090 <other_pmus>},
> > config_masks = {0, 0, 0, 0}, missing_features = {exclude_guest = false, checked = false}, mem_events = 0x0}
>
> Thanks for helping, I'm not able to repro this, so extra debugging
> would be useful for me. Here sysfs_aliases_loaded is false as we'll
> load the PMU aliases when there is a request to pmu__have_event. This
> looks pretty ordinary.
>
> > (gdb) s
> > 208 if (!pmu)
> > (gdb) s
> > 211 for (size_t i = 0; i < ARRAY_SIZE(test_events); i++) {
> > (gdb) s
> > 212 ret = do_test(i, with_pmu, /*with_alias=*/false);
> > (gdb) s
> > do_test (i=0, with_pmu=false, with_alias=false) at tests/hwmon_pmu.c:136
> > 136 {
> > (gdb) n
> > 137 const char *test_event = with_alias ? test_events[i].alias : test_events[i].name;
> > (gdb) n
> > 138 struct evlist *evlist = evlist__new();
> > (gdb) n
> > 143 bool found = false;
> > (gdb) n
> > 145 if (!evlist) {
> > (gdb) n
> > 150 if (with_pmu)
> > (gdb) n
> > 153 strlcpy(str, test_event, sizeof(str));
> > (gdb) n
> > 155 pr_debug("Testing '%s'\n", str);
> > (gdb) p str
> > $4 = "temp_test_hwmon_event1\000\000\004\000\000\000\000\000\000\000\274\204z\000\000\000\000\000΄z\000\000\000\000\000\021\000\000\000\000\000\000\000 \305\377\377\377\177\000\000߄z\000\000\000\000\000\353\204z\000\000\000\000\000\376\204z\000\000\000\000\000\n\205z\000\000\000\000\000\021\205z\000\000\000\000\000\035\205z\000\000\000\000\0000\205z\000\000\000\000\000<\205z\000\000\000\000"
> > (gdb) n
> > Testing 'temp_test_hwmon_event1'
> > 156 parse_events_error__init(&err);
>
> So there was no parse event output like the expected:
> ```
> Attempt to add: hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
> ..after resolving event: hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
> ```
> The wildcard PMU lookup will call perf_pmu__have_event trying to find
> a PMU with the event:
> ```
> Breakpoint 1, perf_pmu__have_event (pmu=0x555556157f90,
> name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> 1816 {
> (gdb) bt
> #0 perf_pmu__have_event (pmu=0x555556157f90, name=0x5555560ce470
> "temp_test_hwmon_event1")
> at util/pmu.c:1816
> #1 0x00005555557ab143 in parse_events_multi_pmu_add
> (parse_state=0x7fffffffbf00,
> event_name=0x5555560ce470 "temp_test_hwmon_event1", hw_config=10,
> const_parsed_terms=0x0,
> listp=0x7fffffffa270, loc_=0x7fffffffb120) at util/parse-events.c:1592
> #2 0x00005555558108cc in parse_events_parse
> (_parse_state=0x7fffffffbf00, scanner=0x555556138aa0)
> at util/parse-events.y:293
> #3 0x00005555557abdc2 in parse_events__scanner (str=0x7fffffffc000
> "temp_test_hwmon_event1",
> input=0x0, parse_state=0x7fffffffbf00) at util/parse-events.c:1870
> #4 0x00005555557ac735 in __parse_events (evlist=0x55555613ca40,
> str=0x7fffffffc000 "temp_test_hwmon_event1", pmu_filter=0x0,
> err=0x7fffffffbff0,
> fake_pmu=false, warn_if_reordered=true, fake_tp=false) at
> util/parse-events.c:2139
> #5 0x00005555557448ca in parse_events (evlist=0x55555613ca40,
> str=0x7fffffffc000 "temp_test_hwmon_event1", err=0x7fffffffbff0)
> at /home/irogers/kernel.org2/tools/perf/util/parse-events.h:41
> #6 0x0000555555744f6e in do_test (i=0, with_pmu=false,
> with_alias=false) at tests/hwmon_pmu.c:156
> #7 0x00005555557452dd in test__hwmon_pmu (with_pmu=false) at
> tests/hwmon_pmu.c:212
> #8 0x000055555574538d in test__hwmon_pmu_without_pmu
> (test=0x5555560a3740 <suite.hwmon_pmu>,
> subtest=1) at tests/hwmon_pmu.c:229
> #9 0x00005555556fc935 in start_test (test=0x5555560a3740
> <suite.hwmon_pmu>, i=10, subi=1,
> child=0x55555613c528, width=64, pass=1) at tests/builtin-test.c:424
> #10 0x00005555556fd014 in __cmd_test (suites=0x55555613c0f0, argc=1,
> argv=0x7fffffffd9c0,
> skiplist=0x0) at tests/builtin-test.c:571
> #11 0x00005555556fdb29 in cmd_test (argc=1, argv=0x7fffffffd9c0) at
> tests/builtin-test.c:773
> #12 0x000055555568043a in run_builtin (p=0x55555608f950 <commands+624>, argc=4,
> argv=0x7fffffffd9c0) at perf.c:351
> #13 0x00005555556806e1 in handle_internal_command (argc=4,
> argv=0x7fffffffd9c0) at perf.c:404
> #14 0x000055555568083a in run_argv (argcp=0x7fffffffd7bc,
> argv=0x7fffffffd7b0) at perf.c:448
> #15 0x0000555555680b83 in main (argc=4, argv=0x7fffffffd9c0) at perf.c:560
> (gdb) p pmu->name
> $1 = 0x5555560ce940 "cpu"
> ```
> Repeating this the test hwmon_a_test_hwmon_pmu test PMU should be tested:
> ```
> (gdb) c
> Continuing.
>
> (gdb) p pmu->name
> $2 = 0x5555560d6b20 "breakpoint"
> (gdb) c
> Continuing.
>
> Breakpoint 1, perf_pmu__have_event (pmu=0x555556158060,
> name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> 1816 {
> (gdb) p pmu->name
> $3 = 0x5555560d7ec0 "cstate_core"
> (gdb) c
> Continuing.
>
> Breakpoint 1, perf_pmu__have_event (pmu=0x555556158610,
> name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> 1816 {
> (gdb) p pmu->name
> $4 = 0x5555560c84b0 "cstate_pkg"
> (gdb) c
> Continuing.
>
> Breakpoint 1, perf_pmu__have_event (pmu=0x5555561360b0,
> name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> 1816 {
> (gdb) p pmu->name
> $5 = 0x5555560d46a0 "hwmon_a_test_hwmon_pmu"
> ```
> which should then go into the hwmon_pmu__have_event:
> ```
> (gdb) n
> 1817 if (!name)
> (gdb)
> 1819 if (perf_pmu__is_tool(pmu) && tool_pmu__skip_event(name))
> (gdb)
> 1821 if (perf_pmu__is_hwmon(pmu))
> (gdb) n
> 1822 return hwmon_pmu__have_event(pmu, name);
> (gdb) s
> hwmon_pmu__have_event (pmu=0x5555561360b0, name=0x5555560ce470
> "temp_test_hwmon_event1")
> at util/hwmon_pmu.c:559
> ```
> hwmon_pmu__have_event should return true but it is either not getting
> called in your case or it is returning false. Not getting called I
> find hard to understand as your output shows the test PMU was created.
> It seems more likely reading the "events" and then doing the hashmap
> lookup in hwmon_pmu__have_event fails. This was failing for me with
> undefined behavior sanitizer because of the under initialized unions.
> But that should be fixed by: "perf hwmon_pmu: Ensure hwmon key union
> is zeroed before use". The particular event "temp_test_hwmon_event1"
> is going to search all events as it uses the "label" name, so that
> makes me think the bug is here:
> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n584
> but I can't eye ball an issue and the test works for me even when
> trying to be aggressive with sanitizers. If you could help me look I'd
> appreciate it.
Where is that "temp_test_hwmon_event1" added?
I see it at:
⬢ [acme@toolbox perf-tools-next]$ git grep -B6 -A10 temp_test_hwmon_event1 tools/
tools/perf/tests/hwmon_pmu.c-static const struct test_event {
tools/perf/tests/hwmon_pmu.c- const char *name;
tools/perf/tests/hwmon_pmu.c- const char *alias;
tools/perf/tests/hwmon_pmu.c- long config;
tools/perf/tests/hwmon_pmu.c-} test_events[] = {
tools/perf/tests/hwmon_pmu.c- {
tools/perf/tests/hwmon_pmu.c: "temp_test_hwmon_event1",
tools/perf/tests/hwmon_pmu.c- "temp1",
tools/perf/tests/hwmon_pmu.c- 0xA0001,
tools/perf/tests/hwmon_pmu.c- },
tools/perf/tests/hwmon_pmu.c- {
tools/perf/tests/hwmon_pmu.c- "temp_test_hwmon_event2",
tools/perf/tests/hwmon_pmu.c- "temp2",
tools/perf/tests/hwmon_pmu.c- 0xA0002,
tools/perf/tests/hwmon_pmu.c- },
tools/perf/tests/hwmon_pmu.c-};
tools/perf/tests/hwmon_pmu.c-
⬢ [acme@toolbox perf-tools-next]$
And then it is used in do_test() for looking it up in the hwmon that
should have been added via:
test_pmu_get()
perf_pmus__add_test_hwmon_pmu()
And we have:
root@number:~# ls -la /tmp/perf-hwmon-pmu-test-YPH4sb/
total 16
drwx------. 3 root root 140 Nov 21 16:15 .
drwxrwxrwt. 41 root root 1180 Nov 21 17:33 ..
drwxr-xr-x. 2 root root 60 Nov 21 16:15 hwmon1234
-rw-------. 1 root root 6 Nov 21 16:15 temp1_input
-rw-------. 1 root root 18 Nov 21 16:15 temp1_label
-rw-------. 1 root root 6 Nov 21 16:15 temp2_input
-rw-------. 1 root root 18 Nov 21 16:15 temp2_label
root@number:~#
So it should parse that dir, and then associate the alias that is the
prefix for the files, etc. Ok, then we have:
root@number:~# perf probe -x ~/bin/perf -L hwmon_pmu__have_event
<hwmon_pmu__have_event@/home/acme/git/perf-tools-next/tools/perf/util/hwmon_pmu.c:0>
0 bool hwmon_pmu__have_event(struct perf_pmu *pmu, const char *name)
1 {
2 struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
enum hwmon_type type;
int number;
5 union hwmon_pmu_event_key key = { .type_and_num = 0 };
struct hashmap_entry *cur;
size_t bkt;
9 if (!parse_hwmon_filename(name, &type, &number, /*item=*/NULL, /*is_alarm=*/NULL))
10 return false;
12 if (hwmon_pmu__read_events(hwm))
13 return false;
15 key.type = type;
16 key.num = number;
17 if (hashmap_find(&hwm->events, key.type_and_num, /*value=*/NULL))
18 return true;
19 if (key.num != -1)
20 return false;
/* Item is of form <type>_ which means we should match <type>_<label>. */
22 hashmap__for_each_entry((&hwm->events), cur, bkt) {
23 struct hwmon_pmu_event_value *value = cur->pvalue;
25 key.type_and_num = cur->key;
26 if (key.type == type && value->name && !strcasecmp(name, value->name))
27 return true;
}
29 return false;
30 }
static int hwmon_pmu__config_term(const struct hwmon_pmu *hwm,
struct perf_event_attr *attr,
root@number:~#
Probing at the start and end, it gets called, and it returns false.
root@number:~# perf probe -l;
probe_perf:hwmon_pmu__have_event (on hwmon_pmu__have_event:1@util/hwmon_pmu.c in /home/acme/bin/perf with name_string)
probe_perf:hwmon_pmu__have_event__return (on hwmon_pmu__have_event%return@util/hwmon_pmu.c in /home/acme/bin/perf with arg1)
root@number:~# perf trace --libtrace -e probe_perf:* perf test -F 11
11.1: Basic parsing test : Ok
0.000 :146016/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.017 :146016/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
0.021 :146016/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.031 :146016/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
0.034 :146016/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.189 :146016/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
0.192 :146016/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.203 :146016/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
0.205 :146016/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.221 :146016/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
0.224 :146016/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.234 :146016/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
event syntax error: 'temp_test_hwmon_event1'
\___ Bad event name
Unable to find event on a PMU of 'temp_test_hwmon_event1'
11.2: Parsing without PMU name : FAILED!
3.701 perf/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
3.705 perf/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
3.707 perf/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
3.710 perf/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
3.712 perf/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
3.713 perf/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
3.714 perf/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
3.716 perf/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
3.717 perf/146016 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
3.718 perf/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
3.870 perf/146016 probe_perf:hwmon_pmu__have_event(event syntax error: 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
\___ Bad event or PMU
(6611f1) name_string="hwmon_a_test_hwmon_pmu"
Unable to find PMU or event on a PMU of 'hwmon_a_test_hwmon_pmu'
)
3.871 perf/146016 probe_perf:hwmon_pmu__have_event__return((6611e1 <- 6570de) arg1=0x0)
11.3: Parsing with PMU name : FAILED!
root@number:~#
So lets see what is the return false we're getting:
root@number:~# perf probe -d probe_perf:hwmon_pmu__have_event__return
Removed event: probe_perf:hwmon_pmu__have_event__return
root@number:~# perf probe -l
probe_perf:hwmon_pmu__have_event (on hwmon_pmu__have_event:1@util/hwmon_pmu.c in /home/acme/bin/perf with name_string)
root@number:~# perf probe -x ~/bin/perf hwmon_pmu__have_event:10
Added new event:
probe_perf:hwmon_pmu__have_event_L10 (on hwmon_pmu__have_event:10 in /home/acme/bin/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:hwmon_pmu__have_event_L10 -aR sleep 1
root@number:~# perf probe -x ~/bin/perf hwmon_pmu__have_event:13
Added new event:
probe_perf:hwmon_pmu__have_event_L13 (on hwmon_pmu__have_event:13 in /home/acme/bin/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:hwmon_pmu__have_event_L13 -aR sleep 1
root@number:~# perf probe -x ~/bin/perf hwmon_pmu__have_event:20
Added new event:
probe_perf:hwmon_pmu__have_event_L20 (on hwmon_pmu__have_event:20 in /home/acme/bin/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:hwmon_pmu__have_event_L20 -aR sleep 1
root@number:~# perf probe -x ~/bin/perf hwmon_pmu__have_event:29
Added new event:
probe_perf:hwmon_pmu__have_event_L29 (on hwmon_pmu__have_event:29 in /home/acme/bin/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:hwmon_pmu__have_event_L29 -aR sleep 1
root@number:~# perf probe -l
probe_perf:hwmon_pmu__have_event (on hwmon_pmu__have_event:1@util/hwmon_pmu.c in /home/acme/bin/perf with name_string)
probe_perf:hwmon_pmu__have_event_L10 (on hwmon_pmu__have_event:10@util/hwmon_pmu.c in /home/acme/bin/perf)
probe_perf:hwmon_pmu__have_event_L13 (on hwmon_pmu__have_event:13@util/hwmon_pmu.c in /home/acme/bin/perf)
probe_perf:hwmon_pmu__have_event_L20 (on hwmon_pmu__have_event:20@util/hwmon_pmu.c in /home/acme/bin/perf)
probe_perf:hwmon_pmu__have_event_L29 (on hwmon_pmu__have_event:29@util/hwmon_pmu.c in /home/acme/bin/perf)
root@number:~#
root@number:~# perf trace --libtrace -e probe_perf:* perf test -F 11
11.1: Basic parsing test : Ok
event syntax error: 'temp_test_hwmon_event1'
\___ Bad event name
Unable to find event on a PMU of 'temp_test_hwmon_event1'
0.000 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.029 perf/146265 probe_perf:hwmon_pmu__have_event_L29((66135d))
0.032 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.040 perf/146265 probe_perf:hwmon_pmu__have_event_L29((66135d))
0.042 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.194 perf/146265 probe_perf:hwmon_pmu__have_event_L29((66135d))
0.196 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.206 perf/146265 probe_perf:hwmon_pmu__have_event_L29((66135d))
0.207 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.221 perf/146265 probe_perf:hwmon_pmu__have_event_L29((66135d))
0.223 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
0.232 perf/146265 probe_perf:hwmon_pmu__have_event_L29((66135d))
11.2: Parsing without PMU name : FAILED!
4.068 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
4.076 perf/146265 probe_perf:hwmon_pmu__have_event_L10((66123e))
4.078 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
4.080 perf/146265 probe_perf:hwmon_pmu__have_event_L10((66123e))
4.081 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
4.083 perf/146265 probe_perf:hwmon_pmu__have_event_L10((66123e))
4.084 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
4.086 perf/146265 probe_perf:hwmon_pmu__have_event_L10((66123e))
4.088 perf/146265 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
4.089 perf/146265 probe_perf:hwmon_pmu__have_event_L10((66123e))
4.272 event syntax error: 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
perf/ \___ Bad event or PMU
146265
Unable to find PMU or event on a PMU of 'hwmon_a_test_hwmon_pmu'
probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
4.274 perf/146265 probe_perf:hwmon_pmu__have_event_L10((66123e))
11.3: Parsing with PMU name : FAILED!
root@number:~#
So for the "Unable to find event on a PMU of 'temp_test_hwmon_event1'"
case its the last 'return false', while for the "Parsing without PMU
name" case its all in line 10, i.e.
9 if (!parse_hwmon_filename(name, &type, &number, /*item=*/NULL, /*is_alarm=*/NULL))
10 return false;
root@number:~# perf probe -x ~/bin/perf parse_hwmon_filename filename:string
Unable to find event on a PMU of 'temp_test_hwmon_event1'
11.2: Parsing without PMU name : FAILED!
6.436 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.446 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.452 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.454 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.488 perf/146683 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.490 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.492 perf/146683 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.494 perf/146683 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.495 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.497 perf/146683 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.499 perf/146683 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.500 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.502 perf/146683 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.504 perf/146683 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.505 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.507 perf/146683 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.508 perf/146683 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.510 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.512 perf/146683 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.655 perf/146683 event syntax error: 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
probe_perf:hwmon_pmu__have_event( \___ Bad event or PMU
(6611f1) name_string="hwmon_a_test_hwmon_pmu"
Unable to find PMU or event on a PMU of 'hwmon_a_test_hwmon_pmu'
)
6.658 perf/146683 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.660 perf/146683 probe_perf:hwmon_pmu__have_event_L10((66123e))
11.3: Parsing with PMU name : FAILED!
root@number:~#
Hope this helps,
- Arnaldo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 20:58 ` Arnaldo Carvalho de Melo
@ 2024-11-21 21:08 ` Arnaldo Carvalho de Melo
2024-11-22 6:59 ` Ian Rogers
1 sibling, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-21 21:08 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Thu, Nov 21, 2024 at 05:58:09PM -0300, Arnaldo Carvalho de Melo wrote:
> root@number:~# perf probe -x ~/bin/perf -L hwmon_pmu__have_event
> <hwmon_pmu__have_event@/home/acme/git/perf-tools-next/tools/perf/util/hwmon_pmu.c:0>
> 0 bool hwmon_pmu__have_event(struct perf_pmu *pmu, const char *name)
> 1 {
> 2 struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
> enum hwmon_type type;
> int number;
> 5 union hwmon_pmu_event_key key = { .type_and_num = 0 };
> struct hashmap_entry *cur;
> size_t bkt;
>
> 9 if (!parse_hwmon_filename(name, &type, &number, /*item=*/NULL, /*is_alarm=*/NULL))
> 10 return false;
>
> 12 if (hwmon_pmu__read_events(hwm))
> 13 return false;
>
> 15 key.type = type;
> 16 key.num = number;
> 17 if (hashmap_find(&hwm->events, key.type_and_num, /*value=*/NULL))
> 18 return true;
> 19 if (key.num != -1)
> 20 return false;
> /* Item is of form <type>_ which means we should match <type>_<label>. */
> 22 hashmap__for_each_entry((&hwm->events), cur, bkt) {
> 23 struct hwmon_pmu_event_value *value = cur->pvalue;
>
> 25 key.type_and_num = cur->key;
> 26 if (key.type == type && value->name && !strcasecmp(name, value->name))
> 27 return true;
> }
> 29 return false;
> 30 }
To read all the values it looks for in the hashmap:
root@number:~# perf probe -x ~/bin/perf hwmon_pmu__have_event:25 'value->name:string'
Added new events:
probe_perf:hwmon_pmu__have_event_L25 (on hwmon_pmu__have_event:25 in /home/acme/bin/perf with name=value->name:string)
probe_perf:hwmon_pmu__have_event_L25 (on hwmon_pmu__have_event:25 in /home/acme/bin/perf with name=value->name:string)
You can now use it in all perf tools, such as:
perf record -e probe_perf:hwmon_pmu__have_event_L25 -aR sleep 1
root@number:~#
root@number:~# perf trace --libtrace -e probe_perf:* perf test -F 11
11.1: Basic parsing test : Ok
0.000 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="cpu0_accuracy")
0.044 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_input")
0.054 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="fan2_vid")
0.062 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="power3_crit_alarm")
0.069 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="intrusion4_average_interval_min_alarm")
0.076 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="badtype5_baditem")
0.083 :147400/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="humidity6_baditem")
1.936 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
1.938 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
1.942 perf/147400 probe_perf:hwmon_pmu__have_event_L29((66135d))
1.944 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
1.945 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
1.949 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="uevent")
1.950 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_input")
1.952 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="name")
1.954 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_input")
1.957 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
1.959 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
1.961 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
1.962 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
1.964 perf/147400 probe_perf:hwmon_pmu__have_event_L29((66135d))
1.965 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
1.966 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
1.991 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp42_input")
1.993 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp26_input")
1.994 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="uevent")
1.996 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp10_crit_alarm")
1.997 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp35_crit_alarm")
1.999 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp37_max")
2.001 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp30_label")
2.005 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp34_crit")
2.006 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp14_label")
2.010 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp36_input")
2.011 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp40_max")
2.013 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp6_input")
2.014 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp22_crit")
2.016 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp40_label")
2.019 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp44_max")
2.021 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_crit_alarm")
2.023 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp44_crit_alarm")
2.024 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp10_crit")
2.026 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp34_label")
2.029 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp18_label")
2.032 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp45_crit")
2.034 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_crit")
2.035 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_max")
2.037 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp44_label")
2.040 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp6_max")
2.041 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp30_max")
2.042 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp38_crit_alarm")
2.044 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp34_max")
2.045 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp39_crit")
2.047 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp38_label")
2.050 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp43_input")
2.051 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp18_crit_alarm")
2.053 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp38_max")
2.054 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp42_crit_alarm")
2.056 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp10_input")
2.057 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp44_crit")
2.059 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_label")
2.063 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp41_max")
2.064 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp22_crit_alarm")
2.066 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_crit")
2.067 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp37_input")
2.069 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp45_max")
2.070 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp41_label")
2.074 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp30_input")
2.075 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp14_input")
2.077 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp38_crit")
2.078 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp35_label")
2.081 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp36_crit_alarm")
2.083 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp26_crit")
2.084 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp40_input")
2.085 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp40_crit_alarm")
2.087 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp43_crit")
2.088 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp45_label")
2.092 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp14_crit")
2.093 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp34_input")
2.094 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp45_crit_alarm")
2.096 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp35_max")
2.097 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp18_input")
2.099 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp10_max")
2.100 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp39_label")
2.103 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp22_label")
2.106 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp6_crit")
2.108 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp39_max")
2.109 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp44_input")
2.111 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp14_max")
2.112 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp37_crit")
2.114 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp42_max")
2.115 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_label")
2.123 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp18_max")
2.124 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp38_input")
2.125 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp34_crit_alarm")
2.127 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp42_crit")
2.128 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp42_label")
2.131 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp26_label")
2.134 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp14_crit_alarm")
2.136 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp39_crit_alarm")
2.137 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp30_crit")
2.138 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_input")
2.140 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_crit_alarm")
2.141 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp43_crit_alarm")
2.143 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp36_label")
2.146 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp6_label")
2.149 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp36_crit")
2.151 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp41_input")
2.152 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp6_crit_alarm")
2.153 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp36_max")
2.155 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp35_input")
2.156 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp41_crit")
2.158 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp45_input")
2.159 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp43_max")
2.160 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp37_crit_alarm")
2.162 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp18_crit")
2.163 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp41_crit_alarm")
2.165 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp35_crit")
2.166 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp22_max")
2.168 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp39_input")
2.169 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp22_input")
2.170 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_max")
2.172 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp43_label")
2.175 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp26_max")
2.177 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp10_label")
2.180 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp40_crit")
2.181 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="name")
2.183 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp26_crit_alarm")
2.184 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_input")
2.186 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp37_label")
2.189 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp30_crit_alarm")
2.191 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_34")
2.192 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_34")
2.194 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_39")
2.195 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_39")
2.197 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_36")
2.198 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_36")
2.199 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_28")
2.201 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_28")
2.202 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_41")
2.203 perf/147400 event syntax error: 'temp_test_hwmon_event1'
probe_perf:hwmon_pmu__have_event_L25( \___ Bad event name
(6612ef) name="temp_core_41"
Unable to find event on a PMU of 'temp_test_hwmon_event1'
)
2.205 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_package_id_0")
2.206 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_package_id_0")
2.208 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_20")
2.209 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_20")
2.210 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_33")
2.212 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_33")
2.213 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_12")
2.215 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_12")
2.216 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_4")
2.217 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_4")
2.219 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_38")
2.220 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_38")
2.221 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_43")
2.223 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_43")
2.224 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_35")
2.226 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_35")
2.227 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_40")
2.228 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_40")
2.230 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_32")
2.231 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_32")
2.233 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_24")
2.234 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_24")
2.235 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_37")
2.237 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_37")
2.238 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_16")
2.239 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_16")
2.241 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_8")
2.242 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_8")
2.244 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_42")
2.245 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_42")
2.246 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_core_0")
2.248 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_core_0")
2.249 perf/147400 probe_perf:hwmon_pmu__have_event_L29((66135d))
2.251 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
2.252 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
2.256 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="uevent")
2.258 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp6_input")
2.259 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp3_input")
2.261 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp4_input")
2.262 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_input")
2.264 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp5_input")
2.265 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="name")
2.267 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp2_input")
2.269 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.270 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.272 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.273 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.275 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.277 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.278 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.280 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.281 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.283 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.285 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.286 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.287 perf/147400 probe_perf:hwmon_pmu__have_event_L29((66135d))
2.289 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
2.290 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
2.294 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="uevent")
2.295 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_label")
2.299 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_crit")
2.301 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_alarm")
2.302 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_input")
2.303 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_min")
2.305 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_max")
2.306 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="name")
2.308 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="temp_composite")
2.309 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="temp_composite")
2.311 perf/147400 probe_perf:hwmon_pmu__have_event_L29((66135d))
2.312 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="temp_test_hwmon_event1")
2.313 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
2.317 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="uevent")
2.319 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_lcrit_alarm")
2.320 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_enable")
2.322 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_crit")
2.323 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_lcrit")
2.325 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_min_alarm")
2.326 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_input")
2.328 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_crit_alarm")
2.329 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_min")
2.331 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_max_alarm")
2.332 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp1_max")
2.334 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="name")
2.335 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612e8) name="")
2.337 perf/147400 probe_perf:hwmon_pmu__have_event_L25((6612ef) name="")
2.338 perf/147400 probe_perf:hwmon_pmu__have_event_L29((66135d))
11.2: Parsing without PMU name : FAILED!
6.499 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.517 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.526 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.530 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="temp_test_hwmon_event1")
6.596 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.599 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.602 perf/147400 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.606 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.609 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.612 perf/147400 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.615 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.618 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.621 perf/147400 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.624 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.627 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.630 perf/147400 probe_perf:hwmon_pmu__have_event_L10((66123e))
6.633 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.636 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.638 perf/147400 probe_perf:hwmon_pmu__have_event_L10((66123e))
event syntax error: 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
\___ Bad event or PMU
Unable to find PMU or event on a PMU of 'hwmon_a_test_hwmon_pmu'
6.895 perf/147400 probe_perf:hwmon_pmu__have_event((6611f1) name_string="hwmon_a_test_hwmon_pmu")
6.900 perf/147400 probe_perf:parse_hwmon_filename((65fd14) filename_string="hwmon_a_test_hwmon_pmu")
6.904 perf/147400 probe_perf:hwmon_pmu__have_event_L10((66123e))
11.3: Parsing with PMU name : FAILED!
root@number:~#
And before the hashmap__find() at line 17:
> 15 key.type = type;
> 16 key.num = number;
> 17 if (hashmap_find(&hwm->events, key.type_and_num, /*value=*/NULL))
> 18 return true;
root@number:~# perf probe -x ~/bin/perf hwmon_pmu__have_event:17 type number
Added new events:
probe_perf:hwmon_pmu__have_event_L17 (on hwmon_pmu__have_event:17 in /home/acme/bin/perf with type number)
probe_perf:hwmon_pmu__have_event_L17 (on hwmon_pmu__have_event:17 in /home/acme/bin/perf with type number)
probe_perf:hwmon_pmu__have_event_L17 (on hwmon_pmu__have_event:17 in /home/acme/bin/perf with type number)
probe_perf:hwmon_pmu__have_event_L17 (on hwmon_pmu__have_event:17 in /home/acme/bin/perf with type number)
You can now use it in all perf tools, such as:
perf record -e probe_perf:hwmon_pmu__have_event_L17 -aR sleep 1
root@number:~#
root@number:~# perf trace --libtrace -e probe_perf:hwmon_pmu__have_event_L17 perf test -F 11
11.1: Basic parsing test : Ok
0.000 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((66126f) type=0xa number=-1)
0.011 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((661273) type=0xa number=-1)
0.013 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((66127e) type=0xa number=-1)
0.015 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((66128e) type=0xa number=-1)
0.021 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((66126f) type=0xa number=-1)
0.022 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((661273) type=0xa number=-1)
0.023 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((66127e) type=0xa number=-1)
0.024 :147579/147579 probe_perf:hwmon_pmu__have_event_L17((66128e) type=0xa number=-1)
event syntax error: 'temp_test_hwmon_event1'
\___ Bad event name
Unable to find event on a PMU of 'temp_test_hwmon_event1'
0.160 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66126f) type=0xa number=-1)
0.162 perf/147579 probe_perf:hwmon_pmu__have_event_L17((661273) type=0xa number=-1)
0.163 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66127e) type=0xa number=-1)
0.165 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66128e) type=0xa number=-1)
0.172 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66126f) type=0xa number=-1)
0.173 perf/147579 probe_perf:hwmon_pmu__have_event_L17((661273) type=0xa number=-1)
0.174 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66127e) type=0xa number=-1)
0.175 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66128e) type=0xa number=-1)
0.185 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66126f) type=0xa number=-1)
0.186 perf/147579 probe_perf:hwmon_pmu__have_event_L17((661273) type=0xa number=-1)
0.187 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66127e) type=0xa number=-1)
0.189 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66128e) type=0xa number=-1)
0.213 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66126f) type=0xa number=-1)
0.214 perf/147579 probe_perf:hwmon_pmu__have_event_L17((661273) type=0xa number=-1)
0.216 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66127e) type=0xa number=-1)
0.217 perf/147579 probe_perf:hwmon_pmu__have_event_L17((66128e) type=0xa number=-1)
11.2: Parsing without PMU name : FAILED!
event syntax error: 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
\___ Bad event or PMU
Unable to find PMU or event on a PMU of 'hwmon_a_test_hwmon_pmu'
11.3: Parsing with PMU name : FAILED!
root@number:~#
- Arnaldo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 20:58 ` Arnaldo Carvalho de Melo
2024-11-21 21:08 ` Arnaldo Carvalho de Melo
@ 2024-11-22 6:59 ` Ian Rogers
1 sibling, 0 replies; 9+ messages in thread
From: Ian Rogers @ 2024-11-22 6:59 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Thu, Nov 21, 2024 at 12:58 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Thu, Nov 21, 2024 at 10:55:00AM -0800, Ian Rogers wrote:
> > On Thu, Nov 21, 2024 at 9:22 AM Arnaldo Carvalho de Melo
> > <acme@kernel.org> wrote:
> > >
> > > On Thu, Nov 21, 2024 at 02:04:45PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > On Wed, Nov 20, 2024 at 04:09:55PM -0800, Ian Rogers wrote:
> > > > > Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> > > > > address issue with hwmon_pmu__config_terms needing to load events - a
> > > > > load bearing assert fired. Also fix missing list deletion when putting
> > > > > the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> > > > > less spammy in verbose mode.
> > >
> > > > After applying this, with this series of patches on a Fedora 40 system,
> > > > I get output from -v where before I needed, IIRC, to use -vv:
> > > >
> > > > f8244bb9bfa66f79 (HEAD -> perf-tools-next, x1/perf-tools-next) perf tests: Fix hwmon parsing with PMU name test
> > > > 9ae6c7a4bd02acbd perf hwmon_pmu: Ensure hwmon key union is zeroed before use
> > > > 3e37de098af38179 perf tests hwmon_pmu: Remove double evlist__delete()
> > > > 0565017a0ac824c2 perf test: Correct hwmon test PMU detection
> > > > 85c60a01b85ee956 (perf-tools-next/tmp.perf-tools-next, perf-tools-next/perf-tools-next) perf: Remove unused del_perf_probe_events()
> > > > ⬢ [acme@toolbox perf-tools-next]$
> > >
> > > <SNIP>
> > >
> > > > root@number:~# perf test -v 11
> > > > 11: Hwmon PMU :
> > > > 11.1: Basic parsing test : Ok
> > > > --- start ---
> > > > test child forked, pid 1823259
> > > > Testing 'temp_test_hwmon_event1'
> > > > Using CPUID GenuineIntel-6-B7-1
> > > > FAILED tests/hwmon_pmu.c:159 failed to parse event 'temp_test_hwmon_event1', err 1
> > > > event syntax error: 'temp_test_hwmon_event1'
> > > > \___ Bad event name
> > > >
> > > > Unable to find event on a PMU of 'temp_test_hwmon_event1'
> > >
> > > In gdb it fails on the first call to do_test() from the first test__hwmon_pmu()
> > >
> > > Starting program: /root/bin/perf test -F -vv 11
> > > [Thread debugging using libthread_db enabled]
> > > Using host libthread_db library "/lib64/libthread_db.so.1".
> > > --- start ---
> > > ---- end ----
> > > 11.1: Basic parsing test : Ok
> > > --- start ---
> > >
> > > Breakpoint 1, test__hwmon_pmu (with_pmu=false) at tests/hwmon_pmu.c:203
> > > 203 {
> > > (gdb) n
> > > 205 struct perf_pmu *pmu = test_pmu_get(dir, sizeof(dir));
> > > (gdb) n
> > > 206 int ret = TEST_OK;
> > > (gdb) p pmu
> > > $2 = (struct perf_pmu *) 0xf50450
> > > (gdb) p *pmu
> > > $3 = {name = 0xf50ac0 "hwmon_a_test_hwmon_pmu", alias_name = 0xf50aa0 "hwmon1234", id = 0x0, type = 4294902994, selectable = false, is_core = false, is_uncore = false, auxtrace = false,
> > > formats_checked = false, config_masks_present = false, config_masks_computed = false, max_precise = 0, perf_event_attr_init_default = 0x0, cpus = 0xf4fbf0, format = {next = 0xf50488,
> > > prev = 0xf50488}, aliases = {next = 0xf50498, prev = 0xf50498}, events_table = 0x0, sysfs_aliases = 0, cpu_json_aliases = 0, sys_json_aliases = 0, sysfs_aliases_loaded = false,
> > > cpu_aliases_added = false, caps_initialized = false, nr_caps = 0, caps = {next = 0xf504c8, prev = 0xf504c8}, list = {next = 0xedc090 <other_pmus>, prev = 0xedc090 <other_pmus>},
> > > config_masks = {0, 0, 0, 0}, missing_features = {exclude_guest = false, checked = false}, mem_events = 0x0}
> >
> > Thanks for helping, I'm not able to repro this, so extra debugging
> > would be useful for me. Here sysfs_aliases_loaded is false as we'll
> > load the PMU aliases when there is a request to pmu__have_event. This
> > looks pretty ordinary.
> >
> > > (gdb) s
> > > 208 if (!pmu)
> > > (gdb) s
> > > 211 for (size_t i = 0; i < ARRAY_SIZE(test_events); i++) {
> > > (gdb) s
> > > 212 ret = do_test(i, with_pmu, /*with_alias=*/false);
> > > (gdb) s
> > > do_test (i=0, with_pmu=false, with_alias=false) at tests/hwmon_pmu.c:136
> > > 136 {
> > > (gdb) n
> > > 137 const char *test_event = with_alias ? test_events[i].alias : test_events[i].name;
> > > (gdb) n
> > > 138 struct evlist *evlist = evlist__new();
> > > (gdb) n
> > > 143 bool found = false;
> > > (gdb) n
> > > 145 if (!evlist) {
> > > (gdb) n
> > > 150 if (with_pmu)
> > > (gdb) n
> > > 153 strlcpy(str, test_event, sizeof(str));
> > > (gdb) n
> > > 155 pr_debug("Testing '%s'\n", str);
> > > (gdb) p str
> > > $4 = "temp_test_hwmon_event1\000\000\004\000\000\000\000\000\000\000\274\204z\000\000\000\000\000΄z\000\000\000\000\000\021\000\000\000\000\000\000\000 \305\377\377\377\177\000\000߄z\000\000\000\000\000\353\204z\000\000\000\000\000\376\204z\000\000\000\000\000\n\205z\000\000\000\000\000\021\205z\000\000\000\000\000\035\205z\000\000\000\000\0000\205z\000\000\000\000\000<\205z\000\000\000\000"
> > > (gdb) n
> > > Testing 'temp_test_hwmon_event1'
> > > 156 parse_events_error__init(&err);
> >
> > So there was no parse event output like the expected:
> > ```
> > Attempt to add: hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
> > ..after resolving event: hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
> > ```
> > The wildcard PMU lookup will call perf_pmu__have_event trying to find
> > a PMU with the event:
> > ```
> > Breakpoint 1, perf_pmu__have_event (pmu=0x555556157f90,
> > name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> > 1816 {
> > (gdb) bt
> > #0 perf_pmu__have_event (pmu=0x555556157f90, name=0x5555560ce470
> > "temp_test_hwmon_event1")
> > at util/pmu.c:1816
> > #1 0x00005555557ab143 in parse_events_multi_pmu_add
> > (parse_state=0x7fffffffbf00,
> > event_name=0x5555560ce470 "temp_test_hwmon_event1", hw_config=10,
> > const_parsed_terms=0x0,
> > listp=0x7fffffffa270, loc_=0x7fffffffb120) at util/parse-events.c:1592
> > #2 0x00005555558108cc in parse_events_parse
> > (_parse_state=0x7fffffffbf00, scanner=0x555556138aa0)
> > at util/parse-events.y:293
> > #3 0x00005555557abdc2 in parse_events__scanner (str=0x7fffffffc000
> > "temp_test_hwmon_event1",
> > input=0x0, parse_state=0x7fffffffbf00) at util/parse-events.c:1870
> > #4 0x00005555557ac735 in __parse_events (evlist=0x55555613ca40,
> > str=0x7fffffffc000 "temp_test_hwmon_event1", pmu_filter=0x0,
> > err=0x7fffffffbff0,
> > fake_pmu=false, warn_if_reordered=true, fake_tp=false) at
> > util/parse-events.c:2139
> > #5 0x00005555557448ca in parse_events (evlist=0x55555613ca40,
> > str=0x7fffffffc000 "temp_test_hwmon_event1", err=0x7fffffffbff0)
> > at /home/irogers/kernel.org2/tools/perf/util/parse-events.h:41
> > #6 0x0000555555744f6e in do_test (i=0, with_pmu=false,
> > with_alias=false) at tests/hwmon_pmu.c:156
> > #7 0x00005555557452dd in test__hwmon_pmu (with_pmu=false) at
> > tests/hwmon_pmu.c:212
> > #8 0x000055555574538d in test__hwmon_pmu_without_pmu
> > (test=0x5555560a3740 <suite.hwmon_pmu>,
> > subtest=1) at tests/hwmon_pmu.c:229
> > #9 0x00005555556fc935 in start_test (test=0x5555560a3740
> > <suite.hwmon_pmu>, i=10, subi=1,
> > child=0x55555613c528, width=64, pass=1) at tests/builtin-test.c:424
> > #10 0x00005555556fd014 in __cmd_test (suites=0x55555613c0f0, argc=1,
> > argv=0x7fffffffd9c0,
> > skiplist=0x0) at tests/builtin-test.c:571
> > #11 0x00005555556fdb29 in cmd_test (argc=1, argv=0x7fffffffd9c0) at
> > tests/builtin-test.c:773
> > #12 0x000055555568043a in run_builtin (p=0x55555608f950 <commands+624>, argc=4,
> > argv=0x7fffffffd9c0) at perf.c:351
> > #13 0x00005555556806e1 in handle_internal_command (argc=4,
> > argv=0x7fffffffd9c0) at perf.c:404
> > #14 0x000055555568083a in run_argv (argcp=0x7fffffffd7bc,
> > argv=0x7fffffffd7b0) at perf.c:448
> > #15 0x0000555555680b83 in main (argc=4, argv=0x7fffffffd9c0) at perf.c:560
> > (gdb) p pmu->name
> > $1 = 0x5555560ce940 "cpu"
> > ```
> > Repeating this the test hwmon_a_test_hwmon_pmu test PMU should be tested:
> > ```
> > (gdb) c
> > Continuing.
> >
> > (gdb) p pmu->name
> > $2 = 0x5555560d6b20 "breakpoint"
> > (gdb) c
> > Continuing.
> >
> > Breakpoint 1, perf_pmu__have_event (pmu=0x555556158060,
> > name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> > 1816 {
> > (gdb) p pmu->name
> > $3 = 0x5555560d7ec0 "cstate_core"
> > (gdb) c
> > Continuing.
> >
> > Breakpoint 1, perf_pmu__have_event (pmu=0x555556158610,
> > name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> > 1816 {
> > (gdb) p pmu->name
> > $4 = 0x5555560c84b0 "cstate_pkg"
> > (gdb) c
> > Continuing.
> >
> > Breakpoint 1, perf_pmu__have_event (pmu=0x5555561360b0,
> > name=0x5555560ce470 "temp_test_hwmon_event1") at util/pmu.c:1816
> > 1816 {
> > (gdb) p pmu->name
> > $5 = 0x5555560d46a0 "hwmon_a_test_hwmon_pmu"
> > ```
> > which should then go into the hwmon_pmu__have_event:
> > ```
> > (gdb) n
> > 1817 if (!name)
> > (gdb)
> > 1819 if (perf_pmu__is_tool(pmu) && tool_pmu__skip_event(name))
> > (gdb)
> > 1821 if (perf_pmu__is_hwmon(pmu))
> > (gdb) n
> > 1822 return hwmon_pmu__have_event(pmu, name);
> > (gdb) s
> > hwmon_pmu__have_event (pmu=0x5555561360b0, name=0x5555560ce470
> > "temp_test_hwmon_event1")
> > at util/hwmon_pmu.c:559
> > ```
> > hwmon_pmu__have_event should return true but it is either not getting
> > called in your case or it is returning false. Not getting called I
> > find hard to understand as your output shows the test PMU was created.
> > It seems more likely reading the "events" and then doing the hashmap
> > lookup in hwmon_pmu__have_event fails. This was failing for me with
> > undefined behavior sanitizer because of the under initialized unions.
> > But that should be fixed by: "perf hwmon_pmu: Ensure hwmon key union
> > is zeroed before use". The particular event "temp_test_hwmon_event1"
> > is going to search all events as it uses the "label" name, so that
> > makes me think the bug is here:
> > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n584
> > but I can't eye ball an issue and the test works for me even when
> > trying to be aggressive with sanitizers. If you could help me look I'd
> > appreciate it.
>
> Where is that "temp_test_hwmon_event1" added?
test_pmu_get creates the directory for the test PMU. The file
temp1_label will be created with the contents "test hwmon event1",
there is also a fake "input" file:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/tests/hwmon_pmu.c?h=perf-tools-next#n62
```
{ "temp1_label", "test hwmon event1\n", },
{ "temp1_input", "40000\n", },
```
So we will have an event called temp1 based on the type and number.
Because we have a label there will be an alias of
"temp_test_hwmon_event1" where temp is the type from the filename,
"test_hwmon_event1" is the contents of the file "fixed" by removing
escapes, spaces, etc. and making them underscores:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n234
These files are read and stored in a hashmap where the key is the
type, so temp, and the number, so 1:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n287
The value associated with the key is just a bitmap saying what kinds
of hwmon items (files) there are for this type+number as well as a
cache of reading the file event's label file and of its "fixed" name
to aid searching:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n125
The key is numeric but the failing event is a string and requires the
whole map searching to check for presence by matching what is the name
computed from the label file:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/hwmon_pmu.c?h=perf-tools-next#n579
```
Breakpoint 1, hwmon_pmu__have_event (pmu=0x555556147f40,
name=0x5555560d8470 "temp_test_hwmon_event1") at util/hwmon_pmu.c:559
559 {
(gdb) n
560 struct hwmon_pmu *hwm = container_of(pmu, struct
hwmon_pmu, pmu);
(gdb)
563 union hwmon_pmu_event_key key = {};
(gdb)
567 if (!parse_hwmon_filename(name, &type, &number,
/*item=*/NULL, /*is_alarm=*/NULL))
(gdb)
570 if (hwmon_pmu__read_events(hwm))
(gdb)
573 key.type = type;
(gdb)
574 key.num = number;
(gdb)
575 if (hashmap_find(&hwm->events, key.type_and_num,
/*value=*/NULL))
(gdb)
577 if (key.num != -1)
(gdb)
580 hashmap__for_each_entry((&hwm->events), cur, bkt) {
(gdb) n
581 struct hwmon_pmu_event_value *value = cur->pvalue;
(gdb)
583 key.type_and_num = cur->key;
(gdb)
584 if (key.type == type && value->name &&
!strcasecmp(name, value->name))
(gdb) p value->name
$1 = 0x5555560d0680 "temp_test_hwmon_event1"
(gdb) n
585 return true;
```
The if here must be failing for you, but I fail to see why. I don't
see the strcasecmp in your output and what we care about is why either
the type is wrong or value->name is wrong, if you could help to log
these it would be great.
Thanks,
Ian
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] perf tests: Fix hwmon parsing with PMU name test
2024-11-21 0:09 [PATCH v1] perf tests: Fix hwmon parsing with PMU name test Ian Rogers
2024-11-21 5:49 ` Namhyung Kim
2024-11-21 17:04 ` Arnaldo Carvalho de Melo
@ 2024-11-22 22:17 ` Namhyung Kim
2 siblings, 0 replies; 9+ messages in thread
From: Namhyung Kim @ 2024-11-22 22:17 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
Kan Liang, linux-perf-users, linux-kernel, Ian Rogers
On Wed, 20 Nov 2024 16:09:55 -0800, Ian Rogers wrote:
> Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
> address issue with hwmon_pmu__config_terms needing to load events - a
> load bearing assert fired. Also fix missing list deletion when putting
> the hwmon test PMU and lower some debug warnings to make the hwmon PMU
> less spammy in verbose mode.
>
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-22 22:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 0:09 [PATCH v1] perf tests: Fix hwmon parsing with PMU name test Ian Rogers
2024-11-21 5:49 ` Namhyung Kim
2024-11-21 17:04 ` Arnaldo Carvalho de Melo
2024-11-21 17:22 ` Arnaldo Carvalho de Melo
2024-11-21 18:55 ` Ian Rogers
2024-11-21 20:58 ` Arnaldo Carvalho de Melo
2024-11-21 21:08 ` Arnaldo Carvalho de Melo
2024-11-22 6:59 ` Ian Rogers
2024-11-22 22:17 ` Namhyung Kim
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.