* [PATCH] perf, tools, pmu-events: Fix fixed counters on Intel
@ 2015-09-04 18:33 Andi Kleen
2015-09-09 20:58 ` Sukadev Bhattiprolu
0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2015-09-04 18:33 UTC (permalink / raw)
To: sukadev; +Cc: acme, linux-kernel, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
[This patch is on top of Sukadev's json patchkit]
The JSON event lists use a different encoding for fixed counters
than perf for instructions and cycles (ref-cycles is ok)
This lead to some common events like inst_retired.any
or cpu_clk_unhalted.thread not counting, when specified with their
JSON name.
Special case these events in the jevents conversion process.
I prefer to not touch the JSON files for this, as it's intended
that standard JSON files can be just dropped into the perf
build without changes.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/pmu-events/jevents.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 7347cca..f4e5903 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -237,6 +237,28 @@ static void print_events_table_suffix(FILE *outfp)
fprintf(outfp, "};\n");
}
+static struct fixed {
+ const char *name;
+ const char *event;
+} fixed[] = {
+ { "inst_retired.any", "event=0xc0" },
+ { "cpu_clk_unhalted.thread", "event=0x3c" },
+ { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
+ {},
+};
+
+/*
+ * Handle different fixed counter encodings between JSON and perf.
+ */
+static char *real_event(const char *name, char *event)
+{
+ int i;
+ for (i = 0; fixed[i].name; i++)
+ if (!strcasecmp(name, fixed[i].name))
+ return (char *)fixed[i].event;
+ return event;
+}
+
/* Call func with each event in the json file */
int json_events(const char *fn,
int (*func)(void *data, char *name, char *event, char *desc,
@@ -324,8 +346,7 @@ int json_events(const char *fn,
if (msr != NULL)
addfield(map, &event, ",", msr->pname, msrval);
fixname(name);
-
- err = func(data, name, event, desc, long_desc, topic);
+ err = func(data, name, real_event(name, event), desc, long_desc, topic);
free(event);
free(desc);
free(name);
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf, tools, pmu-events: Fix fixed counters on Intel
2015-09-04 18:33 [PATCH] perf, tools, pmu-events: Fix fixed counters on Intel Andi Kleen
@ 2015-09-09 20:58 ` Sukadev Bhattiprolu
2015-09-09 21:24 ` Andi Kleen
0 siblings, 1 reply; 3+ messages in thread
From: Sukadev Bhattiprolu @ 2015-09-09 20:58 UTC (permalink / raw)
To: Andi Kleen; +Cc: acme, linux-kernel, Andi Kleen
Andi,
Andi Kleen [andi@firstfloor.org] wrote:
| From: Andi Kleen <ak@linux.intel.com>
|
| [This patch is on top of Sukadev's json patchkit]
I removed this line from the commit log...
|
| The JSON event lists use a different encoding for fixed counters
| than perf for instructions and cycles (ref-cycles is ok)
|
| This lead to some common events like inst_retired.any
| or cpu_clk_unhalted.thread not counting, when specified with their
| JSON name.
|
| Special case these events in the jevents conversion process.
| I prefer to not touch the JSON files for this, as it's intended
| that standard JSON files can be just dropped into the perf
| build without changes.
|
| Signed-off-by: Andi Kleen <ak@linux.intel.com>
| ---
| tools/perf/pmu-events/jevents.c | 25 +++++++++++++++++++++++--
| 1 file changed, 23 insertions(+), 2 deletions(-)
|
| diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
| index 7347cca..f4e5903 100644
| --- a/tools/perf/pmu-events/jevents.c
| +++ b/tools/perf/pmu-events/jevents.c
| @@ -237,6 +237,28 @@ static void print_events_table_suffix(FILE *outfp)
| fprintf(outfp, "};\n");
| }
|
| +static struct fixed {
| + const char *name;
| + const char *event;
| +} fixed[] = {
| + { "inst_retired.any", "event=0xc0" },
| + { "cpu_clk_unhalted.thread", "event=0x3c" },
| + { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
| + {},
...and replaced this line with:
{NULL, NULL},
to fix the compile error:
pmu-events/jevents.c:247:2: error: missing initializer for field ‘name’ of ‘struct fixed’ [-Werror=missing-field-initializers]
{},
After this I was able to get non-zero counts for the 'inst_retired.any'
event on my system. Without the patch, I get 0 count for the event.
I pushed this commit to the 'json-v16' branch.
I also noticed an "Unknown MSR" message when building 'jevents':
CC /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/jevents.o
LD /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/jevents-in.o
LINK /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/jevents
GEN /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/pmu-events.c
jevents: Unknown MSR in event file 0x3F7
The message is unrelated to the current patch and seems to show up when
processing:
tools/perf/pmu-events/arch/x86/Skylake_core.json
(Note that you have to merge the 'json-files-7' branch with 'json-v16' to get
the JSON files and hence the error).
Thanks,
Sukadev
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf, tools, pmu-events: Fix fixed counters on Intel
2015-09-09 20:58 ` Sukadev Bhattiprolu
@ 2015-09-09 21:24 ` Andi Kleen
0 siblings, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2015-09-09 21:24 UTC (permalink / raw)
To: Sukadev Bhattiprolu; +Cc: Andi Kleen, acme, linux-kernel
>
> pmu-events/jevents.c:247:2: error: missing initializer for field ‘name’ of ‘struct fixed’ [-Werror=missing-field-initializers]
Thanks.
Somehow a WERROR=0 must have slipped into the build script again.
> After this I was able to get non-zero counts for the 'inst_retired.any'
> event on my system. Without the patch, I get 0 count for the event.
>
> I pushed this commit to the 'json-v16' branch.
>
> I also noticed an "Unknown MSR" message when building 'jevents':
>
> CC /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/jevents.o
> LD /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/jevents-in.o
> LINK /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/jevents
> GEN /root/suka/linux-acme.git/tools/perf/perf-obj/pmu-events/pmu-events.c
> jevents: Unknown MSR in event file 0x3F7
I'll take a look and send a patch for that.
-Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-09 21:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04 18:33 [PATCH] perf, tools, pmu-events: Fix fixed counters on Intel Andi Kleen
2015-09-09 20:58 ` Sukadev Bhattiprolu
2015-09-09 21:24 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).