]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
perf sort: Replace static cacheline size with sysconf cacheline size
authorRicky Ringler <ricky.ringler@proton.me>
Thu, 29 Jan 2026 00:42:27 +0000 (00:42 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 6 Feb 2026 21:51:15 +0000 (18:51 -0300)
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>
tools/perf/util/sort.c

index 01a9d73ae348feaafebe6e780df34ae15c9aacaf..42d5cd7ef4e23960de30bb2a060156f863f8fcb6 100644 (file)
@@ -2474,8 +2474,7 @@ struct sort_entry sort_type_offset = {
 
 /* --sort typecln */
 
-/* TODO: use actual value in the system */
-#define TYPE_CACHELINE_SIZE  64
+#define DEFAULT_CACHELINE_SIZE 64
 
 static int64_t
 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)
        struct annotated_data_type *right_type = right->mem_type;
        int64_t left_cln, right_cln;
        int64_t ret;
+       int cln_size = cacheline_size();
+
+       if (cln_size == 0)
+               cln_size = DEFAULT_CACHELINE_SIZE;
 
        if (!left_type) {
                sort__type_init(left);
@@ -2499,8 +2502,8 @@ sort__typecln_sort(struct hist_entry *left, struct hist_entry *right)
        if (ret)
                return ret;
 
-       left_cln = left->mem_type_off / TYPE_CACHELINE_SIZE;
-       right_cln = right->mem_type_off / TYPE_CACHELINE_SIZE;
+       left_cln = left->mem_type_off / cln_size;
+       right_cln = right->mem_type_off / cln_size;
        return left_cln - right_cln;
 }
 
@@ -2508,9 +2511,13 @@ static int hist_entry__typecln_snprintf(struct hist_entry *he, char *bf,
                                     size_t size, unsigned int width __maybe_unused)
 {
        struct annotated_data_type *he_type = he->mem_type;
+       int cln_size = cacheline_size();
+
+       if (cln_size == 0)
+               cln_size = DEFAULT_CACHELINE_SIZE;
 
        return repsep_snprintf(bf, size, "%s: cache-line %d", he_type->self.type_name,
-                              he->mem_type_off / TYPE_CACHELINE_SIZE);
+                              he->mem_type_off / cln_size);
 }
 
 struct sort_entry sort_type_cacheline = {