linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
To: David Laight <David.Laight@ACULAB.COM>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"acme@kernel.org" <acme@kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "ananth@in.ibm.com" <ananth@in.ibm.com>,
	"naveen.n.rao@linux.vnet.ibm.com"
	<naveen.n.rao@linux.vnet.ibm.com>,
	"dja@axtens.net" <dja@axtens.net>
Subject: Re: [PATCH 3/4] perf annotate: add powerpc support
Date: Wed, 29 Jun 2016 12:17:29 +0530	[thread overview]
Message-ID: <57736F01.1010308@linux.vnet.ibm.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D5F4E67FA@AcuExch.aculab.com>

Thanks David.

On Tuesday 28 June 2016 09:37 PM, David Laight wrote:
> From: Ravi Bangoria
>> Sent: 28 June 2016 12:37
>>
>> Powerpc has long list of branch instructions and hardcoding them in table
>> appears to be error-prone. So, add new function to find instruction
>> instead of creating table.
>>
>> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
>> ---
>>   tools/perf/util/annotate.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 64 insertions(+)
>>
>> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
>> index 36a5825..96c6610 100644
>> --- a/tools/perf/util/annotate.c
>> +++ b/tools/perf/util/annotate.c
>> @@ -476,6 +476,68 @@ static int ins__cmp(const void *a, const void *b)
>>   	return strcmp(ia->name, ib->name);
>>   }
>>
>> +static struct ins *ins__find_powerpc(const char *name)
> It would be better if the function name include 'branch'.
>
>> +{
>> +	int i;
>> +	struct ins *ins;
>> +
>> +	ins = zalloc(sizeof(struct ins));
>> +	if (!ins)
>> +		return NULL;
>> +
>> +	ins->name = strdup(name);
>> +	if (!ins->name)
>> +		return NULL;
> 	You leak 'ins' here.
>
>> +
>> +	if (name[0] == 'b') {
>> +		/* branch instructions */
>> +		ins->ops = &jump_ops;
>> +
>> +		/*
>> +		 * - Few start with 'b', but aren't branch instructions.
>> +		 * - Let's also ignore instructions involving 'ctr' and
>> +		 *   'tar' since target branch addresses for those can't
>> +		 *   be determined statically.
>> +		 */
>> +		if (!strncmp(name, "bcd", 3)   ||
>> +		    !strncmp(name, "brinc", 5) ||
>> +		    !strncmp(name, "bper", 4)  ||
>> +		    strstr(name, "ctr")        ||
>> +		    strstr(name, "tar"))
>> +			return NULL;
> 	More importantly you leak 'ins' and 'ins->name' here.
> 	And on other paths below.

Yes. Fair points.

I can create linked list that maintain allocated instructions and
lookup it every time before allocating memory. But for this,
I need to free memory at the end and it's becoming complicated.

I can go back to normal approach of creating table for powerpc.
This is simplest. But only problem is powerpc has around 400 branch
instructions(which includes call and ret as well). And list them all is
bit error-prone.

Suggestions?

- Ravi

> ...
>
> 	David
>

  reply	other threads:[~2016-06-29  6:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28 11:36 [PATCH 0/4] perf annotate: Enable cross arch annotate Ravi Bangoria
2016-06-28 11:36 ` [PATCH 1/4] perf: Utility function to fetch arch from evsel Ravi Bangoria
2016-06-28 11:36 ` [PATCH 2/4] perf annotate: Enable cross arch annotate Ravi Bangoria
2016-06-28 11:36 ` [PATCH 3/4] perf annotate: add powerpc support Ravi Bangoria
2016-06-28 16:07   ` David Laight
2016-06-29  6:47     ` Ravi Bangoria [this message]
2016-06-28 11:36 ` [PATCH 4/4] perf annotate: Define macro for arch names Ravi Bangoria

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=57736F01.1010308@linux.vnet.ibm.com \
    --to=ravi.bangoria@linux.vnet.ibm.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=acme@kernel.org \
    --cc=ananth@in.ibm.com \
    --cc=dja@axtens.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=naveen.n.rao@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).