Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf/x86/intel/ds: Fix precise store latency handling

With the existing code in store_latency_data(), the memory operation (mem_op)
returned to the user is always OP_LOAD where in fact, it should be OP_STORE.
This comes from the fact that the function is simply grabbing the information
from a data source map which covers only load accesses. Intel 12th gen CPU
offers precise store sampling that captures both the data source and latency.
Therefore it can use the data source mapping table but must override the
memory operation to reflect stores instead of loads.

Fixes: 61b985e3e775 ("perf/x86/intel: Add perf core PMU support for Sapphire Rapids")
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220818054613.1548130-1-eranian@google.com

authored by

Stephane Eranian and committed by
Peter Zijlstra
d4bdb0be 7d359886

+9 -1
+9 -1
arch/x86/events/intel/ds.c
··· 291 291 static u64 store_latency_data(struct perf_event *event, u64 status) 292 292 { 293 293 union intel_x86_pebs_dse dse; 294 + union perf_mem_data_src src; 294 295 u64 val; 295 296 296 297 dse.val = status; ··· 305 304 306 305 val |= P(BLK, NA); 307 306 308 - return val; 307 + /* 308 + * the pebs_data_source table is only for loads 309 + * so override the mem_op to say STORE instead 310 + */ 311 + src.val = val; 312 + src.mem_op = P(OP,STORE); 313 + 314 + return src.val; 309 315 } 310 316 311 317 struct pebs_record_core {