[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <158462704993.28353.6246503222087533009.tip-bot2@tip-bot2>
Date: Thu, 19 Mar 2020 14:10:49 -0000
From: "tip-bot2 for Jin Yao" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Jin Yao <yao.jin@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>, Jin Yao <yao.jin@...el.com>,
Jiri Olsa <jolsa@...nel.org>,
Kan Liang <kan.liang@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
x86 <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: [tip: perf/core] perf block-info: Fix wrong block address comparison
in block_info__cmp()
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 3e152aa984ff4f639f7d2daf1ad10d408c0a3332
Gitweb: https://git.kernel.org/tip/3e152aa984ff4f639f7d2daf1ad10d408c0a3332
Author: Jin Yao <yao.jin@...ux.intel.com>
AuthorDate: Sun, 02 Feb 2020 22:16:52 +08:00
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitterDate: Mon, 09 Mar 2020 21:43:25 -03:00
perf block-info: Fix wrong block address comparison in block_info__cmp()
Commit 6041441870ab ("perf block: Cleanup and refactor block info
functions") introduces block_info__cmp(), which compares two blocks.
But the issues are:
1. It should return the strcmp cmp value only if it's not 0.
2. When symbol names are matched, we need to compare the addresses
of blocks further. But it wrongly uses the symbol addresses for
comparison.
3. If the syms are both NULL, we can't consider these two blocks are
matched.
This patch fixes above 3 issues.
Fixes: 6041441870ab ("perf block: Cleanup and refactor block info functions")
Signed-off-by: Jin Yao <yao.jin@...ux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Jin Yao <yao.jin@...el.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Kan Liang <kan.liang@...ux.intel.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lore.kernel.org/lkml/20200202141655.32053-2-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/block-info.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/tools/perf/util/block-info.c b/tools/perf/util/block-info.c
index fbbb6d6..5b42146 100644
--- a/tools/perf/util/block-info.c
+++ b/tools/perf/util/block-info.c
@@ -74,30 +74,21 @@ int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
if (!bi_l->sym || !bi_r->sym) {
if (!bi_l->sym && !bi_r->sym)
- return 0;
+ return -1;
else if (!bi_l->sym)
return -1;
else
return 1;
}
- if (bi_l->sym == bi_r->sym) {
- if (bi_l->start == bi_r->start) {
- if (bi_l->end == bi_r->end)
- return 0;
- else
- return (int64_t)(bi_r->end - bi_l->end);
- } else
- return (int64_t)(bi_r->start - bi_l->start);
- } else {
- cmp = strcmp(bi_l->sym->name, bi_r->sym->name);
+ cmp = strcmp(bi_l->sym->name, bi_r->sym->name);
+ if (cmp)
return cmp;
- }
- if (bi_l->sym->start != bi_r->sym->start)
- return (int64_t)(bi_r->sym->start - bi_l->sym->start);
+ if (bi_l->start != bi_r->start)
+ return (int64_t)(bi_r->start - bi_l->start);
- return (int64_t)(bi_r->sym->end - bi_l->sym->end);
+ return (int64_t)(bi_r->end - bi_l->end);
}
static void init_block_info(struct block_info *bi, struct symbol *sym,
Powered by blists - more mailing lists