Re: [PATCH v3 1/4] perf stat: Fix wrong per-thread runtime stat for interval mode

From: Jin, Yao
Date: Thu May 07 2020 - 22:03:37 EST


Hi Jiri,

On 5/7/2020 11:19 PM, Jiri Olsa wrote:
On Thu, May 07, 2020 at 02:58:19PM +0800, Jin Yao wrote:

SNIP

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e0c1ad23c768..97ee941649e6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -351,6 +351,16 @@ static void read_counters(struct timespec *rs)
}
}
+static void thread_stats_reset(struct perf_stat_config *config)
+{
+ int i;
+
+ if (config->stats) {
+ for (i = 0; i < config->stats_num; i++)
+ perf_stat__reset_shadow_per_stat(&config->stats[i]);
+ }
+}
+
static void process_interval(void)
{
struct timespec ts, rs;
@@ -359,6 +369,7 @@ static void process_interval(void)
diff_timespec(&rs, &ts, &ref_time);
perf_stat__reset_shadow_per_stat(&rt_stat);
+ thread_stats_reset(&stat_config);

can't you call in here perf_stat__reset_stats?


If we call perf_stat__reset_stat here, it will reset the evsel->counts, but I don't think it's necessary. The counts will be updated in read_counts() soon.

and if not, I know it's threads related, but new
and delete functions are:

runtime_stat_new, runtime_stat_delete

so let's call it runtime_stat_reset and place it next to
the new/delete functions


Yes, that's good idea. I will create runtime_stat_reset and place it next to
untime_stat_new/runtime_stat_delete.

other than that it looks ok, thanks

jirka


Thanks!

Thanks
Jin Yao

read_counters(&rs);
if (STAT_RECORD) {
--
2.17.1