Skip to content

Commit c1c8013

Browse files
anarazelacmel
authored andcommitted
perf c2c: Fix return type for histogram sorting comparision functions
Commit 722ddfd ("perf tools: Fix time sorting") changed - correctly so - hist_entry__sort to return int64. Unfortunately several of the builtin-c2c.c comparison routines only happened to work due the cast caused by the wrong return type. This causes meaningless ordering of both the cacheline list, and the cacheline details page. E.g a simple: perf c2c record -a sleep 3 perf c2c report will result in cacheline table like ================================================= Shared Data Cache Line Table ================================================= # # ------- Cacheline ---------- Total Tot - LLC Load Hitm - - Store Reference - - Load Dram - LLC Total - Core Load Hit - - LLC Load Hit - # Index Address Node PA cnt records Hitm Total Lcl Rmt Total L1Hit L1Miss Lcl Rmt Ld Miss Loads FB L1 L2 Llc Rmt # ..... .............. .... ...... ....... ...... ..... ..... ... .... ..... ...... ...... .... ...... ..... ..... ..... ... .... ....... 0 0x7f0d27ffba00 N/A 0 52 0.12% 13 6 7 12 12 0 0 7 14 40 4 16 0 0 0 1 0x7f0d27ff61c0 N/A 0 6353 14.04% 1475 801 674 779 779 0 0 718 1392 5574 1299 1967 0 115 0 2 0x7f0d26d3ec80 N/A 0 71 0.15% 16 4 12 13 13 0 0 12 24 58 1 20 0 9 0 3 0x7f0d26d3ec00 N/A 0 98 0.22% 23 17 6 19 19 0 0 6 12 79 0 40 0 10 0 i.e. with the list not being ordered by Total Hitm. Fixes: 722ddfd ("perf tools: Fix time sorting") Signed-off-by: Andres Freund <[email protected]> Tested-by: Michael Petlan <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] # v3.16+ Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 49e0b6f commit c1c8013

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/perf/builtin-c2c.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ tot_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
595595
{
596596
struct c2c_hist_entry *c2c_left;
597597
struct c2c_hist_entry *c2c_right;
598-
unsigned int tot_hitm_left;
599-
unsigned int tot_hitm_right;
598+
uint64_t tot_hitm_left;
599+
uint64_t tot_hitm_right;
600600

601601
c2c_left = container_of(left, struct c2c_hist_entry, he);
602602
c2c_right = container_of(right, struct c2c_hist_entry, he);
@@ -629,7 +629,8 @@ __f ## _cmp(struct perf_hpp_fmt *fmt __maybe_unused, \
629629
\
630630
c2c_left = container_of(left, struct c2c_hist_entry, he); \
631631
c2c_right = container_of(right, struct c2c_hist_entry, he); \
632-
return c2c_left->stats.__f - c2c_right->stats.__f; \
632+
return (uint64_t) c2c_left->stats.__f - \
633+
(uint64_t) c2c_right->stats.__f; \
633634
}
634635

635636
#define STAT_FN(__f) \
@@ -682,7 +683,8 @@ ld_llcmiss_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
682683
c2c_left = container_of(left, struct c2c_hist_entry, he);
683684
c2c_right = container_of(right, struct c2c_hist_entry, he);
684685

685-
return llc_miss(&c2c_left->stats) - llc_miss(&c2c_right->stats);
686+
return (uint64_t) llc_miss(&c2c_left->stats) -
687+
(uint64_t) llc_miss(&c2c_right->stats);
686688
}
687689

688690
static uint64_t total_records(struct c2c_stats *stats)

0 commit comments

Comments
 (0)