Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/debug: Fix avg_vruntime() usage

John reported that stress-ng-yield could make his machine unhappy and
managed to bisect it to commit b3d99f43c72b ("sched/fair: Fix
zero_vruntime tracking").

The commit in question changes avg_vruntime() from a function that is
a pure reader, to a function that updates variables. This turns an
unlocked sched/debug usage of this function from a minor mistake into
a data corruptor.

Fixes: af4cf40470c2 ("sched/fair: Add cfs_rq::avg_vruntime")
Fixes: b3d99f43c72b ("sched/fair: Fix zero_vruntime tracking")
Reported-by: John Stultz <jstultz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: John Stultz <jstultz@google.com>
Link: https://patch.msgid.link/20260401132355.196370805@infradead.org

+3 -1
+3 -1
kernel/sched/debug.c
··· 902 902 void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) 903 903 { 904 904 s64 left_vruntime = -1, zero_vruntime, right_vruntime = -1, left_deadline = -1, spread; 905 + u64 avruntime; 905 906 struct sched_entity *last, *first, *root; 906 907 struct rq *rq = cpu_rq(cpu); 907 908 unsigned long flags; ··· 926 925 if (last) 927 926 right_vruntime = last->vruntime; 928 927 zero_vruntime = cfs_rq->zero_vruntime; 928 + avruntime = avg_vruntime(cfs_rq); 929 929 raw_spin_rq_unlock_irqrestore(rq, flags); 930 930 931 931 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "left_deadline", ··· 936 934 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "zero_vruntime", 937 935 SPLIT_NS(zero_vruntime)); 938 936 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "avg_vruntime", 939 - SPLIT_NS(avg_vruntime(cfs_rq))); 937 + SPLIT_NS(avruntime)); 940 938 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "right_vruntime", 941 939 SPLIT_NS(right_vruntime)); 942 940 spread = right_vruntime - left_vruntime;