Skip to contentSkip to conversation

perf jevents: Fix event syntax error caused by ExtSel

PATCH Applied [email protected] 3 participants 3 messages May 25, 2022 – May 26, 2022 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf jevents: Fix event syntax error caused by ExtSel

From: Zhengjun Xing <[email protected]>

In the origin code, when "ExtSel" is 1, the eventcode will change to "eventcode |= 1 << 21”. For event “UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS", its "ExtSel" is "1", its eventcode will change from 0x1E to 0x20001E, but in fact the eventcode should <=0x1FF, so this will cause the parse fail:

  # perf stat -e "UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS" -a sleep 0.1
event syntax error: '.._RxL_CREDITS_CONSUMED_VN0.DRS'
                                  \___ value too big for format, maximum is 511

On the perf kernel side, the kernel assumes the valid bits are continuous. It will adjust the 0x100 (bit 8 for perf tool) to bit 21 in HW.

DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");

So the perf tool follows the kernel side and just set bit8 other than bit21.

Fixes fedb2b518239 ("perf jevents: Add support for parsing uncore json files")
---
 tools/perf/pmu-events/jevents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/pmu-events/jevents.c +1 -1
index cee61c4ed59e..e597e4bac90f 100644
@@ -605,7 +605,7 @@ static int json_events(const char *fn,
 			} else if (json_streq(map, field, "ExtSel")) {
 				char *code = NULL;
 				addfield(map, &code, "", "", val);
-				eventcode |= strtoul(code, NULL, 0) << 21;
+				eventcode |= strtoul(code, NULL, 0) << 8;
 				free(code);
 			} else if (json_streq(map, field, "EventName")) {
 				addfield(map, &je.name, "", "", val);
Signature · 1 line
2.25.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · On Wed, May 25, 2022 at 7:04 AM <[email protected]> wrote:

From: Zhengjun Xing <[email protected]>

In the origin code, when "ExtSel" is 1, the eventcode will change to "eventcode |= 1 << 21”. For event “UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS", its "ExtSel" is "1", its eventcode will change from 0x1E to 0x20001E, but in fact the eventcode should <=0x1FF, so this will cause the parse fail:

  # perf stat -e "UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS" -a sleep 0.1
event syntax error: '.._RxL_CREDITS_CONSUMED_VN0.DRS'
                                  \___ value too big for format, maximum is 511

On the perf kernel side, the kernel assumes the valid bits are continuous. It will adjust the 0x100 (bit 8 for perf tool) to bit 21 in HW.

Quoted 7 lines

DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");

So the perf tool follows the kernel side and just set bit8 other than bit21.

Fixes fedb2b518239 ("perf jevents: Add support for parsing uncore json files")

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/pmu-events/jevents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/pmu-events/jevents.c +1 -2
index cee61c4ed59e..e597e4bac90f 100644
@@ -605,7 +605,7 @@ static int json_events(const char *fn,
                        } else if (json_streq(map, field, "ExtSel")) {
                                char *code = NULL;
                                addfield(map, &code, "", "", val);
-                               eventcode |= strtoul(code, NULL, 0) << 21;
+                               eventcode |= strtoul(code, NULL, 0) << 8;
                                free(code);
                        } else if (json_streq(map, field, "EventName")) {
                                addfield(map, &je.name, "", "", val);
--

2.25.1

maintainer Applied
#2 lore raw

Em Wed, May 25, 2022 at 07:27:08AM -0700, Ian Rogers escreveu:

Quoted 19 lines · On Wed, May 25, 2022 at 7:04 AM <[email protected]> wrote:
Quoted 18 lines

From: Zhengjun Xing <[email protected]>

In the origin code, when "ExtSel" is 1, the eventcode will change to "eventcode |= 1 << 21”. For event “UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS", its "ExtSel" is "1", its eventcode will change from 0x1E to 0x20001E, but in fact the eventcode should <=0x1FF, so this will cause the parse fail:

  # perf stat -e "UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS" -a sleep 0.1
event syntax error: '.._RxL_CREDITS_CONSUMED_VN0.DRS'
                                  \___ value too big for format, maximum is 511

On the perf kernel side, the kernel assumes the valid bits are continuous. It will adjust the 0x100 (bit 8 for perf tool) to bit 21 in HW.

DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");

Quoted 7 lines
Quoted 5 lines

So the perf tool follows the kernel side and just set bit8 other than bit21.

Fixes fedb2b518239 ("perf jevents: Add support for parsing uncore json files")

Thanks, applied.

- Arnaldo