Skip to content

Commit e5f32ad

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/ds: Fix non 0 retire latency on Raptorlake
A non-0 retire latency can be observed on a Raptorlake which doesn't support the retire latency feature. By design, the retire latency shares the PERF_SAMPLE_WEIGHT_STRUCT sample type with other types of latency. That could avoid adding too many different sample types to support all kinds of latency. For the machine which doesn't support some kind of latency, 0 should be returned. Perf doesn’t clear/init all the fields of a sample data for the sake of performance. It expects the later perf_{prepare,output}_sample() to update the uninitialized field. However, the current implementation doesn't touch the field of the retire latency if the feature is not supported. The memory garbage is dumped into the perf data. Clear the retire latency if the feature is not supported. Fixes: c87a310 ("perf/x86: Support Retire Latency") Reported-by: "Bayduraev, Alexey V" <alexey.v.bayduraev@intel.com> Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: "Bayduraev, Alexey V" <alexey.v.bayduraev@intel.com> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20240708193336.1192217-4-kan.liang@linux.intel.com
1 parent 556a7c0 commit e5f32ad

File tree

1 file changed

+6
-2
lines changed
  • arch/x86/events/intel

1 file changed

+6
-2
lines changed

arch/x86/events/intel/ds.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,8 +1944,12 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
19441944
set_linear_ip(regs, basic->ip);
19451945
regs->flags = PERF_EFLAGS_EXACT;
19461946

1947-
if ((sample_type & PERF_SAMPLE_WEIGHT_STRUCT) && (x86_pmu.flags & PMU_FL_RETIRE_LATENCY))
1948-
data->weight.var3_w = format_size >> PEBS_RETIRE_LATENCY_OFFSET & PEBS_LATENCY_MASK;
1947+
if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) {
1948+
if (x86_pmu.flags & PMU_FL_RETIRE_LATENCY)
1949+
data->weight.var3_w = format_size >> PEBS_RETIRE_LATENCY_OFFSET & PEBS_LATENCY_MASK;
1950+
else
1951+
data->weight.var3_w = 0;
1952+
}
19491953

19501954
/*
19511955
* The record for MEMINFO is in front of GP

0 commit comments

Comments
 (0)