From: Jin Yao <yao.jin@linux.intel.com>
To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com
Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com,
Jin Yao <yao.jin@linux.intel.com>
Subject: [PATCH v6 1/4] perf util: Fix wrong block address comparison in block_info__cmp
Date: Sun, 2 Feb 2020 22:16:52 +0800 [thread overview]
Message-ID: <20200202141655.32053-2-yao.jin@linux.intel.com> (raw)
In-Reply-To: <20200202141655.32053-1-yao.jin@linux.intel.com>
Commit 6041441870ab ("perf block: Cleanup and refactor block info
functions") introduces a function 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")
v6:
---
New in this patch set.
Signed-off-by: Jin Yao <yao.jin@linux.intel.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 c4b030bf6ec2..4ed5bce945ad 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,
--
2.17.1
next prev parent reply other threads:[~2020-02-02 14:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-02 14:16 [PATCH v6 0/4] perf: Refactor the block info implementation Jin Yao
2020-02-02 14:16 ` Jin Yao [this message]
2020-03-19 14:10 ` [tip: perf/core] perf block-info: Fix wrong block address comparison in block_info__cmp() tip-bot2 for Jin Yao
2020-02-02 14:16 ` [PATCH v6 2/4] perf util: Use __block_info__cmp to replace block_pair_cmp Jin Yao
2020-03-19 14:10 ` [tip: perf/core] perf diff: Use __block_info__cmp() to replace block_pair_cmp() tip-bot2 for Jin Yao
2020-02-02 14:16 ` [PATCH v6 3/4] perf util: Flexible to set block info output formats Jin Yao
2020-03-19 14:10 ` [tip: perf/core] perf block-info: Allow selecting which columns to report and its order tip-bot2 for Jin Yao
2020-02-02 14:16 ` [PATCH v6 4/4] perf util: Support color ops to print block percents in color Jin Yao
2020-03-09 13:54 ` Arnaldo Carvalho de Melo
2020-03-19 14:10 ` [tip: perf/core] perf block-info: " tip-bot2 for Jin Yao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200202141655.32053-2-yao.jin@linux.intel.com \
--to=yao.jin@linux.intel.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox