perf/amd: Zen4 IBS extensions support
Subsystems (2)
cover perf/amd: Zen4 IBS extensions support
IBS support has been enhanced with two new features in upcoming uarch:
1. DataSrc extension and 2. L3 Miss Filtering capability. Both are indicated by CPUID_Fn8000001B_EAX bit 11.
DataSrc extension provides additional data source details for tagged load/store operations. Add support for these new bits in perf report/ script raw-dump.
IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems.
Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage:
# perf record -a -e ibs_op/l3missonly=1/ --raw-samples sleep 5 # perf report -D
Some important points to keep in mind while using L3 miss filtering:
1. Hw internally reset sampling period when tagged instruction does not cause L3 miss. But there is no way to reconstruct aggregated sampling period when this happens.
2. L3 miss is not the actual event being counted. Rather, IBS will count fetch, cycles or uOps depending on the configuration. Thus sampling period have no direct connection to L3 misses.
1st causes sampling period skew. Thus, I've added warning message at perf record:
# perf record -c 10000 -C 0 -e ibs_op/l3missonly=1/ WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled and tagged operation does not cause L3 Miss. This causes sampling period skew.
User can configure smaller sampling period to get more samples while using l3missonly.
Ravi Bangoria (6):
perf/amd/ibs: Add support for L3 miss filtering perf/amd/ibs: Advertise zen4_ibs_extensions as pmu capability
attribute
perf/tool/amd/ibs: Warn about sampling period skew perf/tool: Parse non-cpu pmu capabilities perf/tool/amd/ibs: Support new IBS bits in raw trace dump perf/tool/amd/ibs: Fix comment
arch/x86/events/amd/ibs.c | 76 +++++-- arch/x86/include/asm/amd-ibs.h | 18 +- arch/x86/include/asm/perf_event.h | 3 + tools/arch/x86/include/asm/amd-ibs.h | 18 +- .../Documentation/perf.data-file-format.txt | 18 ++ tools/perf/arch/x86/util/evsel.c | 31 +++ tools/perf/util/amd-sample-raw.c | 68 +++++- tools/perf/util/env.c | 48 +++- tools/perf/util/env.h | 11 + tools/perf/util/evsel.c | 7 + tools/perf/util/evsel.h | 1 + tools/perf/util/header.c | 211 ++++++++++++++++++ tools/perf/util/header.h | 1 + tools/perf/util/pmu.c | 15 +- tools/perf/util/pmu.h | 2 + 15 files changed, 483 insertions(+), 45 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/6 perf/amd/ibs: Add support for L3 miss filtering
IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems.
Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage:
# perf record -a -e ibs_op/l3missonly=1/ --raw-samples sleep 5
--- arch/x86/events/amd/ibs.c | 42 ++++++++++++++++++++++--------- arch/x86/include/asm/perf_event.h | 3 +++ 2 files changed, 33 insertions(+), 12 deletions(-)
arch/x86/events/amd/ibs.c +30 -12
@@ -520,16 +520,12 @@ static void perf_ibs_read(struct perf_event *event) { }PMU_FORMAT_ATTR (rand_en,"config:57" );PMU_FORMAT_ATTR (cnt_ctl,"config:19" ); +PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" ); +PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); -static struct attribute *ibs_fetch_format_attrs[] = { - &format_attr_rand_en.attr, -NULL , -}; - -static struct attribute *ibs_op_format_attrs[] = { -NULL ,/* &format_attr_cnt_ctl.attr if IBS_CAPS_OPCNT */ -NULL , -}; +/* size = nr attrs plus NULL at the end */ +static struct attribute *ibs_fetch_format_attrs[3 ]; +static struct attribute *ibs_op_format_attrs[3 ];static struct perf_ibs perf_ibs_fetch = { .pmu = {
@@ -759,9 +755,9 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)return ret; } -static __init void perf_event_ibs_init (void ) +static __init void perf_ibs_fetch_prepare (void ) { -struct attribute **attr = ibs_op_format_attrs; +struct attribute **format_attrs = perf_ibs_fetch.format_attrs;/* * Some chips fail to reset the fetch count when it is written; instead
@@ -773,11 +769,22 @@ static __init void perf_event_ibs_init(void)if (boot_cpu_data.x86 ==0x19 && boot_cpu_data.x86_model <0x10 ) perf_ibs_fetch.fetch_ignore_if_zero_rip =1 ; + *format_attrs++ = &format_attr_rand_en.attr; +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; + *format_attrs++ = &fetch_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" ); +} + +static __init void perf_ibs_op_prepare (void ) +{ +struct attribute **format_attrs = perf_ibs_op.format_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ; - *attr++ = &format_attr_cnt_ctl.attr; + *format_attrs++ = &format_attr_cnt_ctl.attr; }if (ibs_caps &IBS_CAPS_OPCNTEXT ) {
@@ -786,7 +793,18 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=IBS_OP_MAX_CNT_EXT_MASK ; } +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; + *format_attrs++ = &op_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" ); +} + +static __init void perf_event_ibs_init (void ) +{ +perf_ibs_fetch_prepare (); +perf_ibs_op_prepare ();register_nmi_handler (NMI_LOCAL , perf_ibs_nmi_handler,0 ,"perf_ibs" );pr_info ("perf: AMD IBS detected (0x%08x)\n" , ibs_caps);
arch/x86/include/asm/perf_event.h +3 -0
@@ -391,6 +391,7 @@ struct pebs_xmm {#define IBS_CAPS_OPBRNFUSE (1U<<8)#define IBS_CAPS_FETCHCTLEXTD (1U<<9)#define IBS_CAPS_OPDATA4 (1U<<10) +#define IBS_CAPS_ZEN4IBSEXTENSIONS (1U<<11)#define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \ | IBS_CAPS_FETCHSAM \
@@ -404,6 +405,7 @@ struct pebs_xmm {#define IBSCTL_LVT_OFFSET_MASK 0x0F/* IBS fetch bits/masks */ +#define IBS_FETCH_L3MISSONLY (1ULL<<59)#define IBS_FETCH_RAND_EN (1ULL<<57)#define IBS_FETCH_VAL (1ULL<<49)#define IBS_FETCH_ENABLE (1ULL<<48)
@@ -420,6 +422,7 @@ struct pebs_xmm {#define IBS_OP_CNT_CTL (1ULL<<19)#define IBS_OP_VAL (1ULL<<18)#define IBS_OP_ENABLE (1ULL<<17) +#define IBS_OP_L3MISSONLY (1ULL<<16)#define IBS_OP_MAX_CNT 0x0000FFFFULL#define IBS_OP_MAX_CNT_EXT 0x007FFFFFULL/* not a register bit mask */ #define IBS_OP_MAX_CNT_EXT_MASK (0x7FULL<<20)/* separate upper 7 bits */
Signature · 1 line
2.27.0
Re: [PATCH 1/6] perf/amd/ibs: Add support for L3 miss filtering
Quoted 32 lines · Ravi Bangoria
IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems.
Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage:
# perf record -a -e ibs_op/l3missonly=1/ --raw-samples sleep 5Signed-off-by Ravi Bangoria <[email protected]>--- arch/x86/events/amd/ibs.c | 42 ++++++++++++++++++++++--------- arch/x86/include/asm/perf_event.h | 3 +++ 2 files changed, 33 insertions(+), 12 deletions(-)arch/x86/events/amd/ibs.c +2
-2@@ -520,16 +520,12 @@ static void perf_ibs_read(struct perf_event *event) { }PMU_FORMAT_ATTR (rand_en,"config:57" );PMU_FORMAT_ATTR (cnt_ctl,"config:19" ); +PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" ); +PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); -static struct attribute *ibs_fetch_format_attrs[] = { - &format_attr_rand_en.attr,
arch/x86/events/amd/ibs.c static void perf_ibs_read(struct perf_event *event) { } · line 528
Quoted 10 lines
arch/x86/events/amd/ibs.c +3
-7- NULL, -}; - -static struct attribute *ibs_op_format_attrs[] = { -NULL ,/* &format_attr_cnt_ctl.attr if IBS_CAPS_OPCNT */ -NULL , -}; +/* size = nr attrs plus NULL at the end */ +static struct attribute *ibs_fetch_format_attrs[3 ]; +static struct attribute *ibs_op_format_attrs[3 ];
Define a macro for the array size.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 758
Quoted 9 lines
arch/x86/events/amd/ibs.c +1
-1static struct perf_ibs perf_ibs_fetch = { .pmu = {@@ -759,9 +755,9 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)return ret; } -static __init void perf_event_ibs_init (void ) +static __init void perf_ibs_fetch_prepare (void )
Since this actually initializes the pmu, let's call that perf_ibs_fetch_init().
For low level init functions it would be good to keep track of the return code even if it is later not evaluated. So these kind of function should return an error code.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 760
Quoted 3 lines
arch/x86/events/amd/ibs.c +1
-1{ -struct attribute **attr = ibs_op_format_attrs; +struct attribute **format_attrs = perf_ibs_fetch.format_attrs;
I think we could keep this short here with 'attr'.
arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 776
Quoted 12 lines
arch/x86/events/amd/ibs.c +5
-0/* * Some chips fail to reset the fetch count when it is written; instead @@ -773,11 +769,22 @@ static __init void perf_event_ibs_init(void)if (boot_cpu_data.x86 ==0x19 && boot_cpu_data.x86_model <0x10 ) perf_ibs_fetch.fetch_ignore_if_zero_rip =1 ; + *format_attrs++ = &format_attr_rand_en.attr; +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; + *format_attrs++ = &fetch_l3missonly.attr.attr; + }
You should also write the terminating NULL pointer here, though the mem is preinitialized zero.
Quoted 16 lines
arch/x86/events/amd/ibs.c +7
-1+perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" ); +} + +static __init void perf_ibs_op_prepare (void ) +{ +struct attribute **format_attrs = perf_ibs_op.format_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ; - *attr++ = &format_attr_cnt_ctl.attr; + *format_attrs++ = &format_attr_cnt_ctl.attr; }if (ibs_caps &IBS_CAPS_OPCNTEXT ) {
arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 802
Quoted 10 lines
arch/x86/events/amd/ibs.c +6
-0@@ -786,7 +793,18 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=IBS_OP_MAX_CNT_EXT_MASK ; } +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; + *format_attrs++ = &op_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" ); +}
Same for this function: *_init(), error code, attrs, terminating NULL.
arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 810
Quoted 8 lines
arch/x86/events/amd/ibs.c +5
-0+ +static __init void perf_event_ibs_init (void ) +{ +perf_ibs_fetch_prepare (); +perf_ibs_op_prepare ();register_nmi_handler (NMI_LOCAL , perf_ibs_nmi_handler,0 ,"perf_ibs" );pr_info ("perf: AMD IBS detected (0x%08x)\n" , ibs_caps);
The function is now small enough to be squashed into amd_ibs_init().
-Robert
Re: [PATCH 1/6] perf/amd/ibs: Add support for L3 miss filtering
Quoted 31 lines · Robert Richter
Quoted 30 lines · Ravi Bangoria
IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems.
Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage:
# perf record -a -e ibs_op/l3missonly=1/ --raw-samples sleep 5Signed-off-by Ravi Bangoria <[email protected]>--- arch/x86/events/amd/ibs.c | 42 ++++++++++++++++++++++--------- arch/x86/include/asm/perf_event.h | 3 +++ 2 files changed, 33 insertions(+), 12 deletions(-)arch/x86/events/amd/ibs.c +2
-0@@ -520,16 +520,12 @@ static void perf_ibs_read(struct perf_event *event) { }PMU_FORMAT_ATTR (rand_en,"config:57" );PMU_FORMAT_ATTR (cnt_ctl,"config:19" ); +PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" ); +PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" );
Quoted 14 lines
arch/x86/events/amd/ibs.c static void perf_ibs_read(struct perf_event *event) { } · line 528
Quoted 12 lines
arch/x86/events/amd/ibs.c +3
-9-static struct attribute *ibs_fetch_format_attrs[] = { - &format_attr_rand_en.attr, -NULL , -}; - -static struct attribute *ibs_op_format_attrs[] = { -NULL ,/* &format_attr_cnt_ctl.attr if IBS_CAPS_OPCNT */ -NULL , -}; +/* size = nr attrs plus NULL at the end */ +static struct attribute *ibs_fetch_format_attrs[3 ]; +static struct attribute *ibs_op_format_attrs[3 ];Define a macro for the array size.
Except defining size of the above arrays, there is no use of such macros. So I don't feel the need of it.
Quoted 8 lines
Quoted 8 lines
arch/x86/events/amd/ibs.c +0
-0static struct perf_ibs perf_ibs_fetch = { .pmu = {@@ -759,9 +755,9 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)return ret; }
Quoted 5 lines
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 758
Quoted 2 lines
arch/x86/events/amd/ibs.c +1
-1-static __init void perf_event_ibs_init (void ) +static __init void perf_ibs_fetch_prepare (void )Since this actually initializes the pmu, let's call that
perf_ibs_fetch_init().
Sure
Quoted 4 lines
For low level init functions it would be good to keep track of the return code even if it is later not evaluated. So these kind of function should return an error code.
Sure
Quoted 14 lines
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 760
Quoted 4 lines
arch/x86/events/amd/ibs.c +1
-1{ -struct attribute **attr = ibs_op_format_attrs; +struct attribute **format_attrs = perf_ibs_fetch.format_attrs;I think we could keep this short here with 'attr'.
Quoted 7 lines
arch/x86/events/amd/ibs.c +0
-0/* * Some chips fail to reset the fetch count when it is written; instead @@ -773,11 +769,22 @@ static __init void perf_event_ibs_init(void)if (boot_cpu_data.x86 ==0x19 && boot_cpu_data.x86_model <0x10 ) perf_ibs_fetch.fetch_ignore_if_zero_rip =1 ;
Quoted 8 lines
arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 776
Quoted 5 lines
arch/x86/events/amd/ibs.c +5
-0+ *format_attrs++ = &format_attr_rand_en.attr; +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; + *format_attrs++ = &fetch_l3missonly.attr.attr; + }You should also write the terminating NULL pointer here, though the mem is preinitialized zero.
That seems unnecessary
Quoted 36 lines
Quoted 17 lines
arch/x86/events/amd/ibs.c +7
-1+perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" ); +} + +static __init void perf_ibs_op_prepare (void ) +{ +struct attribute **format_attrs = perf_ibs_op.format_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ; - *attr++ = &format_attr_cnt_ctl.attr; + *format_attrs++ = &format_attr_cnt_ctl.attr; }if (ibs_caps &IBS_CAPS_OPCNTEXT ) {arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 802
Quoted 10 lines
arch/x86/events/amd/ibs.c +6
-0@@ -786,7 +793,18 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=IBS_OP_MAX_CNT_EXT_MASK ; } +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; + *format_attrs++ = &op_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" ); +}Same for this function:
*_init(), error code, attrs, terminating NULL.Quoted 6 lines
arch/x86/events/amd/ibs.c +5
-0+ +static __init void perf_event_ibs_init (void ) +{ +perf_ibs_fetch_prepare (); +perf_ibs_op_prepare ();
Quoted 4 lines
arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 810
Quoted 2 lines
arch/x86/events/amd/ibs.c +0
-0register_nmi_handler (NMI_LOCAL , perf_ibs_nmi_handler,0 ,"perf_ibs" );pr_info ("perf: AMD IBS detected (0x%08x)\n" , ibs_caps);The function is now small enough to be squashed into
amd_ibs_init().
It's small enough but it still make sense to keep this function, as there is an empty version of it when (CONFIG_PERF_EVENTS=n && CONFIG_CPU_SUP_AMD=n).
Thanks for the review,
Ravi
Peter Zijlstra
maintainerRe: [PATCH 1/6] perf/amd/ibs: Add support for L3 miss filtering
In reply to Ravi BangoriaQuoted 82 lines · Ravi Bangoria
IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems.
Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage:
# perf record -a -e ibs_op/l3missonly=1/ --raw-samples sleep 5Signed-off-by Ravi Bangoria <[email protected]>--- arch/x86/events/amd/ibs.c | 42 ++++++++++++++++++++++--------- arch/x86/include/asm/perf_event.h | 3 +++ 2 files changed, 33 insertions(+), 12 deletions(-)arch/x86/events/amd/ibs.c +19
-12@@ -520,16 +520,12 @@ static void perf_ibs_read(struct perf_event *event) { }PMU_FORMAT_ATTR (rand_en,"config:57" );PMU_FORMAT_ATTR (cnt_ctl,"config:19" ); +PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" ); +PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); -static struct attribute *ibs_fetch_format_attrs[] = { - &format_attr_rand_en.attr, -NULL , -}; - -static struct attribute *ibs_op_format_attrs[] = { -NULL ,/* &format_attr_cnt_ctl.attr if IBS_CAPS_OPCNT */ -NULL , -}; +/* size = nr attrs plus NULL at the end */ +static struct attribute *ibs_fetch_format_attrs[3 ]; +static struct attribute *ibs_op_format_attrs[3 ];static struct perf_ibs perf_ibs_fetch = { .pmu = {@@ -759,9 +755,9 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)return ret; } -static __init void perf_event_ibs_init (void ) +static __init void perf_ibs_fetch_prepare (void ) { -struct attribute **attr = ibs_op_format_attrs; +struct attribute **format_attrs = perf_ibs_fetch.format_attrs;/* * Some chips fail to reset the fetch count when it is written; instead @@ -773,11 +769,22 @@ static __init void perf_event_ibs_init(void)if (boot_cpu_data.x86 ==0x19 && boot_cpu_data.x86_model <0x10 ) perf_ibs_fetch.fetch_ignore_if_zero_rip =1 ; + *format_attrs++ = &format_attr_rand_en.attr; +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; + *format_attrs++ = &fetch_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" ); +} + +static __init void perf_ibs_op_prepare (void ) +{ +struct attribute **format_attrs = perf_ibs_op.format_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ; - *attr++ = &format_attr_cnt_ctl.attr; + *format_attrs++ = &format_attr_cnt_ctl.attr; }if (ibs_caps &IBS_CAPS_OPCNTEXT ) {
arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 802
Quoted 10 lines
arch/x86/events/amd/ibs.c +6
-0@@ -786,7 +793,18 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=IBS_OP_MAX_CNT_EXT_MASK ; } +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; + *format_attrs++ = &op_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" ); +}
Right, so Greg told us to stop doing silly things like this and use .is_visible, also see commits like:
b7c9b3927337 ("perf/x86/intel: Use ->is_visible callback for default group")
There's quite a bit of that in the intel driver and some in the x86 core code too. Please have a look.
Re: [PATCH 1/6] perf/amd/ibs: Add support for L3 miss filtering
Quoted 97 lines · Peter Zijlstra
Quoted 82 lines · Ravi Bangoria
IBS L3 miss filtering works by tagging an instruction on IBS counter overflow and generating an NMI if the tagged instruction causes an L3 miss. Samples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu). This helps in reducing sampling overhead when user is interested only in such samples. One of the use case of such filtered samples is to feed data to page-migration daemon in tiered memory systems.
Add support for L3 miss filtering in IBS driver via new pmu attribute "l3missonly". Example usage:
# perf record -a -e ibs_op/l3missonly=1/ --raw-samples sleep 5Signed-off-by Ravi Bangoria <[email protected]>--- arch/x86/events/amd/ibs.c | 42 ++++++++++++++++++++++--------- arch/x86/include/asm/perf_event.h | 3 +++ 2 files changed, 33 insertions(+), 12 deletions(-)arch/x86/events/amd/ibs.c +19
-12@@ -520,16 +520,12 @@ static void perf_ibs_read(struct perf_event *event) { }PMU_FORMAT_ATTR (rand_en,"config:57" );PMU_FORMAT_ATTR (cnt_ctl,"config:19" ); +PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" ); +PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); -static struct attribute *ibs_fetch_format_attrs[] = { - &format_attr_rand_en.attr, -NULL , -}; - -static struct attribute *ibs_op_format_attrs[] = { -NULL ,/* &format_attr_cnt_ctl.attr if IBS_CAPS_OPCNT */ -NULL , -}; +/* size = nr attrs plus NULL at the end */ +static struct attribute *ibs_fetch_format_attrs[3 ]; +static struct attribute *ibs_op_format_attrs[3 ];static struct perf_ibs perf_ibs_fetch = { .pmu = {@@ -759,9 +755,9 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)return ret; } -static __init void perf_event_ibs_init (void ) +static __init void perf_ibs_fetch_prepare (void ) { -struct attribute **attr = ibs_op_format_attrs; +struct attribute **format_attrs = perf_ibs_fetch.format_attrs;/* * Some chips fail to reset the fetch count when it is written; instead @@ -773,11 +769,22 @@ static __init void perf_event_ibs_init(void)if (boot_cpu_data.x86 ==0x19 && boot_cpu_data.x86_model <0x10 ) perf_ibs_fetch.fetch_ignore_if_zero_rip =1 ; + *format_attrs++ = &format_attr_rand_en.attr; +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; + *format_attrs++ = &fetch_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" ); +} + +static __init void perf_ibs_op_prepare (void ) +{ +struct attribute **format_attrs = perf_ibs_op.format_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ; - *attr++ = &format_attr_cnt_ctl.attr; + *format_attrs++ = &format_attr_cnt_ctl.attr; }if (ibs_caps &IBS_CAPS_OPCNTEXT ) {arch/x86/events/amd/ibs.c static __init void perf_event_ibs_init(void) · line 802
Quoted 10 lines
arch/x86/events/amd/ibs.c +6
-0@@ -786,7 +793,18 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |=IBS_OP_MAX_CNT_EXT_MASK ; } +if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { + perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; + *format_attrs++ = &op_l3missonly.attr.attr; + } +perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" ); +}Right, so Greg told us to stop doing silly things like this and use .is_visible, also see commits like:
Quoted 4 lines
b7c9b3927337("perf/x86/intel: Use ->is_visible callback for default group")There's quite a bit of that in the intel driver and some in the x86 core code too. Please have a look.
Sure.
Thanks for the review,
Ravi
PATCH 2/6 perf/amd/ibs: Advertise zen4_ibs_extensions as pmu capability attribute
In reply to Ravi BangoriaPMU driver can advertise certain feature via capability attribute('caps' sysfs directory) which can be consumed by userspace tools like perf. Add zen4_ibs_extensions capability attribute for IBS pmus. This attribute will be enabled when CPUID_Fn8000001B_EAX[11] is set.
Without patch:
$ ls /sys/bus/event_source/devices/ibs_op/caps ls: cannot access '/sys/.../ibs_op/caps': No such file or directory
With patch:
$ ls /sys/bus/event_source/devices/ibs_op/caps zen4_ibs_extensions
--- arch/x86/events/amd/ibs.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
arch/x86/events/amd/ibs.c +28 -6
@@ -95,8 +95,10 @@ struct perf_ibs {struct cpu_perf_ibs __percpu *pcpu;struct attribute **format_attrs; +struct attribute **caps_attrs;struct attribute_group format_group; -const struct attribute_group *attr_groups[2 ]; +struct attribute_group caps_group; +const struct attribute_group *attr_groups[3 ];u64 (*get_count)(u64 config); };
@@ -522,10 +524,13 @@ PMU_FORMAT_ATTR(rand_en, "config:57");PMU_FORMAT_ATTR (cnt_ctl,"config:19" );PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" );PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); +PMU_EVENT_ATTR_STRING (zen4_ibs_extensions, zen4_ibs_extensions,"1" );/* size = nr attrs plus NULL at the end */ static struct attribute *ibs_fetch_format_attrs[3 ];static struct attribute *ibs_op_format_attrs[3 ]; +static struct attribute *ibs_fetch_caps_attrs[2 ]; +static struct attribute *ibs_op_caps_attrs[2 ];static struct perf_ibs perf_ibs_fetch = { .pmu = {
@@ -548,6 +553,7 @@ static struct perf_ibs perf_ibs_fetch = { .offset_mask = { MSR_AMD64_IBSFETCH_REG_MASK }, .offset_max = MSR_AMD64_IBSFETCH_REG_COUNT, .format_attrs = ibs_fetch_format_attrs, + .caps_attrs = ibs_fetch_caps_attrs, .get_count = get_ibs_fetch_count, };
@@ -574,6 +580,7 @@ static struct perf_ibs perf_ibs_op = { .offset_mask = { MSR_AMD64_IBSOP_REG_MASK }, .offset_max = MSR_AMD64_IBSOP_REG_COUNT, .format_attrs = ibs_op_format_attrs, + .caps_attrs = ibs_op_caps_attrs, .get_count = get_ibs_op_count, };
@@ -728,6 +735,7 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) {struct cpu_perf_ibs __percpu *pcpu;int ret; +int i =0 ; pcpu = alloc_percpu(struct cpu_perf_ibs);if (!pcpu)
@@ -736,16 +744,26 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) perf_ibs->pcpu = pcpu;/* register attributes */ +memset (&perf_ibs->attr_groups,0 ,sizeof (perf_ibs->attr_groups));if (perf_ibs->format_attrs[0 ]) {memset (&perf_ibs->format_group,0 ,sizeof (perf_ibs->format_group)); - perf_ibs->format_group.name ="format" ; - perf_ibs->format_group.attrs = perf_ibs->format_attrs; + perf_ibs->format_group.name ="format" ; + perf_ibs->format_group.attrs = perf_ibs->format_attrs; -memset (&perf_ibs->attr_groups,0 ,sizeof (perf_ibs->attr_groups)); - perf_ibs->attr_groups[0 ] = &perf_ibs->format_group; - perf_ibs->pmu.attr_groups = perf_ibs->attr_groups; + perf_ibs->attr_groups[i++] = &perf_ibs->format_group; } +if (perf_ibs->caps_attrs[0 ]) { +memset (&perf_ibs->caps_group,0 ,sizeof (perf_ibs->caps_group)); + perf_ibs->caps_group.name ="caps" ; + perf_ibs->caps_group.attrs = perf_ibs->caps_attrs; + + perf_ibs->attr_groups[i++] = &perf_ibs->caps_group; + } + +if (i) + perf_ibs->pmu.attr_groups = perf_ibs->attr_groups; + ret =perf_pmu_register (&perf_ibs->pmu, name,-1 );if (ret) { perf_ibs->pcpu =NULL ;
@@ -758,6 +776,7 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)static __init void perf_ibs_fetch_prepare (void ) {struct attribute **format_attrs = perf_ibs_fetch.format_attrs; +struct attribute **caps_attr = perf_ibs_fetch.caps_attrs;/* * Some chips fail to reset the fetch count when it is written; instead
@@ -773,6 +792,7 @@ static __init void perf_ibs_fetch_prepare(void)if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; *format_attrs++ = &fetch_l3missonly.attr.attr; + *caps_attr++ = &zen4_ibs_extensions.attr.attr; }perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" );
@@ -781,6 +801,7 @@ static __init void perf_ibs_fetch_prepare(void)static __init void perf_ibs_op_prepare (void ) {struct attribute **format_attrs = perf_ibs_op.format_attrs; +struct attribute **caps_attr = perf_ibs_op.caps_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ;
@@ -796,6 +817,7 @@ static __init void perf_ibs_op_prepare(void)if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; *format_attrs++ = &op_l3missonly.attr.attr; + *caps_attr++ = &zen4_ibs_extensions.attr.attr; }perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" );
Signature · 1 line
2.27.0
Re: [PATCH 2/6] perf/amd/ibs: Advertise zen4_ibs_extensions as pmu capability attribute
Quoted 25 lines · Ravi Bangoria
PMU driver can advertise certain feature via capability attribute('caps' sysfs directory) which can be consumed by userspace tools like perf. Add
zen4_ibs_extensionscapability attribute for IBS pmus. This attribute will be enabled when CPUID_Fn8000001B_EAX[11] is set.Without patch:
$ ls /sys/bus/event_source/devices/ibs_op/caps ls: cannot access '/sys/.../ibs_op/caps': No such file or directoryWith patch:
$ ls /sys/bus/event_source/devices/ibs_op/caps zen4_ibs_extensionsSigned-off-by Ravi Bangoria <[email protected]>--- arch/x86/events/amd/ibs.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)arch/x86/events/amd/ibs.c +0
-0
arch/x86/events/amd/ibs.c struct perf_ibs { · line 101
Quoted 8 lines
arch/x86/events/amd/ibs.c +3
-1@@ -95,8 +95,10 @@ struct perf_ibs {struct cpu_perf_ibs __percpu *pcpu;struct attribute **format_attrs; +struct attribute **caps_attrs;struct attribute_group format_group; -const struct attribute_group *attr_groups[2 ]; +struct attribute_group caps_group; +const struct attribute_group *attr_groups[3 ];
Also add a macro for max groups.
Quoted 34 lines
arch/x86/events/amd/ibs.c +5
-0u64 (*get_count)(u64 config); };@@ -522,10 +524,13 @@ PMU_FORMAT_ATTR(rand_en, "config:57");PMU_FORMAT_ATTR (cnt_ctl,"config:19" );PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" );PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); +PMU_EVENT_ATTR_STRING (zen4_ibs_extensions, zen4_ibs_extensions,"1" );/* size = nr attrs plus NULL at the end */ static struct attribute *ibs_fetch_format_attrs[3 ];static struct attribute *ibs_op_format_attrs[3 ]; +static struct attribute *ibs_fetch_caps_attrs[2 ]; +static struct attribute *ibs_op_caps_attrs[2 ];static struct perf_ibs perf_ibs_fetch = { .pmu = {@@ -548,6 +553,7 @@ static struct perf_ibs perf_ibs_fetch = { .offset_mask = { MSR_AMD64_IBSFETCH_REG_MASK }, .offset_max = MSR_AMD64_IBSFETCH_REG_COUNT, .format_attrs = ibs_fetch_format_attrs, + .caps_attrs = ibs_fetch_caps_attrs, .get_count = get_ibs_fetch_count, };@@ -574,6 +580,7 @@ static struct perf_ibs perf_ibs_op = { .offset_mask = { MSR_AMD64_IBSOP_REG_MASK }, .offset_max = MSR_AMD64_IBSOP_REG_COUNT, .format_attrs = ibs_op_format_attrs, + .caps_attrs = ibs_op_caps_attrs, .get_count = get_ibs_op_count, };
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 738
Quoted 4 lines
arch/x86/events/amd/ibs.c +1
-0@@ -728,6 +735,7 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) {struct cpu_perf_ibs __percpu *pcpu;int ret; +int i =0 ;
'group'? Use a pointer to iterate over groups here same as for attrs?
struct attribute_group **group = &perf_ibs->attr_groups;
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 747
Quoted 8 lines
arch/x86/events/amd/ibs.c +1
-0pcpu = alloc_percpu(struct cpu_perf_ibs);if (!pcpu)@@ -736,16 +744,26 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) perf_ibs->pcpu = pcpu;/* register attributes */ +memset (&perf_ibs->attr_groups,0 ,sizeof (perf_ibs->attr_groups));
With a termination below this could be dropped.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 753
Quoted 11 lines
arch/x86/events/amd/ibs.c +3
-5if (perf_ibs->format_attrs[0 ]) {memset (&perf_ibs->format_group,0 ,sizeof (perf_ibs->format_group)); - perf_ibs->format_group.name ="format" ; - perf_ibs->format_group.attrs = perf_ibs->format_attrs; + perf_ibs->format_group.name ="format" ; + perf_ibs->format_group.attrs = perf_ibs->format_attrs; -memset (&perf_ibs->attr_groups,0 ,sizeof (perf_ibs->attr_groups)); - perf_ibs->attr_groups[0 ] = &perf_ibs->format_group; - perf_ibs->pmu.attr_groups = perf_ibs->attr_groups; + perf_ibs->attr_groups[i++] = &perf_ibs->format_group;
So this could be:
*groups++ = &perf_ibs->format_group
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 761
Quoted 8 lines
arch/x86/events/amd/ibs.c +6
-0} +if (perf_ibs->caps_attrs[0 ]) { +memset (&perf_ibs->caps_group,0 ,sizeof (perf_ibs->caps_group)); + perf_ibs->caps_group.name ="caps" ; + perf_ibs->caps_group.attrs = perf_ibs->caps_attrs; + + perf_ibs->attr_groups[i++] = &perf_ibs->caps_group;
Similar here.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 762
Quoted 1 line
arch/x86/events/amd/ibs.c +1
-0+ }
Add a terminating NULL pointer for groups here.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 764
Quoted 2 lines
arch/x86/events/amd/ibs.c +2
-0+ +if (i)
if (perf_ibs->attr_groups[0]) ...
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 779
Quoted 10 lines
arch/x86/events/amd/ibs.c +3
-0+ perf_ibs->pmu.attr_groups = perf_ibs->attr_groups; + ret =perf_pmu_register (&perf_ibs->pmu, name,-1 );if (ret) { perf_ibs->pcpu =NULL ;@@ -758,6 +776,7 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)static __init void perf_ibs_fetch_prepare (void ) {struct attribute **format_attrs = perf_ibs_fetch.format_attrs; +struct attribute **caps_attr = perf_ibs_fetch.caps_attrs;
Now I see why it was renamed, ok.
Quoted 20 lines
arch/x86/events/amd/ibs.c +2
-0/* * Some chips fail to reset the fetch count when it is written; instead @@ -773,6 +792,7 @@ static __init void perf_ibs_fetch_prepare(void)if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { perf_ibs_fetch.config_mask |=IBS_FETCH_L3MISSONLY ; *format_attrs++ = &fetch_l3missonly.attr.attr; + *caps_attr++ = &zen4_ibs_extensions.attr.attr; }perf_ibs_pmu_init (&perf_ibs_fetch,"ibs_fetch" );@@ -781,6 +801,7 @@ static __init void perf_ibs_fetch_prepare(void)static __init void perf_ibs_op_prepare (void ) {struct attribute **format_attrs = perf_ibs_op.format_attrs; +struct attribute **caps_attr = perf_ibs_op.caps_attrs;if (ibs_caps &IBS_CAPS_OPCNT ) { perf_ibs_op.config_mask |=IBS_OP_CNT_CTL ;
arch/x86/events/amd/ibs.c static __init void perf_ibs_op_prepare(void) · line 821
Quoted 5 lines
arch/x86/events/amd/ibs.c +1
-0@@ -796,6 +817,7 @@ static __init void perf_ibs_op_prepare(void)if (ibs_caps &IBS_CAPS_ZEN4IBSEXTENSIONS ) { perf_ibs_op.config_mask |=IBS_OP_L3MISSONLY ; *format_attrs++ = &op_l3missonly.attr.attr; + *caps_attr++ = &zen4_ibs_extensions.attr.attr; }
Also add a termination for caps here.
-Robert
Quoted 5 lines
arch/x86/events/amd/ibs.c +0
-0perf_ibs_pmu_init (&perf_ibs_op,"ibs_op" );Signature · 1 line
2.27.0
Re: [PATCH 2/6] perf/amd/ibs: Advertise zen4_ibs_extensions as pmu capability attribute
Quoted 28 lines · Robert Richter
Quoted 27 lines · Ravi Bangoria
PMU driver can advertise certain feature via capability attribute('caps' sysfs directory) which can be consumed by userspace tools like perf. Add
zen4_ibs_extensionscapability attribute for IBS pmus. This attribute will be enabled when CPUID_Fn8000001B_EAX[11] is set.Without patch:
$ ls /sys/bus/event_source/devices/ibs_op/caps ls: cannot access '/sys/.../ibs_op/caps': No such file or directoryWith patch:
$ ls /sys/bus/event_source/devices/ibs_op/caps zen4_ibs_extensionsSigned-off-by Ravi Bangoria <[email protected]>--- arch/x86/events/amd/ibs.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)arch/x86/events/amd/ibs.c +0
-0@@ -95,8 +95,10 @@ struct perf_ibs {struct cpu_perf_ibs __percpu *pcpu;
Quoted 8 lines
arch/x86/events/amd/ibs.c struct perf_ibs { · line 101
Quoted 6 lines
arch/x86/events/amd/ibs.c +3
-1struct attribute **format_attrs; +struct attribute **caps_attrs;struct attribute_group format_group; -const struct attribute_group *attr_groups[2 ]; +struct attribute_group caps_group; +const struct attribute_group *attr_groups[3 ];Also add a macro for max groups.
Same as previous patch, except defining size of the array, it won't be used anywhere else.
Quoted 42 lines
Quoted 35 lines
arch/x86/events/amd/ibs.c +5
-0u64 (*get_count)(u64 config); };@@ -522,10 +524,13 @@ PMU_FORMAT_ATTR(rand_en, "config:57");PMU_FORMAT_ATTR (cnt_ctl,"config:19" );PMU_EVENT_ATTR_STRING (l3missonly, fetch_l3missonly,"config:59" );PMU_EVENT_ATTR_STRING (l3missonly, op_l3missonly,"config:16" ); +PMU_EVENT_ATTR_STRING (zen4_ibs_extensions, zen4_ibs_extensions,"1" );/* size = nr attrs plus NULL at the end */ static struct attribute *ibs_fetch_format_attrs[3 ];static struct attribute *ibs_op_format_attrs[3 ]; +static struct attribute *ibs_fetch_caps_attrs[2 ]; +static struct attribute *ibs_op_caps_attrs[2 ];static struct perf_ibs perf_ibs_fetch = { .pmu = {@@ -548,6 +553,7 @@ static struct perf_ibs perf_ibs_fetch = { .offset_mask = { MSR_AMD64_IBSFETCH_REG_MASK }, .offset_max = MSR_AMD64_IBSFETCH_REG_COUNT, .format_attrs = ibs_fetch_format_attrs, + .caps_attrs = ibs_fetch_caps_attrs, .get_count = get_ibs_fetch_count, };@@ -574,6 +580,7 @@ static struct perf_ibs perf_ibs_op = { .offset_mask = { MSR_AMD64_IBSOP_REG_MASK }, .offset_max = MSR_AMD64_IBSOP_REG_COUNT, .format_attrs = ibs_op_format_attrs, + .caps_attrs = ibs_op_caps_attrs, .get_count = get_ibs_op_count, };arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 738
Quoted 4 lines
arch/x86/events/amd/ibs.c +1
-0@@ -728,6 +735,7 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) {struct cpu_perf_ibs __percpu *pcpu;int ret; +int i =0 ;'group'? Use a pointer to iterate over groups here same as for attrs?
Quoted 1 line
struct attribute_group **group = &perf_ibs->attr_groups;
Sure.
Quoted 11 lines
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 747
Quoted 9 lines
arch/x86/events/amd/ibs.c +1
-0pcpu = alloc_percpu(struct cpu_perf_ibs);if (!pcpu)@@ -736,16 +744,26 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) perf_ibs->pcpu = pcpu;/* register attributes */ +memset (&perf_ibs->attr_groups,0 ,sizeof (perf_ibs->attr_groups));With a termination below this could be dropped.
I think we can just remove this line. perf_ibs points to either perf_ibs_fetch or perf_ibs_op, both of which are global variables and would be preinitialized with 0s.
Quoted 38 lines
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 753
Quoted 12 lines
arch/x86/events/amd/ibs.c +3
-5if (perf_ibs->format_attrs[0 ]) {memset (&perf_ibs->format_group,0 ,sizeof (perf_ibs->format_group)); - perf_ibs->format_group.name ="format" ; - perf_ibs->format_group.attrs = perf_ibs->format_attrs; + perf_ibs->format_group.name ="format" ; + perf_ibs->format_group.attrs = perf_ibs->format_attrs; -memset (&perf_ibs->attr_groups,0 ,sizeof (perf_ibs->attr_groups)); - perf_ibs->attr_groups[0 ] = &perf_ibs->format_group; - perf_ibs->pmu.attr_groups = perf_ibs->attr_groups; + perf_ibs->attr_groups[i++] = &perf_ibs->format_group;So this could be:
*groups++ = &perf_ibs->format_grouparch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 761
Quoted 8 lines
arch/x86/events/amd/ibs.c +6
-0} +if (perf_ibs->caps_attrs[0 ]) { +memset (&perf_ibs->caps_group,0 ,sizeof (perf_ibs->caps_group)); + perf_ibs->caps_group.name ="caps" ; + perf_ibs->caps_group.attrs = perf_ibs->caps_attrs; + + perf_ibs->attr_groups[i++] = &perf_ibs->caps_group;Similar here.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 762
Quoted 1 line
arch/x86/events/amd/ibs.c +1
-0+ }Add a terminating NULL pointer for groups here.
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 764
Quoted 2 lines
arch/x86/events/amd/ibs.c +2
-0+ +if (i)if (perf_ibs->attr_groups[0]) ...
Quoted 12 lines
arch/x86/events/amd/ibs.c static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) · line 779
Quoted 10 lines
arch/x86/events/amd/ibs.c +3
-0+ perf_ibs->pmu.attr_groups = perf_ibs->attr_groups; + ret =perf_pmu_register (&perf_ibs->pmu, name,-1 );if (ret) { perf_ibs->pcpu =NULL ;@@ -758,6 +776,7 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name)static __init void perf_ibs_fetch_prepare (void ) {struct attribute **format_attrs = perf_ibs_fetch.format_attrs; +struct attribute **caps_attr = perf_ibs_fetch.caps_attrs;Now I see why it was renamed, ok.
Yup.
Thanks for the review,
Ravi
PATCH 3/6 perf/tool/amd/ibs: Warn about sampling period skew
In reply to Ravi BangoriaSamples without an L3 miss are discarded and counter is reset with random value (between 1-15 for fetch pmu and 1-127 for op pmu) when IBS L3 miss filtering is enabled. This causes a sampling period skew but there is no way to reconstruct aggregated sampling period. So print a warning at perf record if user sets l3missonly=1.
Ex:
# perf record -c 10000 -C 0 -e ibs_op/l3missonly=1/ WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled and tagged operation does not cause L3 Miss. This causes sampling period skew.
--- tools/perf/arch/x86/util/evsel.c | 31 +++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 7 +++++++ tools/perf/util/evsel.h | 1 + 3 files changed, 39 insertions(+)
tools/perf/arch/x86/util/evsel.c +31 -0
@@ -4,6 +4,8 @@#include "util/evsel.h" #include "util/env.h" #include "linux/string.h" +#include "util/pmu.h" +#include "util/debug.h" void arch_evsel__set_sample_weight (struct evsel *evsel) {
@@ -29,3 +31,32 @@ void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr)free (env.cpuid); } + +void arch_evsel__warn_ambiguity (struct evsel *evsel,struct perf_event_attr *attr) +{ +struct perf_env *env =evsel__env (evsel); +struct perf_pmu *evsel_pmu =evsel__find_pmu (evsel); +struct perf_pmu *ibs_fetch_pmu =perf_pmu__find ("ibs_fetch" ); +struct perf_pmu *ibs_op_pmu =perf_pmu__find ("ibs_op" ); +static int warned_once; + +if (warned_once || !perf_env__cpuid (env) || !env->cpuid || + !strstarts (env->cpuid,"AuthenticAMD" ) || !evsel_pmu) +return ; + +if (ibs_fetch_pmu && ibs_fetch_pmu->type == evsel_pmu->type) { +if (attr->config & (1ULL <<59 )) { +pr_warning ( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period skew.\n" ); + warned_once =1 ; + } + }else if (ibs_op_pmu && ibs_op_pmu->type == evsel_pmu->type) { +if (attr->config & (1ULL <<16 )) { +pr_warning ( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period skew.\n" ); + warned_once =1 ; + } + } +}
tools/perf/util/evsel.c +7 -0
@@ -1064,6 +1064,11 @@ void __weak arch_evsel__fixup_new_cycles(struct perf_event_attr *attr __maybe_un { } +void __weak arch_evsel__warn_ambiguity (struct evsel *evsel__maybe_unused , +struct perf_event_attr *attr__maybe_unused ) +{ +} +static void evsel__set_default_freq_period (struct record_opts *opts,struct perf_event_attr *attr) {
@@ -1339,6 +1344,8 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,*/ if (evsel__is_dummy_event (evsel))evsel__reset_sample_bit (evsel,BRANCH_STACK ); + +arch_evsel__warn_ambiguity (evsel, attr); }int evsel__set_filter (struct evsel *evsel,const char *filter)
tools/perf/util/evsel.h +1 -0
@@ -281,6 +281,7 @@ void evsel__set_sample_id(struct evsel *evsel, bool use_sample_identifier);void arch_evsel__set_sample_weight (struct evsel *evsel);void arch_evsel__fixup_new_cycles (struct perf_event_attr *attr); +void arch_evsel__warn_ambiguity (struct evsel *evsel,struct perf_event_attr *attr);int evsel__set_filter (struct evsel *evsel,const char *filter);int evsel__append_tp_filter (struct evsel *evsel,const char *filter);
Signature · 1 line
2.27.0
Re: [PATCH 3/6] perf/tool/amd/ibs: Warn about sampling period skew
tools/perf/arch/x86/util/evsel.c void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr) · line 35
Quoted 6 lines · Ravi Bangoria
tools/perf/arch/x86/util/evsel.c +2
-0@@ -29,3 +31,32 @@ void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr)free (env.cpuid); } + +void arch_evsel__warn_ambiguity (struct evsel *evsel,struct perf_event_attr *attr)
Have an 'ibs_' string in the name?
Quoted 13 lines
tools/perf/arch/x86/util/evsel.c +13
-0+{ +struct perf_env *env =evsel__env (evsel); +struct perf_pmu *evsel_pmu =evsel__find_pmu (evsel); +struct perf_pmu *ibs_fetch_pmu =perf_pmu__find ("ibs_fetch" ); +struct perf_pmu *ibs_op_pmu =perf_pmu__find ("ibs_op" ); +static int warned_once; + +if (warned_once || !perf_env__cpuid (env) || !env->cpuid || + !strstarts (env->cpuid,"AuthenticAMD" ) || !evsel_pmu) +return ; + +if (ibs_fetch_pmu && ibs_fetch_pmu->type == evsel_pmu->type) { +if (attr->config & (1ULL <<59 )) {
tools/perf/arch/x86/util/evsel.c void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr) · line 58
Quoted 10 lines
tools/perf/arch/x86/util/evsel.c +10
-0+pr_warning ( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period skew.\n" ); + warned_once =1 ; + } + }else if (ibs_op_pmu && ibs_op_pmu->type == evsel_pmu->type) { +if (attr->config & (1ULL <<16 )) { +pr_warning ( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period skew.\n" );
Avoid duplicate code. You could move it to the end of the function and early return if the config bit is not set.
tools/perf/arch/x86/util/evsel.c void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr) · line 61
Quoted 4 lines
tools/perf/arch/x86/util/evsel.c +4
-0+ warned_once =1 ; + } + } +}
-Robert
Re: [PATCH 3/6] perf/tool/amd/ibs: Warn about sampling period skew
Quoted 10 lines · Robert Richter
tools/perf/arch/x86/util/evsel.c void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr) · line 35
Quoted 6 lines · Ravi Bangoria
tools/perf/arch/x86/util/evsel.c +2
-0@@ -29,3 +31,32 @@ void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr)free (env.cpuid); } + +void arch_evsel__warn_ambiguity (struct evsel *evsel,struct perf_event_attr *attr)Have an '
ibs_' string in the name?
No, this is not ibs specific. Any arch can define it's own version.
Quoted 19 lines
Quoted 19 lines
tools/perf/arch/x86/util/evsel.c +18
-0+{ +struct perf_env *env =evsel__env (evsel); +struct perf_pmu *evsel_pmu =evsel__find_pmu (evsel); +struct perf_pmu *ibs_fetch_pmu =perf_pmu__find ("ibs_fetch" ); +struct perf_pmu *ibs_op_pmu =perf_pmu__find ("ibs_op" ); +static int warned_once; + +if (warned_once || !perf_env__cpuid (env) || !env->cpuid || + !strstarts (env->cpuid,"AuthenticAMD" ) || !evsel_pmu) +return ; + +if (ibs_fetch_pmu && ibs_fetch_pmu->type == evsel_pmu->type) { +if (attr->config & (1ULL <<59 )) { +pr_warning ( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period skew.\n" ); + warned_once =1 ; + }
Quoted 8 lines
tools/perf/arch/x86/util/evsel.c void arch_evsel__fixup_new_cycles(struct perf_event_attr *attr) · line 58
Quoted 5 lines
tools/perf/arch/x86/util/evsel.c +5
-0+ }else if (ibs_op_pmu && ibs_op_pmu->type == evsel_pmu->type) { +if (attr->config & (1ULL <<16 )) { +pr_warning ( +"WARNING: Hw internally resets sampling period when L3 Miss Filtering is enabled\n" +"and tagged operation does not cause L3 Miss. This causes sampling period skew.\n" );Avoid duplicate code. You could move it to the end of the function and early return if the config bit is not set.
Sure.
Thanks,
Ravi
PATCH 4/6 perf/tool: Parse non-cpu pmu capabilities
In reply to Ravi BangoriaPmus advertise their capabilities via sysfs attribute files but perf tool currently parses only core(cpu) pmu capabilities. Add support for parsing non-cpu pmu capabilities.
--- .../Documentation/perf.data-file-format.txt | 18 ++ tools/perf/util/env.c | 48 +++- tools/perf/util/env.h | 11 + tools/perf/util/header.c | 211 ++++++++++++++++++ tools/perf/util/header.h | 1 + tools/perf/util/pmu.c | 15 +- tools/perf/util/pmu.h | 2 + 7 files changed, 301 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf.data-file-format.txt +18 -0
@@ -435,6 +435,24 @@ struct { } [nr_pmu]; }; + HEADER_PMU_CAPS = 32, + + List of pmu capabilities (except cpu pmu which is already + covered by HEADER_CPU_PMU_CAPS) + +struct { + u32 nr_pmus; + struct { + u8 core_type; /* For hybrid topology */ + char pmu_name[]; + u16 nr_caps; + struct { + char name[]; + char value[]; + } [nr_caps]; + } [nr_pmus]; +}; + other bits are reserved and should ignored for now HEADER_FEAT_BITS = 256,
tools/perf/util/env.c +47 -1
63 lines not on this page · raw message
tools/perf/util/env.h +11 -0
@@ -50,6 +50,13 @@ struct hybrid_cpc_node {char *pmu_name; }; +struct env_pmu_caps { +u8 core_type; +char *pmu_name; +u16 nr_caps; +char **pmu_caps; +}; +struct perf_env {char *hostname;char *os_release;
@@ -75,6 +82,7 @@ struct perf_env {int nr_cpu_pmu_caps;int nr_hybrid_nodes;int nr_hybrid_cpc_nodes; +int nr_pmus_with_caps;char *cmdline;const char **cmdline_argv;char *sibling_cores;
@@ -95,6 +103,7 @@ struct perf_env {unsigned long long memory_bsize;struct hybrid_node *hybrid_nodes;struct hybrid_cpc_node *hybrid_cpc_nodes; +struct env_pmu_caps *env_pmu_caps;#ifdef HAVE_LIBBPF_SUPPORT /* * bpf_info_lock protects bpf rbtrees. This is needed because the
@@ -172,4 +181,6 @@ bool perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node);struct btf_node *perf_env__find_btf (struct perf_env *env,__u32 btf_id);int perf_env__numa_node (struct perf_env *env,struct perf_cpu cpu); +char *perf_env__find_pmu_cap (struct perf_env *env,u8 core_type, +const char *pmu_name,const char *cap);#endif /* __PERF_ENV_H */
tools/perf/util/header.c +211 -0
241 lines not on this page · raw message
tools/perf/util/header.h +1 -0
@@ -47,6 +47,7 @@ enum {HEADER_CLOCK_DATA ,HEADER_HYBRID_TOPOLOGY ,HEADER_HYBRID_CPU_PMU_CAPS , +HEADER_PMU_CAPS ,HEADER_LAST_FEATURE , HEADER_FEAT_BITS = 256, };
tools/perf/util/pmu.c +11 -4
@@ -1890,16 +1890,22 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu)const char *sysfs =sysfs__mountpoint ();DIR *caps_dir;struct dirent *evt_ent; -int nr_caps =0 ; + +if (pmu->caps_initialized) +return pmu->nr_caps;if (!sysfs)return -1 ; + pmu->nr_caps =0 ; +snprintf (caps_path,PATH_MAX ,"%s" EVENT_SOURCE_DEVICE_PATH "%s/caps" , sysfs, pmu->name); -if (stat (caps_path, &st) <0 ) +if (stat (caps_path, &st) <0 ) { + pmu->caps_initialized = true;return 0 ;/* no error if caps does not exist */ + } caps_dir =opendir (caps_path);if (!caps_dir)
@@ -1926,13 +1932,14 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu)continue ; } - nr_caps++; + pmu->nr_caps++;fclose (file); }closedir (caps_dir); -return nr_caps; + pmu->caps_initialized = true; +return pmu->nr_caps; } void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
tools/perf/util/pmu.h +2 -0
@@ -46,6 +46,8 @@ struct perf_pmu {struct perf_cpu_map *cpus;struct list_head format;/* HEAD struct perf_pmu_format -> list */ struct list_head aliases;/* HEAD struct perf_pmu_alias -> list */ +bool caps_initialized; +u16 nr_caps;struct list_head caps;/* HEAD struct perf_pmu_caps -> list */ struct list_head list;/* ELEM */ struct list_head hybrid_list;
Signature · 1 line
2.27.0
Re: [PATCH 4/6] perf/tool: Parse non-cpu pmu capabilities
Quoted 16 lines · Ravi Bangoria
tools/perf/Documentation/perf.data-file-format.txt +8
-0@@ -435,6 +435,24 @@ struct { } [nr_pmu]; }; + HEADER_PMU_CAPS = 32, + + List of pmu capabilities (except cpu pmu which is already + covered by HEADER_CPU_PMU_CAPS) + +struct { + u32 nr_pmus; + struct {
tools/perf/Documentation/perf.data-file-format.txt struct { · line 455
Quoted 10 lines
tools/perf/Documentation/perf.data-file-format.txt +10
-0+ u8 core_type; /* For hybrid topology */ + char pmu_name[]; + u16 nr_caps; + struct { + char name[]; + char value[]; + } [nr_caps]; + } [nr_pmus]; +}; +
This looks quite a bit complex and special.
Why not just reusing struct nr_cpu_pmu_caps (id 28)? Rename it and introduce macros for backwards compatability if needed.
pmu_name is already encoded in sysfs and core_type could be a caps value?
-Robert
Re: [PATCH 4/6] perf/tool: Parse non-cpu pmu capabilities
Quoted 31 lines · Robert Richter
Quoted 16 lines · Ravi Bangoria
tools/perf/Documentation/perf.data-file-format.txt +8
-0@@ -435,6 +435,24 @@ struct { } [nr_pmu]; }; + HEADER_PMU_CAPS = 32, + + List of pmu capabilities (except cpu pmu which is already + covered by HEADER_CPU_PMU_CAPS) + +struct { + u32 nr_pmus; + struct {tools/perf/Documentation/perf.data-file-format.txt struct { · line 455
Quoted 10 lines
tools/perf/Documentation/perf.data-file-format.txt +10
-0+ u8 core_type; /* For hybrid topology */ + char pmu_name[]; + u16 nr_caps; + struct { + char name[]; + char value[]; + } [nr_caps]; + } [nr_pmus]; +}; +This looks quite a bit complex and special.
Quoted 2 lines
Why not just reusing struct
nr_cpu_pmu_caps(id 28)? Rename it and introduce macros for backwards compatability if needed.
No. HEADER_CPU_PMU_CAPS (id 28) is designed only for CPU pmu and can not save more than one pmu data. A designed proposed in this patch is generic and can be used to save capabilities of multiple pmus within single header. Something like:
struct {
nr_pmus=2,
[0] = struct {
core_type = 0,
pmu_name = "ibs_fetch"
nr_caps = 2,
[0] = { .name = "cap1", .value = "value1" }
[1] = { .name = "cap2", .value = "value2" }
},
[1] = struct {
core_type = 0,
pmu_name = "ibs_op"
nr_caps = 3,
[0] = { .name = "cap1", .value = "value1" }
[1] = { .name = "cap2", .value = "value2" }
[2] = { .name = "cap3", .value = "value3" }
},
}Quoted 3 lines
pmu_nameis already encoded in sysfs andcore_typecould be a caps value?
pmu_name is needed to map capability with pmu. And core_type is needed when same pmu is supported by multiple core types (like P-core / E-core on Intel platform) but has different capabilities.
Thanks,
Ravi
PATCH 5/6 perf/tool/amd/ibs: Support new IBS bits in raw trace dump
In reply to Ravi BangoriaIBS support has been enhanced with two new features in upcoming uarch:
1. DataSrc extension and 2. L3 miss filtering. Additional set of bits has been introduced in IBS registers to exploit these features. Interpret those bits while doing perf report/script raw dump.
IBS op pmu ex:
$ sudo ./perf record -c 130 -a -e ibs_op/l3missonly=1/ --raw-samples
$ sudo ./perf report -D
...
ibs_op_ctl: 0000004500070008 MaxCnt 128 L3MissOnly 1 En 1
Val 1 CntCtl 0=cycles CurCnt 69
ibs_op_data: 0000000000710002 CompToRetCtr 2 TagToRetCtr 113
BrnRet 0 RipInvalid 0 BrnFuse 0 Microcode 0
ibs_op_data2: 0000000000000002 CacheHitSt 0=M-state RmtNode 0
DataSrc 2=A peer cache in a near CCX
ibs_op_data3: 000000681d1700a1 LdOp 1 StOp 0 DcL1TlbMiss 0
DcL2TlbMiss 0 DcL1TlbHit2M 0 DcL1TlbHit1G 1 DcL2TlbHit2M 0
DcMiss 1 DcMisAcc 0 DcWcMemAcc 0 DcUcMemAcc 0 DcLockedOp 0
DcMissNoMabAlloc 1 DcLinAddrValid 1 DcPhyAddrValid 1
DcL2TlbHit1G 0 L2Miss 1 SwPf 0 OpMemWidth 8 bytes
OpDcMissOpenMemReqs 7 DcMissLat 104 TlbRefillLat 0IBS Fetch pmu ex:
$ sudo ./perf record -c 130 -a -e ibs_fetch/l3missonly=1/ --raw-samples
$ sudo ./perf report -D
...
ibs_fetch_ctl: 3c1f00c700080008 MaxCnt 128 Cnt 128 Lat 199
En 1 Val 1 Comp 1 IcMiss 1 PhyAddrValid 1 L1TlbPgSz 4KB
L1TlbMiss 0 L2TlbMiss 0 RandEn 0 L2Miss 1 L3MissOnly 1
FetchOcMiss 1 FetchL3Miss 1With the DataSrc extensions, the source of data can be decoded among:
- Local L3 or other L1/L2 in CCX.
- A peer cache in a near CCX.
- Data returned from DRAM.
- A peer cache in a far CCX.
- DRAM address map with "long latency" bit set.
- Data returned from MMIO/Config/PCI/APIC.
- Extension Memory (S-Link, GenZ, etc - identified by the CS target and/or address map at DF's choice).
- Peer Agent Memory.
--- arch/x86/include/asm/amd-ibs.h | 16 ++++--- tools/arch/x86/include/asm/amd-ibs.h | 16 ++++--- tools/perf/util/amd-sample-raw.c | 68 ++++++++++++++++++++++++---- 3 files changed, 80 insertions(+), 20 deletions(-)
arch/x86/include/asm/amd-ibs.h +10 -6
@@ -29,7 +29,10 @@ union ibs_fetch_ctl { rand_en:1, /* 57: random tagging enable */ fetch_l2_miss:1,/* 58: L2 miss for sampled fetch * (needs IbsFetchComp) */ - reserved:5; /* 59-63: reserved */ + l3_miss_only:1, /* 59: Collect L3 miss samples only */ + fetch_oc_miss:1,/* 60: Op cache miss for the sampled fetch */ + fetch_l3_miss:1,/* 61: L3 cache miss for the sampled fetch */ + reserved:2; /* 62-63: reserved */ }; };
@@ -38,14 +41,14 @@ union ibs_op_ctl {__u64 val;struct {__u64 opmaxcnt:16 ,/* 0-15: periodic op max. count */ - reserved0:1 ,/* 16: reserved */ + l3_miss_only:1 ,/* 16: Collect L3 miss samples only */ op_en:1 ,/* 17: op sampling enable */ op_val:1 ,/* 18: op sample valid */ cnt_ctl:1 ,/* 19: periodic op counter control */ opmaxcnt_ext:7 ,/* 20-26: upper 7 bits of periodic op maximum count */ - reserved1:5 ,/* 27-31: reserved */ + reserved0:5 ,/* 27-31: reserved */ opcurcnt:27 ,/* 32-58: periodic op counter current count */ - reserved2:5 ;/* 59-63: reserved */ + reserved1:5 ;/* 59-63: reserved */ }; };
@@ -71,11 +74,12 @@ union ibs_op_data {union ibs_op_data2 {__u64 val;struct { -__u64 data_src:3 ,/* 0-2: data source */ +__u64 data_src_lo:3 ,/* 0-2: data source low */ reserved0:1 ,/* 3: reserved */ rmt_node:1 ,/* 4: destination node */ cache_hit_st:1 ,/* 5: cache hit state */ - reserved1:57 ;/* 5-63: reserved */ + data_src_hi:2 ,/* 6-7: data source high */ + reserved1:56 ;/* 8-63: reserved */ }; };
tools/arch/x86/include/asm/amd-ibs.h +10 -6
@@ -29,7 +29,10 @@ union ibs_fetch_ctl { rand_en:1, /* 57: random tagging enable */ fetch_l2_miss:1,/* 58: L2 miss for sampled fetch * (needs IbsFetchComp) */ - reserved:5; /* 59-63: reserved */ + l3_miss_only:1, /* 59: Collect L3 miss samples only */ + fetch_oc_miss:1,/* 60: Op cache miss for the sampled fetch */ + fetch_l3_miss:1,/* 61: L3 cache miss for the sampled fetch */ + reserved:2; /* 62-63: reserved */ }; };
@@ -38,14 +41,14 @@ union ibs_op_ctl {__u64 val;struct {__u64 opmaxcnt:16 ,/* 0-15: periodic op max. count */ - reserved0:1 ,/* 16: reserved */ + l3_miss_only:1 ,/* 16: Collect L3 miss samples only */ op_en:1 ,/* 17: op sampling enable */ op_val:1 ,/* 18: op sample valid */ cnt_ctl:1 ,/* 19: periodic op counter control */ opmaxcnt_ext:7 ,/* 20-26: upper 7 bits of periodic op maximum count */ - reserved1:5 ,/* 27-31: reserved */ + reserved0:5 ,/* 27-31: reserved */ opcurcnt:27 ,/* 32-58: periodic op counter current count */ - reserved2:5 ;/* 59-63: reserved */ + reserved1:5 ;/* 59-63: reserved */ }; };
@@ -71,11 +74,12 @@ union ibs_op_data {union ibs_op_data2 {__u64 val;struct { -__u64 data_src:3 ,/* 0-2: data source */ +__u64 data_src_lo:3 ,/* 0-2: data source low */ reserved0:1 ,/* 3: reserved */ rmt_node:1 ,/* 4: destination node */ cache_hit_st:1 ,/* 5: cache hit state */ - reserved1:57 ;/* 5-63: reserved */ + data_src_hi:2 ,/* 6-7: data source high */ + reserved1:56 ;/* 8-63: reserved */ }; };
tools/perf/util/amd-sample-raw.c +60 -8
115 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH 5/6] perf/tool/amd/ibs: Support new IBS bits in raw trace dump
arch/x86/include/asm/amd-ibs.h union ibs_op_data { · line 82
Quoted 12 lines · Ravi Bangoria
arch/x86/include/asm/amd-ibs.h +3
-2@@ -71,11 +74,12 @@ union ibs_op_data {union ibs_op_data2 {__u64 val;struct { -__u64 data_src:3 ,/* 0-2: data source */ +__u64 data_src_lo:3 ,/* 0-2: data source low */ reserved0:1 ,/* 3: reserved */ rmt_node:1 ,/* 4: destination node */ cache_hit_st:1 ,/* 5: cache hit state */ - reserved1:57 ;/* 5-63: reserved */ + data_src_hi:2 ,/* 6-7: data source high */ + reserved1:56 ;/* 8-63: reserved */
Good catch, bit 63 was not defined before.
tools/perf/util/amd-sample-raw.c bool evlist__has_amd_ibs(struct evlist *evlist) · line 333
Quoted 10 lines
tools/perf/util/amd-sample-raw.c +3
-0}; };@@ -279,6 +328,9 @@ bool evlist__has_amd_ibs(struct evlist *evlist) pmu_mapping +=strlen (pmu_mapping) +1 /* '\0' */ ; } +if (perf_env__find_pmu_cap (env,0 ,"ibs_op" ,"zen4_ibs_extensions" )) + zen4_ibs_extensions =1 ; +
This caps check should be moved to ibs_op and ibs_fetch pmu specific code. Use the env of the specific pmu respectively in the sample decoding.
-Robert
Quoted 3 lines
tools/perf/util/amd-sample-raw.c +0
-0if (ibs_fetch_type || ibs_op_type) {if (!cpu_family)parse_cpuid (env);
Re: [PATCH 5/6] perf/tool/amd/ibs: Support new IBS bits in raw trace dump
Quoted 16 lines · Robert Richter
arch/x86/include/asm/amd-ibs.h union ibs_op_data { · line 82
Quoted 12 lines · Ravi Bangoria
arch/x86/include/asm/amd-ibs.h +3
-2@@ -71,11 +74,12 @@ union ibs_op_data {union ibs_op_data2 {__u64 val;struct { -__u64 data_src:3 ,/* 0-2: data source */ +__u64 data_src_lo:3 ,/* 0-2: data source low */ reserved0:1 ,/* 3: reserved */ rmt_node:1 ,/* 4: destination node */ cache_hit_st:1 ,/* 5: cache hit state */ - reserved1:57 ;/* 5-63: reserved */ + data_src_hi:2 ,/* 6-7: data source high */ + reserved1:56 ;/* 8-63: reserved */ Good catch, bit 63 was not defined before.
Thanks!
Quoted 8 lines
Quoted 8 lines
tools/perf/util/amd-sample-raw.c +0
-0}; };@@ -279,6 +328,9 @@ bool evlist__has_amd_ibs(struct evlist *evlist) pmu_mapping +=strlen (pmu_mapping) +1 /* '\0' */ ; }
Quoted 7 lines
tools/perf/util/amd-sample-raw.c bool evlist__has_amd_ibs(struct evlist *evlist) · line 333
Quoted 3 lines
tools/perf/util/amd-sample-raw.c +3
-0+if (perf_env__find_pmu_cap (env,0 ,"ibs_op" ,"zen4_ibs_extensions" )) + zen4_ibs_extensions =1 ; +This caps check should be moved to
ibs_opandibs_fetchpmu specific code. Use the env of the specific pmu respectively in the sample decoding.
IIRC, we don't populate perf_pmu at 'perf report' time as we might not be running 'perf report' on the same machine or even same arch.
Thanks for the review,
Ravi
PATCH 6/6 perf/tool/amd/ibs: Fix comment
In reply to Ravi Bangorias/IBS Op Data 2/IBS Op Data 1/ for MSR 0xc0011035.
--- arch/x86/include/asm/amd-ibs.h | 2 +- tools/arch/x86/include/asm/amd-ibs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/amd-ibs.h +1 -1
@@ -52,7 +52,7 @@ union ibs_op_ctl { }; }; -/* MSR 0xc0011035: IBS Op Data 2 */ +/* MSR 0xc0011035: IBS Op Data 1 */ union ibs_op_data {__u64 val;struct {
tools/arch/x86/include/asm/amd-ibs.h +1 -1
@@ -52,7 +52,7 @@ union ibs_op_ctl { }; }; -/* MSR 0xc0011035: IBS Op Data 2 */ +/* MSR 0xc0011035: IBS Op Data 1 */ union ibs_op_data {__u64 val;struct {
Signature · 1 line
2.27.0
Re: [PATCH 6/6] perf/tool/amd/ibs: Fix comment
Quoted 3 lines · Ravi Bangoria
s/IBS Op Data 2/IBS Op Data 1/ for MSR
0xc0011035.Signed-off-by Ravi Bangoria <[email protected]>
Looks good.
-Robert
Peter Zijlstra
maintainerQuoted 3 lines · Ravi Bangoria
IBS support has been enhanced with two new features in upcoming uarch:
1. DataSrc extension and 2. L3 Miss Filtering capability. Both are indicated byCPUID_Fn8000001B_EAXbit 11.
Hi Ravi, could you perhaps also look at fixing this existing IBS problem?
Quoted 9 lines · Peter Zijlstra
Quoted 3 lines · Ravi Bangoria
IBS support has been enhanced with two new features in upcoming uarch:
1. DataSrc extension and 2. L3 Miss Filtering capability. Both are indicated byCPUID_Fn8000001B_EAXbit 11.Hi Ravi, could you perhaps also look at fixing this existing IBS problem?
Sure. Will do.
Thanks.