All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf jevents: Fix event syntax error caused by ExtSel
@ 2022-05-25 14:04 zhengjun.xing
  2022-05-25 14:27 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: zhengjun.xing @ 2022-05-25 14:04 UTC (permalink / raw)
  To: acme, peterz, mingo, alexander.shishkin, jolsa
  Cc: linux-kernel, linux-perf-users, irogers, adrian.hunter, ak,
	kan.liang, zhengjun.xing

From: Zhengjun Xing <zhengjun.xing@linux.intel.com>

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")
Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/pmu-events/jevents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index cee61c4ed59e..e597e4bac90f 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -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


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

* Re: [PATCH] perf jevents: Fix event syntax error caused by ExtSel
  2022-05-25 14:04 [PATCH] perf jevents: Fix event syntax error caused by ExtSel zhengjun.xing
@ 2022-05-25 14:27 ` Ian Rogers
  2022-05-26 15:25   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2022-05-25 14:27 UTC (permalink / raw)
  To: zhengjun.xing
  Cc: acme, peterz, mingo, alexander.shishkin, jolsa, linux-kernel,
	linux-perf-users, adrian.hunter, ak, kan.liang

On Wed, May 25, 2022 at 7:04 AM <zhengjun.xing@linux.intel.com> wrote:
>
> From: Zhengjun Xing <zhengjun.xing@linux.intel.com>
>
> 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")
> Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> Reviewed-by: Kan Liang <kan.liang@linux.intel.com>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/pmu-events/jevents.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index cee61c4ed59e..e597e4bac90f 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -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
>

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

* Re: [PATCH] perf jevents: Fix event syntax error caused by ExtSel
  2022-05-25 14:27 ` Ian Rogers
@ 2022-05-26 15:25   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-05-26 15:25 UTC (permalink / raw)
  To: Ian Rogers
  Cc: zhengjun.xing, peterz, mingo, alexander.shishkin, jolsa,
	linux-kernel, linux-perf-users, adrian.hunter, ak, kan.liang

Em Wed, May 25, 2022 at 07:27:08AM -0700, Ian Rogers escreveu:
> On Wed, May 25, 2022 at 7:04 AM <zhengjun.xing@linux.intel.com> wrote:
> >
> > From: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> >
> > 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")
> > Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
> > Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
> 
> Acked-by: Ian Rogers <irogers@google.com>

Thanks, applied.

- Arnaldo


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

end of thread, other threads:[~2022-05-26 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 14:04 [PATCH] perf jevents: Fix event syntax error caused by ExtSel zhengjun.xing
2022-05-25 14:27 ` Ian Rogers
2022-05-26 15:25   ` Arnaldo Carvalho de Melo

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