Skip to content

Commit a8a9f6d

Browse files
Jin Yaoacmel
authored andcommitted
perf diff: Use __block_info__cmp() to replace block_pair_cmp()
'perf diff' uses block_pair_cmp() to compare two blocks. But block_info__cmp() has the similar functionality and it's a bit more complete. This patch removes block_pair_cmp() and uses __block_info__cmp() instead. __block_info__cmp() is wrapped by block_info__cmp() and it doesn't receives a perf_hpp_fmt parameter. Signed-off-by: Jin Yao <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jin Yao <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 3e152aa commit a8a9f6d

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

tools/perf/builtin-diff.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -572,37 +572,20 @@ static void init_block_hist(struct block_hist *bh)
572572
bh->valid = true;
573573
}
574574

575-
static int block_pair_cmp(struct hist_entry *a, struct hist_entry *b)
576-
{
577-
struct block_info *bi_a = a->block_info;
578-
struct block_info *bi_b = b->block_info;
579-
int cmp;
580-
581-
if (!bi_a->sym || !bi_b->sym)
582-
return -1;
583-
584-
cmp = strcmp(bi_a->sym->name, bi_b->sym->name);
585-
586-
if ((!cmp) && (bi_a->start == bi_b->start) && (bi_a->end == bi_b->end))
587-
return 0;
588-
589-
return -1;
590-
}
591-
592575
static struct hist_entry *get_block_pair(struct hist_entry *he,
593576
struct hists *hists_pair)
594577
{
595578
struct rb_root_cached *root = hists_pair->entries_in;
596579
struct rb_node *next = rb_first_cached(root);
597-
int cmp;
580+
int64_t cmp;
598581

599582
while (next != NULL) {
600583
struct hist_entry *he_pair = rb_entry(next, struct hist_entry,
601584
rb_node_in);
602585

603586
next = rb_next(&he_pair->rb_node_in);
604587

605-
cmp = block_pair_cmp(he_pair, he);
588+
cmp = __block_info__cmp(he_pair, he);
606589
if (!cmp)
607590
return he_pair;
608591
}

tools/perf/util/block-info.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ struct block_info *block_info__new(void)
6565
return bi;
6666
}
6767

68-
int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
69-
struct hist_entry *left, struct hist_entry *right)
68+
int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right)
7069
{
7170
struct block_info *bi_l = left->block_info;
7271
struct block_info *bi_r = right->block_info;
@@ -91,6 +90,12 @@ int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
9190
return (int64_t)(bi_r->end - bi_l->end);
9291
}
9392

93+
int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
94+
struct hist_entry *left, struct hist_entry *right)
95+
{
96+
return __block_info__cmp(left, right);
97+
}
98+
9499
static void init_block_info(struct block_info *bi, struct symbol *sym,
95100
struct cyc_hist *ch, int offset,
96101
u64 total_cycles)

tools/perf/util/block-info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ static inline void __block_info__zput(struct block_info **bi)
6161

6262
#define block_info__zput(bi) __block_info__zput(&bi)
6363

64+
int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right);
65+
6466
int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
6567
struct hist_entry *left, struct hist_entry *right);
6668

0 commit comments

Comments
 (0)