All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Joel Uckelman <joel@lightboxtechnologies.com>
Cc: linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH] perf tools: Fix cache event name generation
Date: Wed, 5 Sep 2012 19:51:33 +0200	[thread overview]
Message-ID: <20120905175133.GA18352@krava.brq.redhat.com> (raw)
In-Reply-To: <CAB04Epfe1n0R3HHi217YJzazh4ejWJk2-Ww1r55X0=q__WftwA@mail.gmail.com>

On Wed, Sep 05, 2012 at 05:21:10PM +0200, Joel Uckelman wrote:
> When I do this with perf 3.5.2,
> 
>   perf stat -x, -e
> L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores,L1-dcache-store-misses
> ls
> 
> I'm seeing this output from perf:
> 
>   697171,L1-dcache-loads
> 
>   28012,L1-dcache-misses
> 
>   455691,L1-dcache-stores
> 
>   11791,L1-dcache-misses
> 
> So, I'm getting two results labeled "L1-dcache-misses" (with different
> values!) and none labeled "L1-dcache-store-misses". It looks to me
> like one of the "L1-dcache-misses" is mislabeled.
> 
> There appears to be a general problem with all of the *-misses
> counters, as a similar thing happens with, e.g., LLC-load-misses and
> LLC-store-missses, and all of the others I've checked.
> 
> Is this a bug, or am I misunderstanding how perf-stat is supposed to work?

bug ;) please try attached patch

thanks,
jirka


---
If the event name is specified with all 3 components, the last one
overwrites the previous one during the name composing within the
parse_events_add_cache function.

Fixing this by properly adjusting the string index.

Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/util/parse-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index b246303..a031ee1 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -308,7 +308,7 @@ int parse_events_add_cache(struct list_head **list, int *idx,
 	for (i = 0; (i < 2) && (op_result[i]); i++) {
 		char *str = op_result[i];
 
-		snprintf(name + n, MAX_NAME_LEN - n, "-%s\n", str);
+		n += snprintf(name + n, MAX_NAME_LEN - n, "-%s", str);
 
 		if (cache_op == -1) {
 			cache_op = parse_aliases(str, perf_evsel__hw_cache_op,
-- 
1.7.11.4

      reply	other threads:[~2012-09-05 17:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 15:21 duplicate cache misses counter labels with perf-stat Joel Uckelman
2012-09-05 17:51 ` Jiri Olsa [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=20120905175133.GA18352@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=joel@lightboxtechnologies.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.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 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.