Skip to content

Commit 2b97264

Browse files
kawamurayyonghong-song
authored andcommitted
tools/offcputime Filter out negative offcpu duration
1 parent a9f9769 commit 2b97264

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/offcputime.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,13 @@ def signal_ignore(signal, frame):
146146
}
147147
148148
// calculate current thread's delta time
149-
u64 delta = bpf_ktime_get_ns() - *tsp;
149+
u64 t_start = *tsp;
150+
u64 t_end = bpf_ktime_get_ns();
150151
start.delete(&pid);
152+
if (t_start > t_end) {
153+
return 0;
154+
}
155+
u64 delta = t_end - t_start;
151156
delta = delta / 1000;
152157
if ((delta < MINBLOCK_US) || (delta > MAXBLOCK_US)) {
153158
return 0;

0 commit comments

Comments
 (0)