perf stat: Move loaded out of struct perf_counts_values
authorJiri Olsa <jolsa@kernel.org>
Sun, 21 Jul 2019 11:23:48 +0000 (13:23 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Jul 2019 21:34:42 +0000 (18:34 -0300)
Because we will make struct perf_counts_values public in following
patches and 'loaded' is implementation related.

No functional change is expected.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/util/counts.c
tools/perf/util/counts.h
tools/perf/util/evsel.c

index 352cf39d7c2feb569914bacde2e66b01b5d51e42..7b9c26f9cf3469d7039665f119aaf9572c7698da 100644 (file)
@@ -287,7 +287,7 @@ static int read_counter(struct perf_evsel *counter, struct timespec *rs)
                         * The leader's group read loads data into its group members
                         * (via perf_evsel__read_counter) and sets threir count->loaded.
                         */
-                       if (!count->loaded &&
+                       if (!perf_counts__is_loaded(counter->counts, cpu, thread) &&
                            read_single_counter(counter, cpu, thread, rs)) {
                                counter->counts->scaled = -1;
                                perf_counts(counter->counts, cpu, thread)->ena = 0;
@@ -295,7 +295,7 @@ static int read_counter(struct perf_evsel *counter, struct timespec *rs)
                                return -1;
                        }
 
-                       count->loaded = false;
+                       perf_counts__set_loaded(counter->counts, cpu, thread, false);
 
                        if (STAT_RECORD) {
                                if (perf_evsel__write_stat_event(counter, cpu, thread, count)) {
index 88be9c4365e0f0b8a57c9d4e5955f483efb3e5c1..01ee81df3fe58e463ac2c4e68c8fb2ffbe468a54 100644 (file)
@@ -19,6 +19,15 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads)
                }
 
                counts->values = values;
+
+               values = xyarray__new(ncpus, nthreads, sizeof(bool));
+               if (!values) {
+                       xyarray__delete(counts->values);
+                       free(counts);
+                       return NULL;
+               }
+
+               counts->loaded = values;
        }
 
        return counts;
@@ -27,6 +36,7 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads)
 void perf_counts__delete(struct perf_counts *counts)
 {
        if (counts) {
+               xyarray__delete(counts->loaded);
                xyarray__delete(counts->values);
                free(counts);
        }
@@ -34,6 +44,7 @@ void perf_counts__delete(struct perf_counts *counts)
 
 static void perf_counts__reset(struct perf_counts *counts)
 {
+       xyarray__reset(counts->loaded);
        xyarray__reset(counts->values);
 }
 
index 0d1050ccc586bb7970b2e8bc5dd84985c83694d5..460b56ce3252f38e16f56027d8e26ffca4b22ec5 100644 (file)
@@ -13,13 +13,13 @@ struct perf_counts_values {
                };
                u64 values[3];
        };
-       bool    loaded;
 };
 
 struct perf_counts {
        s8                        scaled;
        struct perf_counts_values aggr;
        struct xyarray            *values;
+       struct xyarray            *loaded;
 };
 
 
@@ -29,6 +29,18 @@ perf_counts(struct perf_counts *counts, int cpu, int thread)
        return xyarray__entry(counts->values, cpu, thread);
 }
 
+static inline bool
+perf_counts__is_loaded(struct perf_counts *counts, int cpu, int thread)
+{
+       return *((bool *) xyarray__entry(counts->loaded, cpu, thread));
+}
+
+static inline void
+perf_counts__set_loaded(struct perf_counts *counts, int cpu, int thread, bool loaded)
+{
+       *((bool *) xyarray__entry(counts->loaded, cpu, thread)) = loaded;
+}
+
 struct perf_counts *perf_counts__new(int ncpus, int nthreads);
 void perf_counts__delete(struct perf_counts *counts);
 
index 7d1757a2ec46449a04ca020a46f19a075a80cbcb..d23b9574f7934492c48ea3a15d94d9af0703a315 100644 (file)
@@ -1439,7 +1439,8 @@ perf_evsel__set_count(struct perf_evsel *counter, int cpu, int thread,
        count->val    = val;
        count->ena    = ena;
        count->run    = run;
-       count->loaded = true;
+
+       perf_counts__set_loaded(counter->counts, cpu, thread, true);
 }
 
 static int