arch/powerpc/perf: Fix perf record -d sample loss on non-marked events
PATCH 1/1 arch/powerpc/perf: Fix perf record -d sample loss on non-marked events
Previously, when running "perf record -d" on powerpc, perf would drop all samples that were not load or store instructions. This is because of an overly aggressive check introduced in 2ffb26afa642 ("arch/powerpc/perf:
Check the instruction type before creating sample with perf_mem_data_src") which drops samples when the SIER instruction value is considered reserved (0 or 7 in ISA 3.0, and 0 in ISA 3.1).
This happens because
1) "perf record -d" sets PERF_SAMPLE_DATA_SRC for general sampling.
2) When sampling non-memory instructions, the SIER instruction type is 0.
3) record_and_restart drops anything with SIER instruction type 0.
"perf mem record" uses marked events by setting MMCRA_SAMPLE_ENABLE which samples load/store instructions, so a sample with SIER instruction type of 0 would be an anomaly and should be dropped. So fix this issue by loosening the check to only include marked events. For non-marked events, the sample is kept and isa207_get_mem_data_src initializes data_src to 0, preserving the original fix in 2ffb26afa642.
before creating sample with perf_mem_data_src")
--- arch/powerpc/perf/core-book3s.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/perf/core-book3s.c +3 -2
@@ -2304,10 +2304,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,* In ISA v3.0 and before values "0" and "7" are considered reserved. * In ISA v3.1, value "7" has been used to indicate "larx/stcx". * Drop the sample if "type" has reserved values for this field with a -* ISA version check. +* ISA version check for marked events. */ if (event->attr.sample_type &PERF_SAMPLE_DATA_SRC && - ppmu->get_mem_data_src) { + ppmu->get_mem_data_src && + (regs->dsisr &MMCRA_SAMPLE_ENABLE )) { val = (regs->dar &SIER_TYPE_MASK ) >>SIER_TYPE_SHIFT ;if (val ==0 || (val ==7 && !cpu_has_feature (CPU_FTR_ARCH_31 ))) { record =0 ;
Signature · 1 line
2.51.1
Quoted 35 lines · Anubhav Shelat
Previously, when running "perf record -d" on powerpc, perf would drop all samples that were not load or store instructions. This is because of an overly aggressive check introduced in
2ffb26afa642("arch/powerpc/perf:
Check the instruction type before creating sample withperf_mem_data_src") which drops samples when the SIER instruction value is considered reserved (0 or 7 in ISA 3.0, and 0 in ISA 3.1).This happens because
1) "perf record -d" setsPERF_SAMPLE_DATA_SRCfor general sampling.
2) When sampling non-memory instructions, the SIER instruction type is 0.
3)record_and_restartdrops anything with SIER instruction type 0."perf mem record" uses marked events by setting
MMCRA_SAMPLE_ENABLEwhich samples load/store instructions, so a sample with SIER instruction type of 0 would be an anomaly and should be dropped. So fix this issue by loosening the check to only include marked events. For non-marked events, the sample is kept andisa207_get_mem_data_srcinitializesdata_srcto 0, preserving the original fix in2ffb26afa642.Fixes 2ffb26afa642 ("arch/powerpc/perf: Check the instruction typebefore creating sample with
perf_mem_data_src")Signed-off-by Anubhav Shelat <[email protected]>--- arch/powerpc/perf/core-book3s.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/powerpc/perf/core-book3s.c +0
-0@@ -2304,10 +2304,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,* In ISA v3.0 and before values "0" and "7" are considered reserved. * In ISA v3.1, value "7" has been used to indicate "larx/stcx". * Drop the sample if "type" has reserved values for this field with a
arch/powerpc/perf/core-book3s.c static void record_and_restart(struct perf_event *event, unsigned long val, · line 2314
Quoted 10 lines
arch/powerpc/perf/core-book3s.c +3
-2-* ISA version check. +* ISA version check for marked events. */ if (event->attr.sample_type &PERF_SAMPLE_DATA_SRC && - ppmu->get_mem_data_src) { + ppmu->get_mem_data_src && + (regs->dsisr &MMCRA_SAMPLE_ENABLE )) { val = (regs->dar &SIER_TYPE_MASK ) >>SIER_TYPE_SHIFT ;if (val ==0 || (val ==7 && !cpu_has_feature (CPU_FTR_ARCH_31 ))) { record =0 ;
ping
Quoted 52 lines · James Clark
Quoted 35 lines · Anubhav Shelat
Previously, when running "perf record -d" on powerpc, perf would drop all samples that were not load or store instructions. This is because of an overly aggressive check introduced in
2ffb26afa642("arch/powerpc/perf:
Check the instruction type before creating sample withperf_mem_data_src") which drops samples when the SIER instruction value is considered reserved (0 or 7 in ISA 3.0, and 0 in ISA 3.1).This happens because
1) "perf record -d" setsPERF_SAMPLE_DATA_SRCfor general sampling.
2) When sampling non-memory instructions, the SIER instruction type is 0.
3)record_and_restartdrops anything with SIER instruction type 0."perf mem record" uses marked events by setting
MMCRA_SAMPLE_ENABLEwhich samples load/store instructions, so a sample with SIER instruction type of 0 would be an anomaly and should be dropped. So fix this issue by loosening the check to only include marked events. For non-marked events, the sample is kept andisa207_get_mem_data_srcinitializesdata_srcto 0, preserving the original fix in2ffb26afa642.Fixes 2ffb26afa642 ("arch/powerpc/perf: Check the instruction typebefore creating sample with
perf_mem_data_src")Signed-off-by Anubhav Shelat <[email protected]>--- arch/powerpc/perf/core-book3s.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/powerpc/perf/core-book3s.c +0
-0@@ -2304,10 +2304,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,* In ISA v3.0 and before values "0" and "7" are considered reserved. * In ISA v3.1, value "7" has been used to indicate "larx/stcx". * Drop the sample if "type" has reserved values for this field with a arch/powerpc/perf/core-book3s.c static void record_and_restart(struct perf_event *event, unsigned long val, · line 2314
Quoted 10 lines
arch/powerpc/perf/core-book3s.c +3
-2-* ISA version check. +* ISA version check for marked events. */ if (event->attr.sample_type &PERF_SAMPLE_DATA_SRC && - ppmu->get_mem_data_src) { + ppmu->get_mem_data_src && + (regs->dsisr &MMCRA_SAMPLE_ENABLE )) { val = (regs->dar &SIER_TYPE_MASK ) >>SIER_TYPE_SHIFT ;if (val ==0 || (val ==7 && !cpu_has_feature (CPU_FTR_ARCH_31 ))) { record =0 ;Reviewed-by James Clark <[email protected]>