aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/stat.c')
-rw-r--r--tools/perf/util/stat.c60
1 files changed, 18 insertions, 42 deletions
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 8f1ea27f976f..fcd54342c04c 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -4,6 +4,7 @@
4#include <math.h> 4#include <math.h>
5#include <string.h> 5#include <string.h>
6#include "counts.h" 6#include "counts.h"
7#include "cpumap.h"
7#include "debug.h" 8#include "debug.h"
8#include "header.h" 9#include "header.h"
9#include "stat.h" 10#include "stat.h"
@@ -161,6 +162,15 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel)
161 evsel->prev_raw_counts = NULL; 162 evsel->prev_raw_counts = NULL;
162} 163}
163 164
165static void perf_evsel__reset_prev_raw_counts(struct evsel *evsel)
166{
167 if (evsel->prev_raw_counts) {
168 evsel->prev_raw_counts->aggr.val = 0;
169 evsel->prev_raw_counts->aggr.ena = 0;
170 evsel->prev_raw_counts->aggr.run = 0;
171 }
172}
173
164static int perf_evsel__alloc_stats(struct evsel *evsel, bool alloc_raw) 174static int perf_evsel__alloc_stats(struct evsel *evsel, bool alloc_raw)
165{ 175{
166 int ncpus = perf_evsel__nr_cpus(evsel); 176 int ncpus = perf_evsel__nr_cpus(evsel);
@@ -211,6 +221,14 @@ void perf_evlist__reset_stats(struct evlist *evlist)
211 } 221 }
212} 222}
213 223
224void perf_evlist__reset_prev_raw_counts(struct evlist *evlist)
225{
226 struct evsel *evsel;
227
228 evlist__for_each_entry(evlist, evsel)
229 perf_evsel__reset_prev_raw_counts(evsel);
230}
231
214static void zero_per_pkg(struct evsel *counter) 232static void zero_per_pkg(struct evsel *counter)
215{ 233{
216 if (counter->per_pkg_mask) 234 if (counter->per_pkg_mask)
@@ -493,45 +511,3 @@ int create_perf_stat_counter(struct evsel *evsel,
493 511
494 return perf_evsel__open_per_thread(evsel, evsel->core.threads); 512 return perf_evsel__open_per_thread(evsel, evsel->core.threads);
495} 513}
496
497int perf_stat_synthesize_config(struct perf_stat_config *config,
498 struct perf_tool *tool,
499 struct evlist *evlist,
500 perf_event__handler_t process,
501 bool attrs)
502{
503 int err;
504
505 if (attrs) {
506 err = perf_event__synthesize_attrs(tool, evlist, process);
507 if (err < 0) {
508 pr_err("Couldn't synthesize attrs.\n");
509 return err;
510 }
511 }
512
513 err = perf_event__synthesize_extra_attr(tool, evlist, process,
514 attrs);
515
516 err = perf_event__synthesize_thread_map2(tool, evlist->core.threads,
517 process, NULL);
518 if (err < 0) {
519 pr_err("Couldn't synthesize thread map.\n");
520 return err;
521 }
522
523 err = perf_event__synthesize_cpu_map(tool, evlist->core.cpus,
524 process, NULL);
525 if (err < 0) {
526 pr_err("Couldn't synthesize thread map.\n");
527 return err;
528 }
529
530 err = perf_event__synthesize_stat_config(tool, config, process, NULL);
531 if (err < 0) {
532 pr_err("Couldn't synthesize config.\n");
533 return err;
534 }
535
536 return 0;
537}