1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

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: d07be814fc ("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>
This commit is contained in:
Changwoo Min 2025-02-02 12:37:48 +09:00 committed by Tejun Heo
parent 1626e5ef0b
commit 029b6ce733

View file

@ -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;
}
/**