From: Jiri Olsa <jolsa@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
Jiri Olsa <jolsa@kernel.org>
Subject: [PATCH 01/27] perf tools: Introduce hists__inc_nr_samples()
Date: Sun, 1 Jun 2014 15:31:12 +0200 [thread overview]
Message-ID: <1401629498-8726-2-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1401629498-8726-1-git-send-email-jolsa@kernel.org>
From: Namhyung Kim <namhyung@kernel.org>
There're some duplicate code for counting number of samples. Add
hists__inc_nr_samples() and reuse it.
Suggested-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1401335910-16832-2-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-annotate.c | 2 +-
tools/perf/builtin-report.c | 4 +---
tools/perf/builtin-sched.c | 2 +-
tools/perf/builtin-top.c | 5 +----
tools/perf/tests/hists_filter.c | 4 +---
tools/perf/util/hist.c | 7 +++++++
tools/perf/util/hist.h | 1 +
7 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index d30d2c2..bf52461 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -70,7 +70,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return -ENOMEM;
ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
- hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
+ hists__inc_nr_samples(&evsel->hists, true);
return ret;
}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bc0eec1..4a3b84d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -92,9 +92,7 @@ static void report__inc_stats(struct report *rep, struct hist_entry *he)
* counted in perf_session_deliver_event(). The dump_trace
* requires this info is ready before going to the output tree.
*/
- hists__inc_nr_events(he->hists, PERF_RECORD_SAMPLE);
- if (!he->filtered)
- he->hists->stats.nr_non_filtered_samples++;
+ hists__inc_nr_samples(he->hists, he->filtered);
}
static int report__add_mem_hist_entry(struct report *rep, struct addr_location *al,
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index d717683..c38d06c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1428,7 +1428,7 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_
int err = 0;
evsel->hists.stats.total_period += sample->period;
- hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
+ hists__inc_nr_samples(&evsel->hists, true);
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5b389ce..5130926 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -252,10 +252,7 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
if (he == NULL)
return NULL;
- hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
- if (!he->filtered)
- evsel->hists.stats.nr_non_filtered_samples++;
-
+ hists__inc_nr_samples(&evsel->hists, he->filtered);
return he;
}
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index c5ba924..0a71ef4 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -85,9 +85,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
fake_samples[i].map = al.map;
fake_samples[i].sym = al.sym;
- hists__inc_nr_events(he->hists, PERF_RECORD_SAMPLE);
- if (!he->filtered)
- he->hists->stats.nr_non_filtered_samples++;
+ hists__inc_nr_samples(he->hists, he->filtered);
}
}
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b262b44..5943ba6 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -800,6 +800,13 @@ void hists__inc_nr_events(struct hists *hists, u32 type)
events_stats__inc(&hists->stats, type);
}
+void hists__inc_nr_samples(struct hists *hists, bool filtered)
+{
+ events_stats__inc(&hists->stats, PERF_RECORD_SAMPLE);
+ if (!filtered)
+ hists->stats.nr_non_filtered_samples++;
+}
+
static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
struct hist_entry *pair)
{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index a8418d1..03ae1db 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -119,6 +119,7 @@ u64 hists__total_period(struct hists *hists);
void hists__reset_stats(struct hists *hists);
void hists__inc_stats(struct hists *hists, struct hist_entry *h);
void hists__inc_nr_events(struct hists *hists, u32 type);
+void hists__inc_nr_samples(struct hists *hists, bool filtered);
void events_stats__inc(struct events_stats *stats, u32 type);
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
--
1.8.3.1
next prev parent reply other threads:[~2014-06-01 13:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-01 13:31 [GIT PULL 00/27] perf/core improvements and fixes Jiri Olsa
2014-06-01 13:31 ` Jiri Olsa [this message]
2014-06-01 13:31 ` [PATCH 02/27] perf tools: Introduce struct hist_entry_iter Jiri Olsa
2014-06-01 13:31 ` [PATCH 03/27] perf hists: Add support for accumulated stat of hist entry Jiri Olsa
2014-06-01 13:31 ` [PATCH 04/27] perf hists: Check if accumulated when adding a " Jiri Olsa
2014-06-01 13:31 ` [PATCH 05/27] perf hists: Accumulate hist entry stat based on the callchain Jiri Olsa
2014-06-01 13:31 ` [PATCH 06/27] perf tools: Update cpumode for each cumulative entry Jiri Olsa
2014-06-01 13:31 ` [PATCH 07/27] perf report: Cache cumulative callchains Jiri Olsa
2014-06-01 13:31 ` [PATCH 08/27] perf callchain: Add callchain_cursor_snapshot() Jiri Olsa
2014-06-01 13:31 ` [PATCH 09/27] perf tools: Save callchain info for each cumulative entry Jiri Olsa
2014-06-01 13:31 ` [PATCH 10/27] perf ui/hist: Add support to accumulated hist stat Jiri Olsa
2014-06-01 13:31 ` [PATCH 11/27] perf ui/browser: " Jiri Olsa
2014-06-01 13:31 ` [PATCH 12/27] perf ui/gtk: " Jiri Olsa
2014-06-01 13:31 ` [PATCH 13/27] perf tools: Apply percent-limit to cumulative percentage Jiri Olsa
2014-06-01 13:31 ` [PATCH 14/27] perf tools: Add more hpp helper functions Jiri Olsa
2014-06-01 13:31 ` [PATCH 15/27] perf report: Add --children option Jiri Olsa
2014-06-01 13:31 ` [PATCH 16/27] perf report: Add report.children config option Jiri Olsa
2014-06-01 13:31 ` [PATCH 17/27] perf tools: Do not auto-remove Children column if --fields given Jiri Olsa
2014-06-01 13:31 ` [PATCH 18/27] perf tools: Add callback function to hist_entry_iter Jiri Olsa
2014-06-01 13:31 ` [PATCH 19/27] perf top: Convert " Jiri Olsa
2014-06-01 13:31 ` [PATCH 20/27] perf top: Add --children option Jiri Olsa
2014-06-01 13:31 ` [PATCH 21/27] perf top: Add top.children config option Jiri Olsa
2014-06-01 13:31 ` [PATCH 22/27] perf tools: Enable --children option by default Jiri Olsa
2014-06-01 13:31 ` [PATCH 23/27] perf ui/stdio: Fix invalid percentage value of cumulated hist entries Jiri Olsa
2014-06-01 13:31 ` [PATCH 24/27] perf ui/gtk: Fix callchain display Jiri Olsa
2014-06-01 13:31 ` [PATCH 25/27] perf tools: Reset output/sort order to default Jiri Olsa
2014-06-01 13:31 ` [PATCH 26/27] perf tests: Define and use symbolic names for fake symbols Jiri Olsa
2014-06-01 13:31 ` [PATCH 27/27] perf tests: Add a test case for cumulating callchains Jiri Olsa
2014-06-03 18:23 ` [GIT PULL 00/27] perf/core improvements and fixes Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2014-05-29 3:58 [PATCHSET 00/27] perf tools: Add support to accumulate hist periods (v11) Namhyung Kim
2014-05-29 3:58 ` [PATCH 01/27] perf tools: Introduce hists__inc_nr_samples() Namhyung Kim
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=1401629498-8726-2-git-send-email-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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.