From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Jin Yao <yao.jin@linux.intel.com>
Cc: jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com,
alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org,
ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com
Subject: Re: [PATCH v5 1/4] perf util: Move block_pair_cmp to block-info
Date: Fri, 31 Jan 2020 09:32:23 +0100 [thread overview]
Message-ID: <20200131083223.GF3841@kernel.org> (raw)
In-Reply-To: <20200128125556.25498-2-yao.jin@linux.intel.com>
Em Tue, Jan 28, 2020 at 08:55:53PM +0800, Jin Yao escreveu:
> block_pair_cmp() is a function which is used to compare
> two blocks. Moving it from builtin-diff.c to block-info.c
> to let it can be used by other builtins.
>
> v4/v5:
> ------
> No change.
>
> v3:
> ---
> Separate it from original patch for good tracking.
>
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
> tools/perf/builtin-diff.c | 17 -----------------
> tools/perf/util/block-info.c | 17 +++++++++++++++++
> tools/perf/util/block-info.h | 2 ++
> 3 files changed, 19 insertions(+), 17 deletions(-)
>
> diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
> index f8b6ae557d8b..5ff1e21082cb 100644
> --- a/tools/perf/builtin-diff.c
> +++ b/tools/perf/builtin-diff.c
> @@ -572,23 +572,6 @@ static void init_block_hist(struct block_hist *bh)
> bh->valid = true;
> }
>
> -static int block_pair_cmp(struct hist_entry *a, struct hist_entry *b)
> -{
> - struct block_info *bi_a = a->block_info;
> - struct block_info *bi_b = b->block_info;
> - int cmp;
> -
> - if (!bi_a->sym || !bi_b->sym)
> - return -1;
> -
> - cmp = strcmp(bi_a->sym->name, bi_b->sym->name);
> -
> - if ((!cmp) && (bi_a->start == bi_b->start) && (bi_a->end == bi_b->end))
> - return 0;
> -
> - return -1;
> -}
> -
> static struct hist_entry *get_block_pair(struct hist_entry *he,
> struct hists *hists_pair)
> {
> diff --git a/tools/perf/util/block-info.c b/tools/perf/util/block-info.c
> index c4b030bf6ec2..f0f38bdd496a 100644
> --- a/tools/perf/util/block-info.c
> +++ b/tools/perf/util/block-info.c
> @@ -475,3 +475,20 @@ float block_info__total_cycles_percent(struct hist_entry *he)
>
> return 0.0;
> }
> +
> +int block_pair_cmp(struct hist_entry *a, struct hist_entry *b)
First thing that came to mind was that hist_entry comparision functions
had been changed to return int64_t recently, when I went to look at it I
found this:
tools/perf/util/block-info.c
int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
struct hist_entry *left, struct hist_entry *right)
{
struct block_info *bi_l = left->block_info;
struct block_info *bi_r = right->block_info;
int cmp;
.
.
.
Which look a bit more complete, can you check if that can be used
instead or explain why my quick analysis of this is b0rken?
Perhaps we can have a __block_info__cmp() that doesn't receive the
perf_hpp_fmt (that isn't even used above) so that the previous use of
block_pair_cmp() can be replaced with __block_info__cmp() instead?
Thanks,
- Arnaldo
> +{
> + struct block_info *bi_a = a->block_info;
> + struct block_info *bi_b = b->block_info;
> + int cmp;
> +
> + if (!bi_a->sym || !bi_b->sym)
> + return -1;
> +
> + cmp = strcmp(bi_a->sym->name, bi_b->sym->name);
> +
> + if ((!cmp) && (bi_a->start == bi_b->start) && (bi_a->end == bi_b->end))
> + return 0;
> +
> + return -1;
> +}
> diff --git a/tools/perf/util/block-info.h b/tools/perf/util/block-info.h
> index bef0d75e9819..4fa91eeae92e 100644
> --- a/tools/perf/util/block-info.h
> +++ b/tools/perf/util/block-info.h
> @@ -76,4 +76,6 @@ int report__browse_block_hists(struct block_hist *bh, float min_percent,
>
> float block_info__total_cycles_percent(struct hist_entry *he);
>
> +int block_pair_cmp(struct hist_entry *a, struct hist_entry *b);
> +
> #endif /* __PERF_BLOCK_H */
> --
> 2.17.1
>
--
- Arnaldo
next prev parent reply other threads:[~2020-01-31 8:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 12:55 [PATCH v5 0/4] perf: Refactor the block info implementation Jin Yao
2020-01-28 12:55 ` [PATCH v5 1/4] perf util: Move block_pair_cmp to block-info Jin Yao
2020-01-31 8:32 ` Arnaldo Carvalho de Melo [this message]
2020-01-31 11:52 ` Jin, Yao
2020-01-28 12:55 ` [PATCH v5 2/4] perf util: Validate map/dso/sym before comparing blocks Jin Yao
2020-01-28 12:55 ` [PATCH v5 3/4] perf util: Flexible to set block info output formats Jin Yao
2020-01-28 12:55 ` [PATCH v5 4/4] perf util: Support color ops to print block percents in color Jin Yao
2020-01-30 16:02 ` [PATCH v5 0/4] perf: Refactor the block info implementation Jiri Olsa
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=20200131083223.GF3841@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=Linux-kernel@vger.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 \
--cc=yao.jin@linux.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