From: tip-bot for Andi Kleen <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
ak@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org,
jolsa@redhat.com
Subject: [tip:perf/urgent] perf stat: Initialize statistics correctly
Date: Mon, 14 Apr 2014 07:54:17 -0700 [thread overview]
Message-ID: <tip-90f6bb6c98ffef42125d7be6d4612505f561fbce@git.kernel.org> (raw)
In-Reply-To: <1395768699-16060-1-git-send-email-andi@firstfloor.org>
Commit-ID: 90f6bb6c98ffef42125d7be6d4612505f561fbce
Gitweb: http://git.kernel.org/tip/90f6bb6c98ffef42125d7be6d4612505f561fbce
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Tue, 25 Mar 2014 10:31:38 -0700
Committer: Jiri Olsa <jolsa@redhat.com>
CommitDate: Mon, 14 Apr 2014 12:56:06 +0200
perf stat: Initialize statistics correctly
perf stat did initialize the stats structure used to compute
stddev etc. incorrectly. It merely zeroes it. But one member
(min) needs to be set to a non zero value. This causes min
to be not computed at all. Call init_stats() correctly.
It doesn't matter for stat currently because it doesn't use
min, but it's still better to do it correctly.
The other users of statistics are already correct.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1395768699-16060-1-git-send-email-andi@firstfloor.org
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/builtin-stat.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8b0e1c9..65a151e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -174,13 +174,20 @@ static inline int perf_evsel__nr_cpus(struct perf_evsel *evsel)
static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
{
- memset(evsel->priv, 0, sizeof(struct perf_stat));
+ int i;
+ struct perf_stat *ps = evsel->priv;
+
+ for (i = 0; i < 3; i++)
+ init_stats(&ps->res_stats[i]);
}
static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
{
evsel->priv = zalloc(sizeof(struct perf_stat));
- return evsel->priv == NULL ? -ENOMEM : 0;
+ if (evsel == NULL)
+ return -ENOMEM;
+ perf_evsel__reset_stat_priv(evsel);
+ return 0;
}
static void perf_evsel__free_stat_priv(struct perf_evsel *evsel)
prev parent reply other threads:[~2014-04-14 14:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-25 17:31 [PATCH 1/2] perf, tools, stat: Initialize statistics correctly Andi Kleen
2014-03-25 17:31 ` [PATCH 2/2] perf, tools: Support spark lines in perf stat Andi Kleen
2014-04-13 18:08 ` Jiri Olsa
2014-04-14 8:50 ` Jiri Olsa
2014-04-14 17:09 ` Andi Kleen
2014-04-09 1:49 ` [PATCH 1/2] perf, tools, stat: Initialize statistics correctly Namhyung Kim
2014-04-09 13:42 ` Jiri Olsa
2014-04-14 14:54 ` tip-bot for Andi Kleen [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=tip-90f6bb6c98ffef42125d7be6d4612505f561fbce@git.kernel.org \
--to=tipbot@zytor.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@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