linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf-tools: Don't assume there's no attr info if no sample ids is provided
Date: Tue, 30 Nov 2010 11:53:05 -0200	[thread overview]
Message-ID: <20101130135305.GA9217@ghostprotocols.net> (raw)
In-Reply-To: <m3mxor6nex.fsf@gmail.com>

Em Tue, Nov 30, 2010 at 12:50:14PM +0100, Franck Bui-Huu escreveu:
> From: Franck Bui-Huu <fbuihuu@gmail.com>
> 
> This primarily fixes perf-report, which didn't report the correct type
> of event if perf-record was called to record one event different from
> 'cycles':
> 
>   $ perf record -e instructions true
>     [ perf record: Woken up 1 times to write data ]
>     [ perf record: Captured and wrote 0.007 MB perf.data (~295 samples) ]
> 
>   $ perf report | head -n1
>     # Events: 7  cycles
> 
> Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
> ---
>  tools/perf/util/header.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)


Please CC lkml when submitting patches.

Thanks a lot, applied to my perf/urgent branch.

- Arnaldo
 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index d7e67b1..64a85ba 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -946,11 +946,16 @@ perf_header__find_attr(u64 id, struct perf_header *header)
>  
>  	/*
>  	 * We set id to -1 if the data file doesn't contain sample
> -	 * ids. Check for this and avoid walking through the entire
> -	 * list of ids which may be large.
> +	 * ids. This can happen when the data file contains one type
> +	 * of event and in that case, the header can still store the
> +	 * event attribute information. Check for this and avoid
> +	 * walking through the entire list of ids which may be large.
>  	 */
> -	if (id == -1ULL)
> +	if (id == -1ULL) {
> +		if (header->attrs > 0)
> +			return &header->attr[0]->attr;
>  		return NULL;
> +	}
>  
>  	for (i = 0; i < header->attrs; i++) {
>  		struct perf_header_attr *attr = header->attr[i];
> -- 
> 1.7.3.2
> --
> To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2010-11-30 13:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 11:50 [PATCH] perf-tools: Don't assume there's no attr info if no sample ids is provided Franck Bui-Huu
2010-11-30 13:53 ` Arnaldo Carvalho de Melo [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=20101130135305.GA9217@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=vagabon.xyz@gmail.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).