All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Robert Richter <robert.richter@amd.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/8] perf tools: Rename some variables for better understanding
Date: Fri, 17 Aug 2012 12:34:46 -0300	[thread overview]
Message-ID: <20120817153446.GA7764@infradead.org> (raw)
In-Reply-To: <1345144224-27280-4-git-send-email-robert.richter@amd.com>

Em Thu, Aug 16, 2012 at 09:10:19PM +0200, Robert Richter escreveu:
> Trivial patch to improve understanding of code.
> 
> Varible attr is usually used for struct perf_event_attr. Using it in a
> different context is irritating. Thus, renaming it.

Right, this is historical stuff, originally it was a perf_event_attr, so
'attr', when I converted it to evsel I kept 'attr' to reduce the patch
size.

Anyway, applying, thanks,

- Arnaldo
 
> Signed-off-by: Robert Richter <robert.richter@amd.com>
> ---
>  tools/perf/util/header.c |   42 +++++++++++++++++++++---------------------
>  1 files changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 471b0c4..e2e5129 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -608,11 +608,11 @@ static int write_nrcpus(int fd, struct perf_header *h __used,
>  static int write_event_desc(int fd, struct perf_header *h __used,
>  			    struct perf_evlist *evlist)
>  {
> -	struct perf_evsel *attr;
> +	struct perf_evsel *evsel;
>  	u32 nre = 0, nri, sz;
>  	int ret;
>  
> -	list_for_each_entry(attr, &evlist->entries, node)
> +	list_for_each_entry(evsel, &evlist->entries, node)
>  		nre++;
>  
>  	/*
> @@ -625,14 +625,14 @@ static int write_event_desc(int fd, struct perf_header *h __used,
>  	/*
>  	 * size of perf_event_attr struct
>  	 */
> -	sz = (u32)sizeof(attr->attr);
> +	sz = (u32)sizeof(evsel->attr);
>  	ret = do_write(fd, &sz, sizeof(sz));
>  	if (ret < 0)
>  		return ret;
>  
> -	list_for_each_entry(attr, &evlist->entries, node) {
> +	list_for_each_entry(evsel, &evlist->entries, node) {
>  
> -		ret = do_write(fd, &attr->attr, sz);
> +		ret = do_write(fd, &evsel->attr, sz);
>  		if (ret < 0)
>  			return ret;
>  		/*
> @@ -642,7 +642,7 @@ static int write_event_desc(int fd, struct perf_header *h __used,
>  		 * copy into an nri to be independent of the
>  		 * type of ids,
>  		 */
> -		nri = attr->ids;
> +		nri = evsel->ids;
>  		ret = do_write(fd, &nri, sizeof(nri));
>  		if (ret < 0)
>  			return ret;
> @@ -650,13 +650,13 @@ static int write_event_desc(int fd, struct perf_header *h __used,
>  		/*
>  		 * write event string as passed on cmdline
>  		 */
> -		ret = do_write_string(fd, perf_evsel__name(attr));
> +		ret = do_write_string(fd, perf_evsel__name(evsel));
>  		if (ret < 0)
>  			return ret;
>  		/*
>  		 * write unique ids for this event
>  		 */
> -		ret = do_write(fd, attr->id, attr->ids * sizeof(u64));
> +		ret = do_write(fd, evsel->id, evsel->ids * sizeof(u64));
>  		if (ret < 0)
>  			return ret;
>  	}
> @@ -1683,7 +1683,7 @@ int perf_session__write_header(struct perf_session *session,
>  	struct perf_file_header f_header;
>  	struct perf_file_attr   f_attr;
>  	struct perf_header *header = &session->header;
> -	struct perf_evsel *attr, *pair = NULL;
> +	struct perf_evsel *evsel, *pair = NULL;
>  	int err;
>  
>  	lseek(fd, sizeof(f_header), SEEK_SET);
> @@ -1691,9 +1691,9 @@ int perf_session__write_header(struct perf_session *session,
>  	if (session->evlist != evlist)
>  		pair = perf_evlist__first(session->evlist);
>  
> -	list_for_each_entry(attr, &evlist->entries, node) {
> -		attr->id_offset = lseek(fd, 0, SEEK_CUR);
> -		err = do_write(fd, attr->id, attr->ids * sizeof(u64));
> +	list_for_each_entry(evsel, &evlist->entries, node) {
> +		evsel->id_offset = lseek(fd, 0, SEEK_CUR);
> +		err = do_write(fd, evsel->id, evsel->ids * sizeof(u64));
>  		if (err < 0) {
>  out_err_write:
>  			pr_debug("failed to write perf header\n");
> @@ -1703,19 +1703,19 @@ out_err_write:
>  			err = do_write(fd, pair->id, pair->ids * sizeof(u64));
>  			if (err < 0)
>  				goto out_err_write;
> -			attr->ids += pair->ids;
> +			evsel->ids += pair->ids;
>  			pair = perf_evsel__next(pair);
>  		}
>  	}
>  
>  	header->attr_offset = lseek(fd, 0, SEEK_CUR);
>  
> -	list_for_each_entry(attr, &evlist->entries, node) {
> +	list_for_each_entry(evsel, &evlist->entries, node) {
>  		f_attr = (struct perf_file_attr){
> -			.attr = attr->attr,
> +			.attr = evsel->attr,
>  			.ids  = {
> -				.offset = attr->id_offset,
> -				.size   = attr->ids * sizeof(u64),
> +				.offset = evsel->id_offset,
> +				.size   = evsel->ids * sizeof(u64),
>  			}
>  		};
>  		err = do_write(fd, &f_attr, sizeof(f_attr));
> @@ -2277,12 +2277,12 @@ int perf_event__synthesize_attrs(struct perf_tool *tool,
>  				   struct perf_session *session,
>  				   perf_event__handler_t process)
>  {
> -	struct perf_evsel *attr;
> +	struct perf_evsel *evsel;
>  	int err = 0;
>  
> -	list_for_each_entry(attr, &session->evlist->entries, node) {
> -		err = perf_event__synthesize_attr(tool, &attr->attr, attr->ids,
> -						  attr->id, process);
> +	list_for_each_entry(evsel, &session->evlist->entries, node) {
> +		err = perf_event__synthesize_attr(tool, &evsel->attr, evsel->ids,
> +						  evsel->id, process);
>  		if (err) {
>  			pr_debug("failed to create perf header attribute\n");
>  			return err;
> -- 
> 1.7.8.6
> 

  reply	other threads:[~2012-08-17 15:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 19:10 [PATCH 0/8] perf tools: Various updates Robert Richter
2012-08-16 19:10 ` [PATCH 1/8] perf tools: Fix type for evsel->ids and add size check for ids Robert Richter
2012-08-21 16:24   ` [tip:perf/core] perf tools: Fix type for evsel-> ids " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 2/8] perf tools: Report number of pmu type of unknown events Robert Richter
2012-08-21 16:25   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 3/8] perf tools: Rename some variables for better understanding Robert Richter
2012-08-17 15:34   ` Arnaldo Carvalho de Melo [this message]
2012-08-21 16:26   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 4/8] perf tools: Rename global variable 'events' in util/header.c Robert Richter
2012-08-21 16:27   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 5/8] perf tools: Catch event names from command line Robert Richter
2012-08-20 17:42   ` Jiri Olsa
2012-08-21 18:02     ` Robert Richter
2012-08-21 18:03     ` [PATCH 1/2] perf test: Update event names in test cases Robert Richter
2012-08-21 18:03       ` [PATCH 2/2] perf test: Do not abort tests on error Robert Richter
2012-08-27 16:53         ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-27 16:54   ` [tip:perf/core] perf tools: Catch event names from command line tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 6/8] perf tools: Refactor print_event_desc() Robert Richter
2012-08-27 16:55   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 7/8] perf report: Update event names from header description Robert Richter
2012-08-27 16:56   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 8/8] perf tools: Add pmu mappings to header information Robert Richter
2012-08-27 16:57   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-17 16:18 ` [PATCH 0/8] perf tools: Various updates Arnaldo Carvalho de Melo

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=20120817153446.GA7764@infradead.org \
    --to=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=robert.richter@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.