LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Jin, Yao" <yao.jin@linux.intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: acme@kernel.org, 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 v2 1/3] perf util: Move block_pair_cmp to block-info
Date: Tue, 7 Jan 2020 21:57:56 +0800	[thread overview]
Message-ID: <2e4be21f-cd40-7d7f-4894-b9245de723e9@linux.intel.com> (raw)
In-Reply-To: <20200107095733.GD290055@krava>



On 1/7/2020 5:57 PM, Jiri Olsa wrote:
> On Tue, Jan 07, 2020 at 03:45:23AM +0800, Jin Yao wrote:
>> 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 be used by other builtins.
>>
>> In block_pair_cmp, there is a minor change. It checks valid
>> for map, dso and sym first. If they are invalid, we will not
>> compare the address because the address might not make sense.
> 
> please separate the change as well, it's hard to track
> what you did when the whole function is moved
> 

Got it, thanks! I will separate this too.

>>
>>   v2:
>>   ---
>>   New patch created in v2
>>
>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>> ---
>>   tools/perf/builtin-diff.c    | 17 -----------------
>>   tools/perf/util/block-info.c | 23 +++++++++++++++++++++++
>>   tools/perf/util/block-info.h |  2 ++
>>   3 files changed, 25 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..18a445938681 100644
>> --- a/tools/perf/util/block-info.c
>> +++ b/tools/perf/util/block-info.c
>> @@ -475,3 +475,26 @@ float block_info__total_cycles_percent(struct hist_entry *he)
>>   
>>   	return 0.0;
>>   }
>> +
>> +int block_pair_cmp(struct hist_entry *pair, struct hist_entry *he)
>> +{
>> +	struct block_info *bi_p = pair->block_info;
>> +	struct block_info *bi_h = he->block_info;
>> +	struct map_symbol *ms_p = &pair->ms;
>> +	struct map_symbol *ms_h = &he->ms;
>> +	int cmp;
>> +
>> +	if (!ms_p->map || !ms_p->map->dso || !ms_p->sym ||
>> +	    !ms_h->map || !ms_h->map->dso || !ms_h->sym) {
>> +		return -1;
>> +	}
>> +
>> +	cmp = strcmp(ms_p->sym->name, ms_h->sym->name);
>> +	if (cmp)
>> +		return -1;
> 
> should this return cmp? also you don't mention this change in the changelog
> 

Yes, return cmp should be OK.

It's changed from "strcmp(bi_a->sym->name, bi_b->sym->name)" to 
"strcmp(ms_p->sym->name, ms_h->sym->name)" is because we don't need an 
additional checking for bi_a->sym and bi_b->sym.

If we use "strcmp(bi_a->sym->name, bi_b->sym->name)" here, I think we'd 
better check the sym first. I will mention that in changelog.

Thanks
Jin Yao

> thanks,
> jirka
> 

      reply	other threads:[~2020-01-07 13:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 19:45 Jin Yao
2020-01-06 19:45 ` [PATCH v2 2/3] perf util: Flexible to set block info output formats Jin Yao
2020-01-07 10:06   ` Jiri Olsa
2020-01-07 14:00     ` Jin, Yao
2020-01-06 19:45 ` [PATCH v2 3/3] perf util: Support color ops to print block percents in color Jin Yao
2020-01-07  9:57 ` [PATCH v2 1/3] perf util: Move block_pair_cmp to block-info Jiri Olsa
2020-01-07 13:57   ` Jin, Yao [this message]

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=2e4be21f-cd40-7d7f-4894-b9245de723e9@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=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yao.jin@intel.com \
    --subject='Re: [PATCH v2 1/3] perf util: Move block_pair_cmp to block-info' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).