Skip to content

Commit 51ba539

Browse files
Leo Yanacmel
authored andcommitted
perf arm-spe: Don't set data source if it's not a memory operation
Except for memory load and store operations, ARM SPE records also can support other operation types, bug when set the data source field the current code assumes a record is a either load operation or store operation, this leads to wrongly synthesize memory samples. This patch strictly checks the record operation type, it only sets data source only for the operation types ARM_SPE_LD and ARM_SPE_ST, otherwise, returns zero for data source. Therefore, we can synthesize memory samples only when data source is a non-zero value, the function arm_spe__is_memory_event() is useless and removed. Fixes: e55ed34 ("perf arm-spe: Synthesize memory event") Reviewed-by: Ali Saidi <[email protected]> Reviewed-by: German Gomez <[email protected]> Signed-off-by: Leo Yan <[email protected]> Tested-by: Ali Saidi <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: [email protected] Cc: Andrew Kilroy <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Leo Yan <[email protected]> Cc: Li Huafei <[email protected]> Cc: [email protected] Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nick Forrington <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent e5287e6 commit 51ba539

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

tools/perf/util/arm-spe.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,26 +387,16 @@ static int arm_spe__synth_instruction_sample(struct arm_spe_queue *speq,
387387
return arm_spe_deliver_synth_event(spe, speq, event, &sample);
388388
}
389389

390-
#define SPE_MEM_TYPE (ARM_SPE_L1D_ACCESS | ARM_SPE_L1D_MISS | \
391-
ARM_SPE_LLC_ACCESS | ARM_SPE_LLC_MISS | \
392-
ARM_SPE_REMOTE_ACCESS)
393-
394-
static bool arm_spe__is_memory_event(enum arm_spe_sample_type type)
395-
{
396-
if (type & SPE_MEM_TYPE)
397-
return true;
398-
399-
return false;
400-
}
401-
402390
static u64 arm_spe__synth_data_source(const struct arm_spe_record *record)
403391
{
404392
union perf_mem_data_src data_src = { 0 };
405393

406394
if (record->op == ARM_SPE_LD)
407395
data_src.mem_op = PERF_MEM_OP_LOAD;
408-
else
396+
else if (record->op == ARM_SPE_ST)
409397
data_src.mem_op = PERF_MEM_OP_STORE;
398+
else
399+
return 0;
410400

411401
if (record->type & (ARM_SPE_LLC_ACCESS | ARM_SPE_LLC_MISS)) {
412402
data_src.mem_lvl = PERF_MEM_LVL_L3;
@@ -510,7 +500,11 @@ static int arm_spe_sample(struct arm_spe_queue *speq)
510500
return err;
511501
}
512502

513-
if (spe->sample_memory && arm_spe__is_memory_event(record->type)) {
503+
/*
504+
* When data_src is zero it means the record is not a memory operation,
505+
* skip to synthesize memory sample for this case.
506+
*/
507+
if (spe->sample_memory && data_src) {
514508
err = arm_spe__synth_mem_sample(speq, spe->memory_id, data_src);
515509
if (err)
516510
return err;

0 commit comments

Comments
 (0)