diff options
author | 2025-02-02 12:37:48 +0900 | |
---|---|---|
committer | 2025-02-02 07:40:35 -1000 | |
commit | 029b6ce733712a41421955194b113f283dcb1026 (patch) | |
tree | 8d2c2c469c98fb917c338fdbb61e13395660c3cf | |
parent | sched_ext: Fix lock imbalance in dispatch_to_local_dsq() (diff) | |
download | wireguard-linux-029b6ce733712a41421955194b113f283dcb1026.tar.xz wireguard-linux-029b6ce733712a41421955194b113f283dcb1026.zip |
sched_ext: Fix incorrect time delta calculation in time_delta()
When (s64)(after - before) > 0, the code returns the result of
(s64)(after - before) > 0 while the intended result should be
(s64)(after - before). That happens because the middle operand of
the ternary operator was omitted incorrectly, returning the result of
(s64)(after - before) > 0. Thus, add the middle operand
-- (s64)(after - before) -- to return the correct time calculation.
Fixes: d07be814fc71 ("sched_ext: Add time helpers for BPF schedulers")
Signed-off-by: Changwoo Min <changwoo@igalia.com>
Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | tools/sched_ext/include/scx/common.bpf.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h index f254a39b86a5..d72b60a0c582 100644 --- a/tools/sched_ext/include/scx/common.bpf.h +++ b/tools/sched_ext/include/scx/common.bpf.h @@ -432,7 +432,7 @@ void bpf_rcu_read_unlock(void) __ksym; */ static inline s64 time_delta(u64 after, u64 before) { - return (s64)(after - before) > 0 ? : 0; + return (s64)(after - before) > 0 ? (s64)(after - before) : 0; } /** |