[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250324223452.208081-13-irogers@google.com>
Date: Mon, 24 Mar 2025 15:34:50 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>, Weilin Wang <weilin.wang@...el.com>,
James Clark <james.clark@...aro.org>, Xu Yang <xu.yang_2@....com>,
John Garry <john.g.garry@...cle.com>, Howard Chu <howardchu95@...il.com>,
Levi Yun <yeoreum.yun@....com>, Dominique Martinet <asmadeus@...ewreck.org>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v1 12/14] perf intel-tpebs: Use stats for retirement latency statistics
struct stats provides access to mean, min and max. It also provides
uniformity with statistics code used elsewhere in perf.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/perf/util/intel-tpebs.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c
index 4d51dc8f74ea..0def3419b1e5 100644
--- a/tools/perf/util/intel-tpebs.c
+++ b/tools/perf/util/intel-tpebs.c
@@ -18,6 +18,7 @@
#include "evsel.h"
#include "mutex.h"
#include "session.h"
+#include "stat.h"
#include "tool.h"
#include "cpumap.h"
#include "metricgroup.h"
@@ -41,12 +42,8 @@ struct tpebs_retire_lat {
struct evsel *evsel;
/** @event: Event passed to perf record. */
char *event;
- /* Count of retire_latency values found in sample data */
- size_t count;
- /* Sum of all the retire_latency values in sample data */
- int sum;
- /* Average of retire_latency, val = sum / count */
- double val;
+ /** @stats: Recorded retirement latency stats. */
+ struct stats stats;
/* Has the event been sent to perf record? */
bool started;
};
@@ -144,9 +141,7 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
* latency value will be used. Save the number of samples and the sum of
* retire latency value for each event.
*/
- t->count += 1;
- t->sum += sample->retire_lat;
- t->val = (double) t->sum / t->count;
+ update_stats(&t->stats, sample->retire_lat);
mutex_unlock(tpebs_mtx_get());
return 0;
}
@@ -516,7 +511,7 @@ int evsel__tpebs_read(struct evsel *evsel, int cpu_map_idx, int thread)
return ret;
mutex_lock(tpebs_mtx_get());
}
- val = rint(t->val);
+ val = rint(t->stats.mean);
mutex_unlock(tpebs_mtx_get());
if (old_count) {
--
2.49.0.395.g12beb8f557-goog
Powered by blists - more mailing lists