[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1398156591-11001-5-git-send-email-namhyung@kernel.org>
Date: Tue, 22 Apr 2014 17:49:46 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...nel.org>,
Paul Mackerras <paulus@...ba.org>,
Namhyung Kim <namhyung.kim@....com>,
Namhyung Kim <namhyung@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <andi@...stfloor.org>
Subject: [PATCH 4/9] perf tools: Introduce hists__inc_dump_events()
Now event stats are accounted at the hists__output_resort(), but if
dump_trace is enabled (via -D option of perf report/annotate), the
perf will not go be there and output will miss the sample events
count. The hists__inc_dump_events() will take care of it.
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/builtin-annotate.c | 1 +
tools/perf/builtin-report.c | 3 +++
tools/perf/util/hist.c | 13 +++++++++++++
tools/perf/util/hist.h | 1 +
4 files changed, 18 insertions(+)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 469bd5fcb824..be89afbacd39 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -68,6 +68,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
if (he == NULL)
return -ENOMEM;
+ hists__inc_dump_events(&evsel->hists);
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 5691f55ddd4d..04258e131da4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -124,6 +124,7 @@ static int report__add_mem_hist_entry(struct report *rep, struct addr_location *
}
rep->nr_samples++;
+ hists__inc_dump_events(&evsel->hists);
if (he->stat.nr_events == 1) {
/* count new entries only */
rep->nr_entries++;
@@ -181,6 +182,7 @@ static int report__add_branch_hist_entry(struct report *rep, struct addr_locatio
}
rep->nr_samples++;
+ hists__inc_dump_events(&evsel->hists);
if (he->stat.nr_events == 1) {
/* count new entries only */
rep->nr_entries++;
@@ -218,6 +220,7 @@ static int report__add_hist_entry(struct report *rep, struct perf_evsel *evsel,
err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
rep->nr_samples++;
+ hists__inc_dump_events(&evsel->hists);
if (he->stat.nr_events == 1) {
/* count new entries only */
rep->nr_entries++;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index f955ae5a41c5..883340d7d43e 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -333,6 +333,19 @@ void hists__inc_nr_events(struct hists *hists, u32 type)
__events_stats__add(&hists->stats, type, 1);
}
+void hists__inc_dump_events(struct hists *hists)
+{
+ if (!dump_trace)
+ return;
+
+ /*
+ * If dump_trace is enabled, perf will exit before accounting
+ * sample events during hists__output_resort(). Thus it needs to
+ * be done separately.
+ */
+ __events_stats__add(&hists->stats, PERF_RECORD_SAMPLE, 1);
+}
+
static void hists__add_nr_events(struct hists *hists, u32 type, u32 val)
{
__events_stats__add(&hists->stats, type, val);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 5a0343eb22e2..185bd41be2ce 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -118,6 +118,7 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows);
u64 hists__total_period(struct hists *hists);
void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h);
void hists__inc_nr_events(struct hists *hists, u32 type);
+void hists__inc_dump_events(struct hists *hists);
void events_stats__inc(struct events_stats *stats, u32 type);
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
--
1.9.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists