public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for David Ahern <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
	mingo@kernel.org, dsahern@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf trace: Fix summary percentage when processing files
Date: Wed, 11 Dec 2013 03:03:40 -0800	[thread overview]
Message-ID: <tip-3160565f0e005d2ec736ae25cf0a79988c0cbe71@git.kernel.org> (raw)
In-Reply-To: <1386211302-31303-4-git-send-email-dsahern@gmail.com>

Commit-ID:  3160565f0e005d2ec736ae25cf0a79988c0cbe71
Gitweb:     http://git.kernel.org/tip/3160565f0e005d2ec736ae25cf0a79988c0cbe71
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Wed, 4 Dec 2013 19:41:41 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 5 Dec 2013 10:09:58 -0300

perf trace: Fix summary percentage when processing files

Getting a divide by 0 when events are processed from a file:

   perf trace -i perf.data -s
   ...
   dnsmasq (1684), 10 events, inf%, 0.000 msec

The problem is that the event count is not incremented as events are
processed. With this patch:

   perf trace -i perf.data -s
   ...
   dnsmasq (1684), 10 events, 8.9%, 0.000 msec

Signed-off-by: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/1386211302-31303-4-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index a7aa771..56bbca5 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1770,8 +1770,10 @@ static int trace__process_sample(struct perf_tool *tool,
 	if (!trace->full_time && trace->base_time == 0)
 		trace->base_time = sample->time;
 
-	if (handler)
+	if (handler) {
+		++trace->nr_events;
 		handler(trace, evsel, sample);
+	}
 
 	return err;
 }

  reply	other threads:[~2013-12-11 11:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05  2:41 [PATCH 0/4] perf trace fixes David Ahern
2013-12-05  2:41 ` [PATCH 1/4] perf trace: Add support for syscalls vs raw_syscalls David Ahern
2013-12-11 11:03   ` [tip:perf/core] " tip-bot for David Ahern
2013-12-05  2:41 ` [PATCH 2/4] perf trace: Fix crash on RHEL6 David Ahern
2013-12-05 13:09   ` Arnaldo Carvalho de Melo
2013-12-05 14:27     ` David Ahern
2013-12-05 14:47       ` Arnaldo Carvalho de Melo
2013-12-05  2:41 ` [PATCH 3/4] perf trace: Fix summary percentage when processing files David Ahern
2013-12-11 11:03   ` tip-bot for David Ahern [this message]
2013-12-05  2:41 ` [PATCH 4/4] perf trace: Add option to specify machine type David Ahern
2013-12-05 13:50   ` Arnaldo Carvalho de Melo
2013-12-05 14:33     ` David Ahern
2013-12-05 14:49       ` Arnaldo Carvalho de Melo
2013-12-05  4:04 ` [PATCH 0/4] perf trace fixes David Ahern

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=tip-3160565f0e005d2ec736ae25cf0a79988c0cbe71@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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