From: John Garry <john.garry@huawei.com> To: <will@kernel.org>, <mathieu.poirier@linaro.org>, <leo.yan@linaro.org>, <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>, <mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>, <jolsa@redhat.com>, <namhyung@kernel.org> Cc: <irogers@google.com>, <linux-arm-kernel@lists.infradead.org>, <linux-perf-users@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>, <zhangshaokun@hisilicon.com>, <liuqi115@huawei.com>, John Garry <john.garry@huawei.com> Subject: [PATCH 2/5] perf jevents: Support ConfigCode Date: Thu, 16 Sep 2021 20:34:22 +0800 [thread overview] Message-ID: <1631795665-240946-3-git-send-email-john.garry@huawei.com> (raw) In-Reply-To: <1631795665-240946-1-git-send-email-john.garry@huawei.com> Some PMUs use "config=XXX" for eventcodes, like: more /sys/bus/event_source/devices/hisi_sccl1_ddrc3/events/act_cmd config=0x5 However jevents would give an alias with .event field "event=0x5" for this event. This is handled without issue by the parse events code, but the pmu alias code gets a bit confused, as it warns about assigning "event=0x5" over "config=0x5" in perf_pmu_assign_str() when merging aliases: ./perf stat -v -e act_cmd ... alias act_cmd differs in field 'value' ... To make things a bit more straightforward, allow jevents to support "config=XXX" as well, by supporting a "ConfigCode" field. Signed-off-by: John Garry <john.garry@huawei.com> --- tools/perf/pmu-events/jevents.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 6731b3cf0c2f..ef92c2fdd45d 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -575,10 +575,12 @@ static int json_events(const char *fn, struct json_event je = {}; char *arch_std = NULL; unsigned long long eventcode = 0; + unsigned long long configcode = 0; struct msrmap *msr = NULL; jsmntok_t *msrval = NULL; jsmntok_t *precise = NULL; jsmntok_t *obj = tok++; + bool configcode_present = false; EXPECT(obj->type == JSMN_OBJECT, obj, "expected object"); for (j = 0; j < obj->size; j += 2) { @@ -601,6 +603,12 @@ static int json_events(const char *fn, addfield(map, &code, "", "", val); eventcode |= strtoul(code, NULL, 0); free(code); + } else if (json_streq(map, field, "ConfigCode")) { + char *code = NULL; + addfield(map, &code, "", "", val); + configcode |= strtoul(code, NULL, 0); + free(code); + configcode_present = true; } else if (json_streq(map, field, "ExtSel")) { char *code = NULL; addfield(map, &code, "", "", val); @@ -682,7 +690,10 @@ static int json_events(const char *fn, addfield(map, &extra_desc, " ", "(Precise event)", NULL); } - snprintf(buf, sizeof buf, "event=%#llx", eventcode); + if (configcode_present) + snprintf(buf, sizeof buf, "config=%#llx", configcode); + else + snprintf(buf, sizeof buf, "event=%#llx", eventcode); addfield(map, &event, ",", buf, NULL); if (je.desc && extra_desc) addfield(map, &je.desc, " ", extra_desc, NULL); -- 2.26.2
WARNING: multiple messages have this Message-ID (diff)
From: John Garry <john.garry@huawei.com> To: <will@kernel.org>, <mathieu.poirier@linaro.org>, <leo.yan@linaro.org>, <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>, <mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>, <jolsa@redhat.com>, <namhyung@kernel.org> Cc: <irogers@google.com>, <linux-arm-kernel@lists.infradead.org>, <linux-perf-users@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>, <zhangshaokun@hisilicon.com>, <liuqi115@huawei.com>, John Garry <john.garry@huawei.com> Subject: [PATCH 2/5] perf jevents: Support ConfigCode Date: Thu, 16 Sep 2021 20:34:22 +0800 [thread overview] Message-ID: <1631795665-240946-3-git-send-email-john.garry@huawei.com> (raw) In-Reply-To: <1631795665-240946-1-git-send-email-john.garry@huawei.com> Some PMUs use "config=XXX" for eventcodes, like: more /sys/bus/event_source/devices/hisi_sccl1_ddrc3/events/act_cmd config=0x5 However jevents would give an alias with .event field "event=0x5" for this event. This is handled without issue by the parse events code, but the pmu alias code gets a bit confused, as it warns about assigning "event=0x5" over "config=0x5" in perf_pmu_assign_str() when merging aliases: ./perf stat -v -e act_cmd ... alias act_cmd differs in field 'value' ... To make things a bit more straightforward, allow jevents to support "config=XXX" as well, by supporting a "ConfigCode" field. Signed-off-by: John Garry <john.garry@huawei.com> --- tools/perf/pmu-events/jevents.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 6731b3cf0c2f..ef92c2fdd45d 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -575,10 +575,12 @@ static int json_events(const char *fn, struct json_event je = {}; char *arch_std = NULL; unsigned long long eventcode = 0; + unsigned long long configcode = 0; struct msrmap *msr = NULL; jsmntok_t *msrval = NULL; jsmntok_t *precise = NULL; jsmntok_t *obj = tok++; + bool configcode_present = false; EXPECT(obj->type == JSMN_OBJECT, obj, "expected object"); for (j = 0; j < obj->size; j += 2) { @@ -601,6 +603,12 @@ static int json_events(const char *fn, addfield(map, &code, "", "", val); eventcode |= strtoul(code, NULL, 0); free(code); + } else if (json_streq(map, field, "ConfigCode")) { + char *code = NULL; + addfield(map, &code, "", "", val); + configcode |= strtoul(code, NULL, 0); + free(code); + configcode_present = true; } else if (json_streq(map, field, "ExtSel")) { char *code = NULL; addfield(map, &code, "", "", val); @@ -682,7 +690,10 @@ static int json_events(const char *fn, addfield(map, &extra_desc, " ", "(Precise event)", NULL); } - snprintf(buf, sizeof buf, "event=%#llx", eventcode); + if (configcode_present) + snprintf(buf, sizeof buf, "config=%#llx", configcode); + else + snprintf(buf, sizeof buf, "event=%#llx", eventcode); addfield(map, &event, ",", buf, NULL); if (je.desc && extra_desc) addfield(map, &je.desc, " ", extra_desc, NULL); -- 2.26.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-09-16 12:39 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-16 12:34 [PATCH 0/5] Improve perf list support for hisi uncore PMUs John Garry 2021-09-16 12:34 ` John Garry 2021-09-16 12:34 ` [PATCH 1/5] perf parse-events: Set numeric term config John Garry 2021-09-16 12:34 ` John Garry 2021-09-28 17:59 ` Ian Rogers 2021-09-28 17:59 ` Ian Rogers 2021-09-28 19:16 ` Arnaldo Carvalho de Melo 2021-09-28 19:16 ` Arnaldo Carvalho de Melo 2021-09-16 12:34 ` John Garry [this message] 2021-09-16 12:34 ` [PATCH 2/5] perf jevents: Support ConfigCode John Garry 2021-09-28 18:00 ` Ian Rogers 2021-09-28 18:00 ` Ian Rogers 2021-09-16 12:34 ` [PATCH 3/5] perf test: Verify more event members in pmu-events test John Garry 2021-09-16 12:34 ` John Garry 2021-09-28 18:02 ` Ian Rogers 2021-09-28 18:02 ` Ian Rogers 2021-09-16 12:34 ` [PATCH 4/5] perf test: Add pmu-event test for event described as "config=" John Garry 2021-09-16 12:34 ` John Garry 2021-09-28 18:03 ` Ian Rogers 2021-09-28 18:03 ` Ian Rogers 2021-09-16 12:34 ` [PATCH 5/5] perf vendor events arm64: Revise hip08 uncore events John Garry 2021-09-16 12:34 ` John Garry 2021-09-28 18:04 ` Ian Rogers 2021-09-28 18:04 ` Ian Rogers
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1631795665-240946-3-git-send-email-john.garry@huawei.com \ --to=john.garry@huawei.com \ --cc=acme@kernel.org \ --cc=alexander.shishkin@linux.intel.com \ --cc=irogers@google.com \ --cc=jolsa@redhat.com \ --cc=leo.yan@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-perf-users@vger.kernel.org \ --cc=linuxarm@huawei.com \ --cc=liuqi115@huawei.com \ --cc=mark.rutland@arm.com \ --cc=mathieu.poirier@linaro.org \ --cc=mingo@redhat.com \ --cc=namhyung@kernel.org \ --cc=peterz@infradead.org \ --cc=will@kernel.org \ --cc=zhangshaokun@hisilicon.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.