linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	dsahern@gmail.com, artagnon@gmail.com
Subject: Re: [PATCH 2/8] perf tools: Make the print_pmu_events funtion to return unsigned int.
Date: Thu, 09 Jan 2014 17:23:43 -0500	[thread overview]
Message-ID: <52CF216F.3020100@cn.fujitsu.com> (raw)
In-Reply-To: <20140108151038.GA2626@infradead.org>

On 01/08/2014 10:10 AM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Dec 30, 2013 at 10:26:37AM -0500, Dongsheng Yang escreveu:
>> Sometimes we need to know how many events have been printed in print_pmu_events.
> "Sometimes" is too vague, of course it should be needed, otherwise why
> bother with the patch? It would be better if you provided an example of
> _where_ it will be used, like when printing that newline.
>
> Anyway, reading the other patches,

Arnaldo, I squashed this commit into [1/8] in my next version.
They are doing one thing in fact. Please help to review it.

I hope everything looks okey to you.

Thanx

- Yang
> - Arnaldo
>   
>> This patch make this function to return the number of events we have printed.
>>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>>   tools/perf/util/pmu.c | 12 +++++++-----
>>   tools/perf/util/pmu.h |  2 +-
>>   2 files changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>> index 0934d64..331dc2c 100644
>> --- a/tools/perf/util/pmu.c
>> +++ b/tools/perf/util/pmu.c
>> @@ -711,12 +711,12 @@ static int cmp_string(const void *a, const void *b)
>>   	return strcmp(*as, *bs);
>>   }
>>   
>> -void print_pmu_events(const char *event_glob, bool name_only)
>> +unsigned int print_pmu_events(const char *event_glob, bool name_only)
>>   {
>>   	struct perf_pmu *pmu;
>>   	struct perf_pmu_alias *alias;
>>   	char buf[1024];
>> -	int printed = 0;
>> +	unsigned int count = 0;
>>   	int len, j;
>>   	char **aliases;
>>   
>> @@ -727,7 +727,7 @@ void print_pmu_events(const char *event_glob, bool name_only)
>>   			len++;
>>   	aliases = malloc(sizeof(char *) * len);
>>   	if (!aliases)
>> -		return;
>> +		return count;
>>   	pmu = NULL;
>>   	j = 0;
>>   	while ((pmu = perf_pmu__scan(pmu)) != NULL)
>> @@ -752,15 +752,17 @@ void print_pmu_events(const char *event_glob, bool name_only)
>>   	for (j = 0; j < len; j++) {
>>   		if (name_only) {
>>   			printf("%s ", aliases[j]);
>> +			count++;
>>   			continue;
>>   		}
>>   		printf("  %-50s [Kernel PMU event]\n", aliases[j]);
>>   		zfree(&aliases[j]);
>> -		printed++;
>> +		count++;
>>   	}
>> -	if (printed)
>> +	if (count)
>>   		printf("\n");
>>   	free(aliases);
>> +	return count;
>>   }
>>   
>>   bool pmu_have_event(const char *pname, const char *name)
>> diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
>> index 9183380..2987fe2 100644
>> --- a/tools/perf/util/pmu.h
>> +++ b/tools/perf/util/pmu.h
>> @@ -42,7 +42,7 @@ int perf_pmu__format_parse(char *dir, struct list_head *head);
>>   
>>   struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
>>   
>> -void print_pmu_events(const char *event_glob, bool name_only);
>> +unsigned int print_pmu_events(const char *event_glob, bool name_only);
>>   bool pmu_have_event(const char *pname, const char *name);
>>   
>>   int perf_pmu__test(void);
>> -- 
>> 1.8.2.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


  parent reply	other threads:[~2014-01-09  9:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30 15:26 [PATCH 0/8 V2] Enhancement for perf list Dongsheng Yang
2013-12-30 15:26 ` [PATCH 1/8] perf tools: Make the all print_xxx_event functions to return unsigned int Dongsheng Yang
2013-12-30 15:26 ` [PATCH 2/8] perf tools: Make the print_pmu_events funtion " Dongsheng Yang
2014-01-08 15:10   ` Arnaldo Carvalho de Melo
2014-01-09 14:58     ` Dongsheng Yang
2014-01-09 22:23     ` Dongsheng Yang [this message]
2013-12-30 15:26 ` [PATCH 3/8] perf tools: free aliases[j] in pmu.c if name_only is true Dongsheng Yang
2014-01-08 15:12   ` Arnaldo Carvalho de Melo
2014-01-09 14:53     ` Dongsheng Yang
2013-12-30 15:26 ` [PATCH 4/8] perf tools: Improve the message of perf list for unexpected input Dongsheng Yang
2014-01-08 15:16   ` Arnaldo Carvalho de Melo
2014-01-09 14:38     ` Dongsheng Yang
2013-12-30 15:26 ` [PATCH 5/8] perf tools: Add support of name_only for print_events_type() function Dongsheng Yang
2014-01-08 15:19   ` Arnaldo Carvalho de Melo
2014-01-09 14:37     ` Dongsheng Yang
2013-12-30 15:26 ` [PATCH 6/8] perf tools: Make --raw-dump work as a proper option for perf list Dongsheng Yang
2013-12-30  8:09   ` Ramkumar Ramachandra
2014-01-08 15:20   ` Arnaldo Carvalho de Melo
2014-01-08 21:44     ` David Ahern
2014-01-09 14:36       ` Dongsheng Yang
2014-01-10 15:30         ` David Ahern
2014-01-13 21:03           ` Dongsheng Yang
2013-12-30 15:26 ` [PATCH 7/8] perf tools: Fix bug when --raw-dump is not the first arguement " Dongsheng Yang
2013-12-30 15:26 ` [PATCH 8/8] perf tools: Enhancement for perf list with --raw-dump Dongsheng Yang

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=52CF216F.3020100@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=acme@redhat.com \
    --cc=artagnon@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /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).