Skip to content

Commit 920c557

Browse files
Ricky Ringleracmel
authored andcommitted
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 <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c73a56e commit 920c557

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

tools/perf/util/sort.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,8 +2474,7 @@ struct sort_entry sort_type_offset = {
24742474

24752475
/* --sort typecln */
24762476

2477-
/* TODO: use actual value in the system */
2478-
#define TYPE_CACHELINE_SIZE 64
2477+
#define DEFAULT_CACHELINE_SIZE 64
24792478

24802479
static int64_t
24812480
sort__typecln_sort(struct hist_entry *left, struct hist_entry *right)
@@ -2484,6 +2483,10 @@ sort__typecln_sort(struct hist_entry *left, struct hist_entry *right)
24842483
struct annotated_data_type *right_type = right->mem_type;
24852484
int64_t left_cln, right_cln;
24862485
int64_t ret;
2486+
int cln_size = cacheline_size();
2487+
2488+
if (cln_size == 0)
2489+
cln_size = DEFAULT_CACHELINE_SIZE;
24872490

24882491
if (!left_type) {
24892492
sort__type_init(left);
@@ -2499,18 +2502,22 @@ sort__typecln_sort(struct hist_entry *left, struct hist_entry *right)
24992502
if (ret)
25002503
return ret;
25012504

2502-
left_cln = left->mem_type_off / TYPE_CACHELINE_SIZE;
2503-
right_cln = right->mem_type_off / TYPE_CACHELINE_SIZE;
2505+
left_cln = left->mem_type_off / cln_size;
2506+
right_cln = right->mem_type_off / cln_size;
25042507
return left_cln - right_cln;
25052508
}
25062509

25072510
static int hist_entry__typecln_snprintf(struct hist_entry *he, char *bf,
25082511
size_t size, unsigned int width __maybe_unused)
25092512
{
25102513
struct annotated_data_type *he_type = he->mem_type;
2514+
int cln_size = cacheline_size();
2515+
2516+
if (cln_size == 0)
2517+
cln_size = DEFAULT_CACHELINE_SIZE;
25112518

25122519
return repsep_snprintf(bf, size, "%s: cache-line %d", he_type->self.type_name,
2513-
he->mem_type_off / TYPE_CACHELINE_SIZE);
2520+
he->mem_type_off / cln_size);
25142521
}
25152522

25162523
struct sort_entry sort_type_cacheline = {

0 commit comments

Comments
 (0)