summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Petlan <mpetlan@redhat.com>2026-04-02 17:51:18 +0300
committerNamhyung Kim <namhyung@kernel.org>2026-04-03 04:43:35 +0300
commit11e8d234d4be7af401e8a24e078005ecd9bc1d1a (patch)
treec5eb33b0c7dd78dcce6dd52792e19cb2cbf9d257 /tools
parent85a9a4abcdc09ee941273c99d3ad0bc2ddef09ea (diff)
downloadlinux-11e8d234d4be7af401e8a24e078005ecd9bc1d1a.tar.xz
perf trace: Fix potential u64 underflow in duration calculation
Although it happens very rarely, in case of out-of-order events (i.e. due to CPU migration when a syscall is executed), the calculation of event duration might underflow and thus a bogus value is printed: 2.804 ( 0.001 ms): :49553/49553 rt_sigaction(sig: QUIT, act: 0x7fff403ed6e0, oact: 0x7fff403ed780, sigsetsize: 8) = 0 2.807 ( 0.001 ms): :49553/49553 rt_sigaction(sig: CHLD, act: 0x7fff403ed6e0, oact: 0x7fff403ed780, sigsetsize: 8) = 0 2.815 (18446744073709.438 ms): :49553/49553 execve(filename: 0xbb173a30, argv: 0x55aabb171930, envp: 0x55aabb171120) = 0 2.815 ( 0.534 ms): pwd/49553 ... [continued]: execve()) = 0 Check for possible underflow first and in case of a bogus value, do not print it. 2.804 ( 0.001 ms): :49553/49553 rt_sigaction(sig: QUIT, act: 0x7fff403ed6e0, oact: 0x7fff403ed780, sigsetsize: 8) = 0 2.807 ( 0.001 ms): :49553/49553 rt_sigaction(sig: CHLD, act: 0x7fff403ed6e0, oact: 0x7fff403ed780, sigsetsize: 8) = 0 2.815 ( ): :49553/49553 execve(filename: 0xbb173a30, argv: 0x55aabb171930, envp: 0x55aabb171120) = 0 2.815 ( 0.534 ms): pwd/49553 ... [continued]: execve()) = 0 Signed-off-by: Michael Petlan <mpetlan@redhat.com> Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-trace.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index d121640ace6e..873d144807e2 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2960,7 +2960,7 @@ static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
++trace->stats.vfs_getname;
}
- if (ttrace->entry_time) {
+ if (ttrace->entry_time && sample->time >= ttrace->entry_time) {
duration = sample->time - ttrace->entry_time;
if (trace__filter_duration(trace, duration))
goto out;