[PATCH 13/25] perf stat: Move perf_evsel__(alloc|free|reset)_stat_priv into evsel object
From: Jiri Olsa
Date: Wed Jun 10 2015 - 14:14:08 EST
Moving perf_evsel__(alloc|free|reset)_stat_priv into evsel object,
so it could be used outside stat object in following patches.
Link: http://lkml.kernel.org/n/tip-ti0tocuk8fuw0zb7puyuw4e7@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/builtin-stat.c | 25 -------------------------
tools/perf/util/evsel.c | 26 ++++++++++++++++++++++++++
tools/perf/util/evsel.h | 5 +++++
3 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8359f6dad441..d6f23c3436ae 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -141,31 +141,6 @@ static inline void diff_timespec(struct timespec *r, struct timespec *a,
}
}
-static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
-{
- int i;
- struct perf_stat *ps = evsel->priv;
-
- for (i = 0; i < 3; i++)
- init_stats(&ps->res_stats[i]);
-
- perf_stat_evsel_id_init(evsel);
-}
-
-static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
-{
- evsel->priv = zalloc(sizeof(struct perf_stat));
- if (evsel->priv == NULL)
- return -ENOMEM;
- perf_evsel__reset_stat_priv(evsel);
- return 0;
-}
-
-static void perf_evsel__free_stat_priv(struct perf_evsel *evsel)
-{
- zfree(&evsel->priv);
-}
-
static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel,
int ncpus, int nthreads)
{
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a5409d39392e..7375dcc634da 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -26,6 +26,7 @@
#include "perf_regs.h"
#include "debug.h"
#include "trace-event.h"
+#include "stat.h"
static struct {
bool sample_id_all;
@@ -851,6 +852,31 @@ int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads)
return 0;
}
+void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
+{
+ int i;
+ struct perf_stat *ps = evsel->priv;
+
+ for (i = 0; i < 3; i++)
+ init_stats(&ps->res_stats[i]);
+
+ perf_stat_evsel_id_init(evsel);
+}
+
+int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
+{
+ evsel->priv = zalloc(sizeof(struct perf_stat));
+ if (evsel->priv == NULL)
+ return -ENOMEM;
+ perf_evsel__reset_stat_priv(evsel);
+ return 0;
+}
+
+void perf_evsel__free_stat_priv(struct perf_evsel *evsel)
+{
+ zfree(&evsel->priv);
+}
+
struct perf_counts *perf_counts__alloc(int ncpus, int nthreads)
{
struct perf_counts *counts = zalloc(sizeof(*counts));
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 0d495bd161c3..051175098f0b 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -192,6 +192,11 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size);
int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
+
+void perf_evsel__reset_stat_priv(struct perf_evsel *evsel);
+int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel);
+void perf_evsel__free_stat_priv(struct perf_evsel *evsel);
+
void perf_evsel__reset_counts(struct perf_evsel *evsel);
void perf_evsel__free_counts(struct perf_evsel *evsel);
void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/