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

Configure Feed

Select the types of activity you want to include in your feed.

perf sort: Replace static cacheline size with sysconf cacheline size

Testing:
- Built perf
- Executed perf mem record and report

Committer notes:

This addresses a TODO and improves the situation where record and
report/c2c are performed on the same machine or in machines with the
same cacheline size, but the proper way is to store the cacheline size
in the perf.data header at 'record' time and then use it at post
processing time.

Signed-off-by: Ricky Ringler <ricky.ringler@proton.me>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20260129004223.26799-1-ricky.ringler@proton.me
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ricky Ringler and committed by
Arnaldo Carvalho de Melo
920c5570 c73a56ed

+12 -5
+12 -5
tools/perf/util/sort.c
··· 2474 2474 2475 2475 /* --sort typecln */ 2476 2476 2477 - /* TODO: use actual value in the system */ 2478 - #define TYPE_CACHELINE_SIZE 64 2477 + #define DEFAULT_CACHELINE_SIZE 64 2479 2478 2480 2479 static int64_t 2481 2480 sort__typecln_sort(struct hist_entry *left, struct hist_entry *right) ··· 2483 2484 struct annotated_data_type *right_type = right->mem_type; 2484 2485 int64_t left_cln, right_cln; 2485 2486 int64_t ret; 2487 + int cln_size = cacheline_size(); 2488 + 2489 + if (cln_size == 0) 2490 + cln_size = DEFAULT_CACHELINE_SIZE; 2486 2491 2487 2492 if (!left_type) { 2488 2493 sort__type_init(left); ··· 2502 2499 if (ret) 2503 2500 return ret; 2504 2501 2505 - left_cln = left->mem_type_off / TYPE_CACHELINE_SIZE; 2506 - right_cln = right->mem_type_off / TYPE_CACHELINE_SIZE; 2502 + left_cln = left->mem_type_off / cln_size; 2503 + right_cln = right->mem_type_off / cln_size; 2507 2504 return left_cln - right_cln; 2508 2505 } 2509 2506 ··· 2511 2508 size_t size, unsigned int width __maybe_unused) 2512 2509 { 2513 2510 struct annotated_data_type *he_type = he->mem_type; 2511 + int cln_size = cacheline_size(); 2512 + 2513 + if (cln_size == 0) 2514 + cln_size = DEFAULT_CACHELINE_SIZE; 2514 2515 2515 2516 return repsep_snprintf(bf, size, "%s: cache-line %d", he_type->self.type_name, 2516 - he->mem_type_off / TYPE_CACHELINE_SIZE); 2517 + he->mem_type_off / cln_size); 2517 2518 } 2518 2519 2519 2520 struct sort_entry sort_type_cacheline = {