Skip to content

Commit e08d007

Browse files
author
Peter Zijlstra
committed
sched/debug: Fix avg_vruntime() usage
John reported that stress-ng-yield could make his machine unhappy and managed to bisect it to commit b3d99f4 ("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: af4cf40 ("sched/fair: Add cfs_rq::avg_vruntime") Fixes: b3d99f4 ("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
1 parent 1319ea5 commit e08d007

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/sched/debug.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
902902
void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
903903
{
904904
s64 left_vruntime = -1, zero_vruntime, right_vruntime = -1, left_deadline = -1, spread;
905+
u64 avruntime;
905906
struct sched_entity *last, *first, *root;
906907
struct rq *rq = cpu_rq(cpu);
907908
unsigned long flags;
@@ -925,6 +926,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
925926
if (last)
926927
right_vruntime = last->vruntime;
927928
zero_vruntime = cfs_rq->zero_vruntime;
929+
avruntime = avg_vruntime(cfs_rq);
928930
raw_spin_rq_unlock_irqrestore(rq, flags);
929931

930932
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "left_deadline",
@@ -934,7 +936,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
934936
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "zero_vruntime",
935937
SPLIT_NS(zero_vruntime));
936938
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "avg_vruntime",
937-
SPLIT_NS(avg_vruntime(cfs_rq)));
939+
SPLIT_NS(avruntime));
938940
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "right_vruntime",
939941
SPLIT_NS(right_vruntime));
940942
spread = right_vruntime - left_vruntime;

0 commit comments

Comments
 (0)