perf stat: Create the runtime_stat init/exit function
authorJin Yao <yao.jin@linux.intel.com>
Tue, 5 Dec 2017 14:03:03 +0000 (22:03 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Dec 2017 15:15:43 +0000 (12:15 -0300)
It mainly initializes and releases the rblist which is defined in struct
runtime_stat.

For the original rblist 'runtime_saved_values', it's still kept there
for keeping the patch bisectable.

The rblist 'runtime_saved_values' will be removed in later patch at
switching time.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512482591-4646-4-git-send-email-yao.jin@linux.intel.com
[ Rename 'stat' variables to 'st' to build on centos:{5,6} and others where it shadows a global declaration ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/stat-shadow.c
tools/perf/util/stat.h

index 528be3e8d13b1804575c97de3fbb3d07a6946c68..07cfbf613bdcf1eda98c482fff39361e83b4780f 100644 (file)
@@ -40,6 +40,7 @@ static struct stats runtime_aperf_stats[NUM_CTX][MAX_NR_CPUS];
 static struct rblist runtime_saved_values;
 static bool have_frontend_stalled;
 
+struct runtime_stat rt_stat;
 struct stats walltime_nsecs_stats;
 
 struct saved_value {
@@ -134,6 +135,21 @@ static struct saved_value *saved_value_lookup(struct perf_evsel *evsel,
        return NULL;
 }
 
+void runtime_stat__init(struct runtime_stat *st)
+{
+       struct rblist *rblist = &st->value_list;
+
+       rblist__init(rblist);
+       rblist->node_cmp = saved_value_cmp;
+       rblist->node_new = saved_value_new;
+       rblist->node_delete = saved_value_delete;
+}
+
+void runtime_stat__exit(struct runtime_stat *st)
+{
+       rblist__exit(&st->value_list);
+}
+
 void perf_stat__init_shadow_stats(void)
 {
        have_frontend_stalled = pmu_have_event("cpu", "stalled-cycles-frontend");
@@ -141,6 +157,7 @@ void perf_stat__init_shadow_stats(void)
        runtime_saved_values.node_cmp = saved_value_cmp;
        runtime_saved_values.node_new = saved_value_new;
        runtime_saved_values.node_delete = saved_value_delete;
+       runtime_stat__init(&rt_stat);
 }
 
 static int evsel_context(struct perf_evsel *evsel)
index c685c41f1fb9f1003802561f45c573afcd7489e8..f20240037377ed705bf887d6f89ffba5c62d7978 100644 (file)
@@ -117,12 +117,15 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel,
 
 void perf_stat_evsel_id_init(struct perf_evsel *evsel);
 
+extern struct runtime_stat rt_stat;
 extern struct stats walltime_nsecs_stats;
 
 typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit,
                               const char *fmt, double val);
 typedef void (*new_line_t )(void *ctx);
 
+void runtime_stat__init(struct runtime_stat *st);
+void runtime_stat__exit(struct runtime_stat *st);
 void perf_stat__init_shadow_stats(void);
 void perf_stat__reset_shadow_stats(void);
 void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,