From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: namhyung@kernel.org, acme@redhat.com, mingo@kernel.org,
dsahern@gmail.com, adrian.hunter@intel.com,
a.p.zijlstra@chello.nl, tglx@linutronix.de, ak@linux.intel.com,
eranian@google.com, hpa@zytor.com, jolsa@kernel.org,
linux-kernel@vger.kernel.org
Subject: [tip:perf/urgent] perf stat: Move perf_evlist__(alloc|free|reset) _stats into stat object
Date: Mon, 29 Jun 2015 21:55:32 -0700 [thread overview]
Message-ID: <tip-24e34f68e21a47a582b3cc2eccdb835b80b1830a@git.kernel.org> (raw)
In-Reply-To: <1435310967-14570-12-git-send-email-jolsa@kernel.org>
Commit-ID: 24e34f68e21a47a582b3cc2eccdb835b80b1830a
Gitweb: http://git.kernel.org/tip/24e34f68e21a47a582b3cc2eccdb835b80b1830a
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 26 Jun 2015 11:29:16 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 26 Jun 2015 11:44:37 -0300
perf stat: Move perf_evlist__(alloc|free|reset)_stats into stat object
Moving perf_evlist__(alloc|free|reset)_stats into stat object,
so it could be used in following patches.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1435310967-14570-12-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-stat.c | 42 ------------------------------------------
tools/perf/util/evlist.h | 1 -
tools/perf/util/stat.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/stat.h | 6 ++++++
4 files changed, 50 insertions(+), 43 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0ccba5c..3e385f9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -141,48 +141,6 @@ static inline void diff_timespec(struct timespec *r, struct timespec *a,
}
}
-static void perf_evlist__free_stats(struct perf_evlist *evlist)
-{
- struct perf_evsel *evsel;
-
- evlist__for_each(evlist, evsel) {
- perf_evsel__free_stat_priv(evsel);
- perf_evsel__free_counts(evsel);
- perf_evsel__free_prev_raw_counts(evsel);
- }
-}
-
-static int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw)
-{
- struct perf_evsel *evsel;
- int nthreads = thread_map__nr(evsel_list->threads);
-
- evlist__for_each(evlist, evsel) {
- int ncpus = perf_evsel__nr_cpus(evsel);
-
- if (perf_evsel__alloc_stat_priv(evsel) < 0 ||
- perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
- (alloc_raw && perf_evsel__alloc_prev_raw_counts(evsel, ncpus, nthreads) < 0))
- goto out_free;
- }
-
- return 0;
-
-out_free:
- perf_evlist__free_stats(evlist);
- return -1;
-}
-
-static void perf_evlist__reset_stats(struct perf_evlist *evlist)
-{
- struct perf_evsel *evsel;
-
- evlist__for_each(evlist, evsel) {
- perf_evsel__reset_stat_priv(evsel);
- perf_evsel__reset_counts(evsel);
- }
-}
-
static void perf_stat__reset_stats(void)
{
perf_evlist__reset_stats(evsel_list);
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index a8489b9..037633c 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -289,5 +289,4 @@ void perf_evlist__to_front(struct perf_evlist *evlist,
void perf_evlist__set_tracking_event(struct perf_evlist *evlist,
struct perf_evsel *tracking_evsel);
-
#endif /* __PERF_EVLIST_H */
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 6221c38..818cb02 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -1,6 +1,8 @@
#include <math.h>
#include "stat.h"
+#include "evlist.h"
#include "evsel.h"
+#include "thread_map.h"
void update_stats(struct stats *stats, u64 val)
{
@@ -186,3 +188,45 @@ void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel)
perf_counts__delete(evsel->prev_raw_counts);
evsel->prev_raw_counts = NULL;
}
+
+int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw)
+{
+ struct perf_evsel *evsel;
+ int nthreads = thread_map__nr(evlist->threads);
+
+ evlist__for_each(evlist, evsel) {
+ int ncpus = perf_evsel__nr_cpus(evsel);
+
+ if (perf_evsel__alloc_stat_priv(evsel) < 0 ||
+ perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
+ (alloc_raw && perf_evsel__alloc_prev_raw_counts(evsel, ncpus, nthreads) < 0))
+ goto out_free;
+ }
+
+ return 0;
+
+out_free:
+ perf_evlist__free_stats(evlist);
+ return -1;
+}
+
+void perf_evlist__free_stats(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel;
+
+ evlist__for_each(evlist, evsel) {
+ perf_evsel__free_stat_priv(evsel);
+ perf_evsel__free_counts(evsel);
+ perf_evsel__free_prev_raw_counts(evsel);
+ }
+}
+
+void perf_evlist__reset_stats(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel;
+
+ evlist__for_each(evlist, evsel) {
+ perf_evsel__reset_stat_priv(evsel);
+ perf_evsel__reset_counts(evsel);
+ }
+}
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 454b268..5f62db2 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -70,6 +70,8 @@ static inline void init_stats(struct stats *stats)
}
struct perf_evsel;
+struct perf_evlist;
+
bool __perf_evsel_stat__is(struct perf_evsel *evsel,
enum perf_stat_evsel_id id);
@@ -100,4 +102,8 @@ void perf_evsel__free_stat_priv(struct perf_evsel *evsel);
int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel,
int ncpus, int nthreads);
void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel);
+
+int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
+void perf_evlist__free_stats(struct perf_evlist *evlist);
+void perf_evlist__reset_stats(struct perf_evlist *evlist);
#endif
next prev parent reply other threads:[~2015-06-30 4:55 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 9:29 [PATCHv5 00/22] perf stat: Introduce --per-thread option Jiri Olsa
2015-06-26 9:29 ` [PATCH 01/22] perf thread_map: Introduce thread_map__reset function Jiri Olsa
2015-06-26 14:06 ` Arnaldo Carvalho de Melo
2015-06-30 4:52 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 02/22] perf tools: Add comm string into struct thread_map Jiri Olsa
2015-06-30 4:52 ` [tip:perf/urgent] perf thrad_map: Add comm string into array tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 03/22] perf tests: Add thread_map object tests Jiri Olsa
2015-06-30 4:53 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 04/22] perf stat: Introduce perf_counts function Jiri Olsa
2015-06-30 4:53 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 05/22] perf stat: Use xyarray for cpu evsel counts Jiri Olsa
2015-06-30 4:53 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 06/22] perf stat: Make stats work over the thread dimension Jiri Olsa
2015-06-30 4:54 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 07/22] perf stat: Rename struct perf_counts::cpu member to values Jiri Olsa
2015-06-30 4:54 ` [tip:perf/urgent] perf stat: Rename struct perf_counts:: cpu " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 08/22] perf stat: Introduce perf_evlist__reset_stats Jiri Olsa
2015-06-30 4:54 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 09/22] perf stat: Move perf_evsel__(alloc|free|reset)_stat_priv into stat object Jiri Olsa
2015-06-30 4:54 ` [tip:perf/urgent] perf stat: Move perf_evsel__(alloc|free|reset) _stat_priv " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 10/22] perf stat: Move perf_evsel__(alloc|free)_prev_raw_counts " Jiri Olsa
2015-06-30 4:55 ` [tip:perf/urgent] perf stat: Move perf_evsel__(alloc|free) _prev_raw_counts " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 11/22] perf stat: Move perf_evlist__(alloc|free|reset)_stats " Jiri Olsa
2015-06-30 4:55 ` tip-bot for Jiri Olsa [this message]
2015-06-26 9:29 ` [PATCH 12/22] perf stat: Introduce perf_evsel__alloc_stats function Jiri Olsa
2015-06-30 4:55 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 13/22] perf stat: Introduce perf_evsel__read function Jiri Olsa
2015-06-30 4:56 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 14/22] perf stat: Introduce read_counters function Jiri Olsa
2015-06-30 4:56 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 15/22] perf stat: Separate counters reading and processing Jiri Olsa
2015-06-30 4:56 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 16/22] perf stat: Move zero_per_pkg into counter process code Jiri Olsa
2015-06-30 4:57 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 17/22] perf stat: Move perf_stat initialization " Jiri Olsa
2015-06-30 4:57 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 18/22] perf stat: Remove perf_evsel__read_cb function Jiri Olsa
2015-06-30 4:57 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 19/22] perf stat: Rename print_interval to process_interval Jiri Olsa
2015-06-30 4:57 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 20/22] perf stat: Using init_stats instead of memset Jiri Olsa
2015-06-30 4:58 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 21/22] perf stat: Introduce print_counters function Jiri Olsa
2015-06-30 4:58 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 9:29 ` [PATCH 22/22] perf stat: Introduce --per-thread option Jiri Olsa
2015-06-30 4:58 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-06-26 15:06 ` [PATCHv5 00/22] " Arnaldo Carvalho de Melo
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-24e34f68e21a47a582b3cc2eccdb835b80b1830a@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--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