perf script: Fix output type for dynamically allocated core PMU's
PATCH v2 1/1 perf script: Fix output type for dynamically allocated core PMU's
perf script output may show different fields on different core PMU's that exist on heterogeneous platforms. For example,
perf record -e "{cpu_core/mem-loads-aux/,cpu_core/event=0xcd,\
umask=0x01,ldlat=3,name=MEM_UOPS_RETIRED.LOAD_LATENCY/}:upp"\
-c10000 -W -d -a -- sleep 1
perf script:
chromium-browse 46572 [002] 544966.882384: 10000 cpu_core/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7ffdf1391b0c 10268100142 \
|OP LOAD|LVL L1 hit|SNP None|TLB L1 or L2 hit|LCK No|BLK N/A 5 7 0 7fad7c47425d [unknown] (/usr/lib64/libglib-2.0.so.0.8000.3)
perf record -e cpu_atom/event=0xd0,umask=0x05,ldlat=3,\
name=MEM_UOPS_RETIRED.LOAD_LATENCY/upp -c10000 -W -d -a -- sleep 1
perf script:
gnome-control-c 534224 [023] 544951.816227: 10000 cpu_atom/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7f0aaaa0aae0 [unknown] (/usr/lib64/libglib-2.0.so.0.8000.3)
Some fields, such as data_src, are not included by default.
The cause is that while one PMU may be assigned a type such as PERF_TYPE_RAW, other core PMU's are dynamically allocated at boot time. If this value does not match an existing PERF_TYPE_X value, output_type(perf_event_attr.type) will return OUTPUT_TYPE_OTHER.
Instead search for a core PMU with a matching perf_event_attr type and, if one is found, return PERF_TYPE_RAW to match output of other core PMU's.
---
v2: restrict pmu lookup to platforms with more than one core pmu
--- tools/perf/builtin-script.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/perf/builtin-script.c +15 -0
@@ -384,6 +384,18 @@ static int evsel_script__fprintf(struct evsel_script *es, FILE *fp) st.st_size / 1024.0 / 1024.0, es->filename, es->samples); } +static bool output_type_many_core_pmus (unsigned int type) +{ +struct perf_pmu *pmu; + +if (perf_pmus__num_core_pmus () >1 ) { + pmu =perf_pmus__find_by_type (type); +if (pmu && pmu->is_core) +return true; + } +return false; +} +static inline int output_type (unsigned int type) {switch (type) {
@@ -394,6 +406,9 @@ static inline int output_type(unsigned int type)return type; } +if (output_type_many_core_pmus (type)) +return PERF_TYPE_RAW ; +return OUTPUT_TYPE_OTHER ; }
Signature · 1 line
2.47.1
Quoted 43 lines · Thomas Falcon
perf script output may show different fields on different core PMU's that exist on heterogeneous platforms. For example,
perf record -e "{cpu_core/mem-loads-aux/,cpu_core/event=0xcd,\
umask=0x01,ldlat=3,name=MEM_UOPS_RETIRED.LOAD_LATENCY/}:upp"\
-c10000 -W -d -a -- sleep 1perf script:
chromium-browse 46572 [002] 544966.882384: 10000 cpu_core/MEM_UOPS_RETIRED.LOAD_LATENCY/:
7ffdf1391b0c10268100142 \
|OP LOAD|LVL L1 hit|SNP None|TLB L1 or L2 hit|LCK No|BLK N/A 5 7 07fad7c47425d[unknown] (/usr/lib64/libglib-2.0.so.0.8000.3)perf record -e cpu_atom/event=0xd0,umask=0x05,ldlat=3,\
name=MEM_UOPS_RETIRED.LOAD_LATENCY/upp -c10000 -W -d -a -- sleep 1perf script:
gnome-control-c 534224 [023] 544951.816227: 10000 cpu_atom/MEM_UOPS_RETIRED.LOAD_LATENCY/:
7f0aaaa0aae0[unknown] (/usr/lib64/libglib-2.0.so.0.8000.3)Some fields, such as
data_src, are not included by default.The cause is that while one PMU may be assigned a type such as
PERF_TYPE_RAW, other core PMU's are dynamically allocated at boot time. If this value does not match an existingPERF_TYPE_Xvalue,output_type(perf_event_attr.type)will returnOUTPUT_TYPE_OTHER.Instead search for a core PMU with a matching
perf_event_attrtype and, if one is found, returnPERF_TYPE_RAWto match output of other core PMU's.Suggested-by Kan Liang <[email protected]>Signed-off-by Thomas Falcon <[email protected]>---
v2: restrict pmu lookup to platforms with more than one core pmu--- tools/perf/builtin-script.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)tools/perf/builtin-script.c +0
-0
tools/perf/builtin-script.c static int evsel_script__fprintf(struct evsel_script *es, FILE *fp) · line 393
Quoted 10 lines
tools/perf/builtin-script.c +7
-0@@ -384,6 +384,18 @@ static int evsel_script__fprintf(struct evsel_script *es, FILE *fp) st.st_size / 1024.0 / 1024.0, es->filename, es->samples); } +static bool output_type_many_core_pmus (unsigned int type) +{ +struct perf_pmu *pmu; + +if (perf_pmus__num_core_pmus () >1 ) { + pmu =perf_pmus__find_by_type (type); + if (pmu && pmu->is_core)> + return true;
I think it should be good enough to search the core_pmus.
list_for_each_entry(pmu, &core_pmus, list) {
if (pmu->type == type)
return true;
}Thanks,
Kan
Quoted 17 lines
tools/perf/builtin-script.c +7
-0+ } +return false; +} +static inline int output_type (unsigned int type) {switch (type) {@@ -394,6 +406,9 @@ static inline int output_type(unsigned int type)return type; } +if (output_type_many_core_pmus (type)) +return PERF_TYPE_RAW ; +return OUTPUT_TYPE_OTHER ; }
Quoted 69 lines · Kan
Quoted 56 lines · Thomas Falcon
perf script output may show different fields on different core PMU's
that exist on heterogeneous platforms. For example,perf record -e "{cpu_core/mem-loads-aux/,cpu_core/event=0xcd,\
umask=0x01,ldlat=3,name=MEM_UOPS_RETIRED.LOAD_LATENCY/}:upp"\
-c10000 -W -d -a -- sleep 1perf script:
chromium-browse 46572 [002] 544966.882384:
10000 cpu_core/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7ffdf1391b0c 10268100142\
|OP LOAD|LVL L1 hit|SNP None|TLB L1 or L2 hit|LCK No|BLK N/A 5 7 07fad7c47425d[unknown] (/usr/lib64/libglib-2.0.so.0.8000.3)perf record -e cpu_atom/event=0xd0,umask=0x05,ldlat=3,\
name=MEM_UOPS_RETIRED.LOAD_LATENCY/upp -c10000 -W -d -a -- sleep 1perf script:
gnome-control-c 534224 [023] 544951.816227: 10000 cpu_atom/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7f0aaaa0aae0 [unknown] (
/usr/lib64/libglib-2.0.so.0.8000.3)Some fields, such as
data_src, are not included by default.The cause is that while one PMU may be assigned a type such as
PERF_TYPE_RAW, other core PMU's are dynamically allocated at boot time.
If this value does not match an existingPERF_TYPE_Xvalue,output_type(perf_event_attr.type)will returnOUTPUT_TYPE_OTHER.Instead search for a core PMU with a matching
perf_event_attrtype and, if one is found, returnPERF_TYPE_RAWto match output of other core PMU's.Suggested-by Kan Liang <[email protected]>Signed-off-by Thomas Falcon <[email protected]>---
v2: restrict pmu lookup to platforms with more than one core pmu
---
tools/perf/builtin-script.c | 15 +++++++++++++++1 file changed, 15 insertions(+)tools/perf/builtin- renamed from tools/perf/builtin-script.c +0
-0
script.c
index9e47905f75a6..459794c737ce100644tools/perf/builtin-script.c +0
-0@@ -384,6 +384,18 @@ static int evsel_script__fprintf(struct evsel_script *es, FILE *fp) st.st_size / 1024.0 / 1024.0, es->filename, es->samples); }tools/perf/builtin-script.c static int evsel_script__fprintf(struct evsel_script *es, FILE *fp) · line 394
Quoted 8 lines
tools/perf/builtin-script.c +8
-0+static bool output_type_many_core_pmus (unsigned int type) +{ +struct perf_pmu *pmu; + +if (perf_pmus__num_core_pmus () >1 ) { + pmu =perf_pmus__find_by_type (type); + if (pmu && pmu->is_core)> +return true;I think it should be good enough to search the
core_pmus.
Quoted 7 lines
list_for_each_entry(pmu, &core_pmus, list) { if (pmu->type == type) return true; }Thanks,
Kan
Thanks, will resend with your changes.
Tom
Quoted 19 lines
Quoted 18 lines
tools/perf/builtin-script.c +4
-0+ } +return false; +} +static inline int
output_type(unsigned int type)
{
switch (type) {tools/perf/builtin-script.c +0
-0@@ -394,6 +406,9 @@ static inline int output_type(unsigned int type) return type; }tools/perf/builtin-script.c +3
-0+if (output_type_many_core_pmus (type)) +return PERF_TYPE_RAW ; +return
OUTPUT_TYPE_OTHER;
}