aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/sort.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 8b0bb1f4494a..68a4fd2f505e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -161,6 +161,11 @@ struct sort_entry sort_dso = {
161 161
162/* --sort symbol */ 162/* --sort symbol */
163 163
164static int64_t _sort__addr_cmp(u64 left_ip, u64 right_ip)
165{
166 return (int64_t)(right_ip - left_ip);
167}
168
164static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r) 169static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
165{ 170{
166 u64 ip_l, ip_r; 171 u64 ip_l, ip_r;
@@ -183,7 +188,7 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
183 int64_t ret; 188 int64_t ret;
184 189
185 if (!left->ms.sym && !right->ms.sym) 190 if (!left->ms.sym && !right->ms.sym)
186 return right->level - left->level; 191 return _sort__addr_cmp(left->ip, right->ip);
187 192
188 /* 193 /*
189 * comparing symbol address alone is not enough since it's a 194 * comparing symbol address alone is not enough since it's a
@@ -372,7 +377,7 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
372 struct addr_map_symbol *from_r = &right->branch_info->from; 377 struct addr_map_symbol *from_r = &right->branch_info->from;
373 378
374 if (!from_l->sym && !from_r->sym) 379 if (!from_l->sym && !from_r->sym)
375 return right->level - left->level; 380 return _sort__addr_cmp(from_l->addr, from_r->addr);
376 381
377 return _sort__sym_cmp(from_l->sym, from_r->sym); 382 return _sort__sym_cmp(from_l->sym, from_r->sym);
378} 383}
@@ -384,7 +389,7 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
384 struct addr_map_symbol *to_r = &right->branch_info->to; 389 struct addr_map_symbol *to_r = &right->branch_info->to;
385 390
386 if (!to_l->sym && !to_r->sym) 391 if (!to_l->sym && !to_r->sym)
387 return right->level - left->level; 392 return _sort__addr_cmp(to_l->addr, to_r->addr);
388 393
389 return _sort__sym_cmp(to_l->sym, to_r->sym); 394 return _sort__sym_cmp(to_l->sym, to_r->sym);
390} 395}