Commit df1d6856 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf stat: Move loaded out of struct perf_counts_values

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: default avatarJiri 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e4b00e93
...@@ -287,7 +287,7 @@ static int read_counter(struct perf_evsel *counter, struct timespec *rs) ...@@ -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 * The leader's group read loads data into its group members
* (via perf_evsel__read_counter) and sets threir count->loaded. * (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)) { read_single_counter(counter, cpu, thread, rs)) {
counter->counts->scaled = -1; counter->counts->scaled = -1;
perf_counts(counter->counts, cpu, thread)->ena = 0; perf_counts(counter->counts, cpu, thread)->ena = 0;
...@@ -295,7 +295,7 @@ static int read_counter(struct perf_evsel *counter, struct timespec *rs) ...@@ -295,7 +295,7 @@ static int read_counter(struct perf_evsel *counter, struct timespec *rs)
return -1; return -1;
} }
count->loaded = false; perf_counts__set_loaded(counter->counts, cpu, thread, false);
if (STAT_RECORD) { if (STAT_RECORD) {
if (perf_evsel__write_stat_event(counter, cpu, thread, count)) { if (perf_evsel__write_stat_event(counter, cpu, thread, count)) {
......
...@@ -19,6 +19,15 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads) ...@@ -19,6 +19,15 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads)
} }
counts->values = values; 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; return counts;
...@@ -27,6 +36,7 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads) ...@@ -27,6 +36,7 @@ struct perf_counts *perf_counts__new(int ncpus, int nthreads)
void perf_counts__delete(struct perf_counts *counts) void perf_counts__delete(struct perf_counts *counts)
{ {
if (counts) { if (counts) {
xyarray__delete(counts->loaded);
xyarray__delete(counts->values); xyarray__delete(counts->values);
free(counts); free(counts);
} }
...@@ -34,6 +44,7 @@ void perf_counts__delete(struct perf_counts *counts) ...@@ -34,6 +44,7 @@ void perf_counts__delete(struct perf_counts *counts)
static void perf_counts__reset(struct perf_counts *counts) static void perf_counts__reset(struct perf_counts *counts)
{ {
xyarray__reset(counts->loaded);
xyarray__reset(counts->values); xyarray__reset(counts->values);
} }
......
...@@ -13,13 +13,13 @@ struct perf_counts_values { ...@@ -13,13 +13,13 @@ struct perf_counts_values {
}; };
u64 values[3]; u64 values[3];
}; };
bool loaded;
}; };
struct perf_counts { struct perf_counts {
s8 scaled; s8 scaled;
struct perf_counts_values aggr; struct perf_counts_values aggr;
struct xyarray *values; struct xyarray *values;
struct xyarray *loaded;
}; };
...@@ -29,6 +29,18 @@ perf_counts(struct perf_counts *counts, int cpu, int thread) ...@@ -29,6 +29,18 @@ perf_counts(struct perf_counts *counts, int cpu, int thread)
return xyarray__entry(counts->values, cpu, 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); struct perf_counts *perf_counts__new(int ncpus, int nthreads);
void perf_counts__delete(struct perf_counts *counts); void perf_counts__delete(struct perf_counts *counts);
......
...@@ -1439,7 +1439,8 @@ perf_evsel__set_count(struct perf_evsel *counter, int cpu, int thread, ...@@ -1439,7 +1439,8 @@ perf_evsel__set_count(struct perf_evsel *counter, int cpu, int thread,
count->val = val; count->val = val;
count->ena = ena; count->ena = ena;
count->run = run; count->run = run;
count->loaded = true;
perf_counts__set_loaded(counter->counts, cpu, thread, true);
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment