diff options
| -rw-r--r-- | tools/perf/builtin-stat.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/Build | 1 | ||||
| -rw-r--r-- | tools/perf/util/counts.c | 52 | ||||
| -rw-r--r-- | tools/perf/util/counts.h | 37 | ||||
| -rw-r--r-- | tools/perf/util/evsel.h | 2 | ||||
| -rw-r--r-- | tools/perf/util/python-ext-sources | 2 | ||||
| -rw-r--r-- | tools/perf/util/stat.c | 49 | ||||
| -rw-r--r-- | tools/perf/util/stat.h | 30 |
8 files changed, 93 insertions, 81 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a054ddc0b2a0..7aa039bd379a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | #include "util/cpumap.h" | 58 | #include "util/cpumap.h" |
| 59 | #include "util/thread.h" | 59 | #include "util/thread.h" |
| 60 | #include "util/thread_map.h" | 60 | #include "util/thread_map.h" |
| 61 | #include "util/counts.h" | ||
| 61 | 62 | ||
| 62 | #include <stdlib.h> | 63 | #include <stdlib.h> |
| 63 | #include <sys/prctl.h> | 64 | #include <sys/prctl.h> |
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 2ee81d74cf45..1ce0adc8b3cb 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
| @@ -68,6 +68,7 @@ libperf-y += target.o | |||
| 68 | libperf-y += rblist.o | 68 | libperf-y += rblist.o |
| 69 | libperf-y += intlist.o | 69 | libperf-y += intlist.o |
| 70 | libperf-y += vdso.o | 70 | libperf-y += vdso.o |
| 71 | libperf-y += counts.o | ||
| 71 | libperf-y += stat.o | 72 | libperf-y += stat.o |
| 72 | libperf-y += stat-shadow.o | 73 | libperf-y += stat-shadow.o |
| 73 | libperf-y += record.o | 74 | libperf-y += record.o |
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c new file mode 100644 index 000000000000..e3fde313deb2 --- /dev/null +++ b/tools/perf/util/counts.c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | #include <stdlib.h> | ||
| 2 | #include "evsel.h" | ||
| 3 | #include "counts.h" | ||
| 4 | |||
| 5 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) | ||
| 6 | { | ||
| 7 | struct perf_counts *counts = zalloc(sizeof(*counts)); | ||
| 8 | |||
| 9 | if (counts) { | ||
| 10 | struct xyarray *values; | ||
| 11 | |||
| 12 | values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values)); | ||
| 13 | if (!values) { | ||
| 14 | free(counts); | ||
| 15 | return NULL; | ||
| 16 | } | ||
| 17 | |||
| 18 | counts->values = values; | ||
| 19 | } | ||
| 20 | |||
| 21 | return counts; | ||
| 22 | } | ||
| 23 | |||
| 24 | void perf_counts__delete(struct perf_counts *counts) | ||
| 25 | { | ||
| 26 | if (counts) { | ||
| 27 | xyarray__delete(counts->values); | ||
| 28 | free(counts); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | static void perf_counts__reset(struct perf_counts *counts) | ||
| 33 | { | ||
| 34 | xyarray__reset(counts->values); | ||
| 35 | } | ||
| 36 | |||
| 37 | void perf_evsel__reset_counts(struct perf_evsel *evsel) | ||
| 38 | { | ||
| 39 | perf_counts__reset(evsel->counts); | ||
| 40 | } | ||
| 41 | |||
| 42 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads) | ||
| 43 | { | ||
| 44 | evsel->counts = perf_counts__new(ncpus, nthreads); | ||
| 45 | return evsel->counts != NULL ? 0 : -ENOMEM; | ||
| 46 | } | ||
| 47 | |||
| 48 | void perf_evsel__free_counts(struct perf_evsel *evsel) | ||
| 49 | { | ||
| 50 | perf_counts__delete(evsel->counts); | ||
| 51 | evsel->counts = NULL; | ||
| 52 | } | ||
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h new file mode 100644 index 000000000000..34d8baaf558a --- /dev/null +++ b/tools/perf/util/counts.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | #ifndef __PERF_COUNTS_H | ||
| 2 | #define __PERF_COUNTS_H | ||
| 3 | |||
| 4 | #include "xyarray.h" | ||
| 5 | |||
| 6 | struct perf_counts_values { | ||
| 7 | union { | ||
| 8 | struct { | ||
| 9 | u64 val; | ||
| 10 | u64 ena; | ||
| 11 | u64 run; | ||
| 12 | }; | ||
| 13 | u64 values[3]; | ||
| 14 | }; | ||
| 15 | }; | ||
| 16 | |||
| 17 | struct perf_counts { | ||
| 18 | s8 scaled; | ||
| 19 | struct perf_counts_values aggr; | ||
| 20 | struct xyarray *values; | ||
| 21 | }; | ||
| 22 | |||
| 23 | |||
| 24 | static inline struct perf_counts_values* | ||
| 25 | perf_counts(struct perf_counts *counts, int cpu, int thread) | ||
| 26 | { | ||
| 27 | return xyarray__entry(counts->values, cpu, thread); | ||
| 28 | } | ||
| 29 | |||
| 30 | struct perf_counts *perf_counts__new(int ncpus, int nthreads); | ||
| 31 | void perf_counts__delete(struct perf_counts *counts); | ||
| 32 | |||
| 33 | void perf_evsel__reset_counts(struct perf_evsel *evsel); | ||
| 34 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads); | ||
| 35 | void perf_evsel__free_counts(struct perf_evsel *evsel); | ||
| 36 | |||
| 37 | #endif /* __PERF_COUNTS_H */ | ||
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 6a129081f3ad..b948f69d2558 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "xyarray.h" | 9 | #include "xyarray.h" |
| 10 | #include "symbol.h" | 10 | #include "symbol.h" |
| 11 | #include "cpumap.h" | 11 | #include "cpumap.h" |
| 12 | #include "stat.h" | 12 | #include "counts.h" |
| 13 | 13 | ||
| 14 | struct perf_evsel; | 14 | struct perf_evsel; |
| 15 | 15 | ||
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index 0766d98c5da5..51be28b1bca2 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
| @@ -16,7 +16,7 @@ util/util.c | |||
| 16 | util/xyarray.c | 16 | util/xyarray.c |
| 17 | util/cgroup.c | 17 | util/cgroup.c |
| 18 | util/rblist.c | 18 | util/rblist.c |
| 19 | util/stat.c | 19 | util/counts.c |
| 20 | util/strlist.c | 20 | util/strlist.c |
| 21 | util/trace-event.c | 21 | util/trace-event.c |
| 22 | ../lib/rbtree.c | 22 | ../lib/rbtree.c |
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index c5c709cdc3ce..415c359de465 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
| @@ -97,55 +97,6 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel) | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) | ||
| 101 | { | ||
| 102 | struct perf_counts *counts = zalloc(sizeof(*counts)); | ||
| 103 | |||
| 104 | if (counts) { | ||
| 105 | struct xyarray *values; | ||
| 106 | |||
| 107 | values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values)); | ||
| 108 | if (!values) { | ||
| 109 | free(counts); | ||
| 110 | return NULL; | ||
| 111 | } | ||
| 112 | |||
| 113 | counts->values = values; | ||
| 114 | } | ||
| 115 | |||
| 116 | return counts; | ||
| 117 | } | ||
| 118 | |||
| 119 | void perf_counts__delete(struct perf_counts *counts) | ||
| 120 | { | ||
| 121 | if (counts) { | ||
| 122 | xyarray__delete(counts->values); | ||
| 123 | free(counts); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | static void perf_counts__reset(struct perf_counts *counts) | ||
| 128 | { | ||
| 129 | xyarray__reset(counts->values); | ||
| 130 | } | ||
| 131 | |||
| 132 | void perf_evsel__reset_counts(struct perf_evsel *evsel) | ||
| 133 | { | ||
| 134 | perf_counts__reset(evsel->counts); | ||
| 135 | } | ||
| 136 | |||
| 137 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads) | ||
| 138 | { | ||
| 139 | evsel->counts = perf_counts__new(ncpus, nthreads); | ||
| 140 | return evsel->counts != NULL ? 0 : -ENOMEM; | ||
| 141 | } | ||
| 142 | |||
| 143 | void perf_evsel__free_counts(struct perf_evsel *evsel) | ||
| 144 | { | ||
| 145 | perf_counts__delete(evsel->counts); | ||
| 146 | evsel->counts = NULL; | ||
| 147 | } | ||
| 148 | |||
| 149 | void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) | 100 | void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) |
| 150 | { | 101 | { |
| 151 | int i; | 102 | int i; |
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 0b897b083682..62448c8175d3 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
| @@ -33,23 +33,6 @@ enum aggr_mode { | |||
| 33 | AGGR_THREAD, | 33 | AGGR_THREAD, |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | struct perf_counts_values { | ||
| 37 | union { | ||
| 38 | struct { | ||
| 39 | u64 val; | ||
| 40 | u64 ena; | ||
| 41 | u64 run; | ||
| 42 | }; | ||
| 43 | u64 values[3]; | ||
| 44 | }; | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct perf_counts { | ||
| 48 | s8 scaled; | ||
| 49 | struct perf_counts_values aggr; | ||
| 50 | struct xyarray *values; | ||
| 51 | }; | ||
| 52 | |||
| 53 | struct perf_stat_config { | 36 | struct perf_stat_config { |
| 54 | enum aggr_mode aggr_mode; | 37 | enum aggr_mode aggr_mode; |
| 55 | bool scale; | 38 | bool scale; |
| @@ -57,12 +40,6 @@ struct perf_stat_config { | |||
| 57 | unsigned int interval; | 40 | unsigned int interval; |
| 58 | }; | 41 | }; |
| 59 | 42 | ||
| 60 | static inline struct perf_counts_values* | ||
| 61 | perf_counts(struct perf_counts *counts, int cpu, int thread) | ||
| 62 | { | ||
| 63 | return xyarray__entry(counts->values, cpu, thread); | ||
| 64 | } | ||
| 65 | |||
| 66 | void update_stats(struct stats *stats, u64 val); | 43 | void update_stats(struct stats *stats, u64 val); |
| 67 | double avg_stats(struct stats *stats); | 44 | double avg_stats(struct stats *stats); |
| 68 | double stddev_stats(struct stats *stats); | 45 | double stddev_stats(struct stats *stats); |
| @@ -96,13 +73,6 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, | |||
| 96 | void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel, | 73 | void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel, |
| 97 | double avg, int cpu, enum aggr_mode aggr); | 74 | double avg, int cpu, enum aggr_mode aggr); |
| 98 | 75 | ||
| 99 | struct perf_counts *perf_counts__new(int ncpus, int nthreads); | ||
| 100 | void perf_counts__delete(struct perf_counts *counts); | ||
| 101 | |||
| 102 | void perf_evsel__reset_counts(struct perf_evsel *evsel); | ||
| 103 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads); | ||
| 104 | void perf_evsel__free_counts(struct perf_evsel *evsel); | ||
| 105 | |||
| 106 | void perf_evsel__reset_stat_priv(struct perf_evsel *evsel); | 76 | void perf_evsel__reset_stat_priv(struct perf_evsel *evsel); |
| 107 | int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel); | 77 | int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel); |
| 108 | void perf_evsel__free_stat_priv(struct perf_evsel *evsel); | 78 | void perf_evsel__free_stat_priv(struct perf_evsel *evsel); |
