提交 8576c9d2 编写于 作者: Z Zhengjun Xing 提交者: Zheng Zengkai

perf jevents: Fix event syntax error caused by ExtSel

stable inclusion
from stable-v5.10.121
commit d8b6aaeb9a91ae5e4d01ffa3cac5f7f52b9451f0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d8b6aaeb9a91ae5e4d01ffa3cac5f7f52b9451f0

--------------------------------

[ Upstream commit f4df0dbb ]

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: fedb2b51 ("perf jevents: Add support for parsing uncore json files")
Reviewed-by: NKan Liang <kan.liang@linux.intel.com>
Signed-off-by: NXing Zhengjun <zhengjun.xing@linux.intel.com>
Acked-by: NIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220525140410.1706851-1-zhengjun.xing@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 732db167
...@@ -579,7 +579,7 @@ static int json_events(const char *fn, ...@@ -579,7 +579,7 @@ static int json_events(const char *fn,
} else if (json_streq(map, field, "ExtSel")) { } else if (json_streq(map, field, "ExtSel")) {
char *code = NULL; char *code = NULL;
addfield(map, &code, "", "", val); addfield(map, &code, "", "", val);
eventcode |= strtoul(code, NULL, 0) << 21; eventcode |= strtoul(code, NULL, 0) << 8;
free(code); free(code);
} else if (json_streq(map, field, "EventName")) { } else if (json_streq(map, field, "EventName")) {
addfield(map, &je.name, "", "", val); addfield(map, &je.name, "", "", val);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册