]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
perf stat: Fix duration_time value for higher intervals
authorJiri Olsa <jolsa@kernel.org>
Mon, 18 May 2020 13:14:45 +0000 (15:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:14:46 +0000 (13:14 +0200)
[ Upstream commit ea9eb1f456a08c18feb485894185f7a4e31cc8a4 ]

Joakim reported wrong duration_time value for interval bigger
than 4000 [1].

The problem is in the interval value we pass to update_stats
function, which is typed as 'unsigned int' and overflows when
we get over 2^32 (happens between intervals 4000 and 5000).

Retyping the passed value to unsigned long long.

[1] https://www.spinics.net/lists/linux-perf-users/msg11777.html

Fixes: b90f1333ef08 ("perf stat: Update walltime_nsecs_stats in interval mode")
Reported-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@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://lore.kernel.org/lkml/20200518131445.3745083-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/builtin-stat.c

index 6aae10ff954c72847d9648e25e45e7b1d2a7ea1e..adabe9d4dc8667a428ecb5dbbabf132df2233e5a 100644 (file)
@@ -422,7 +422,7 @@ static void process_interval(void)
        }
 
        init_stats(&walltime_nsecs_stats);
-       update_stats(&walltime_nsecs_stats, stat_config.interval * 1000000);
+       update_stats(&walltime_nsecs_stats, stat_config.interval * 1000000ULL);
        print_counters(&rs, 0, NULL);
 }