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_ext: Fix scx_bpf_dsq_peek() with FIFO DSQs

When removing a task from a FIFO DSQ, we must delete it from the list
before updating dsq->first_task, otherwise the following lookup will
just re-read the same task, leaving first_task pointing to removed
entry.

This issue only affects DSQs operating in FIFO mode, as priority DSQs
correctly update the rbtree before re-evaluating the new first task.

Remove the item from the list before refreshing the first task to
guarantee the correct behavior in FIFO DSQs.

Fixes: 44f5c8ec5b9ad ("sched_ext: Add lockless peek operation for DSQs")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Andrea Righi and committed by
Tejun Heo
71d7847c e6770882

+3 -3
+3 -3
kernel/sched/ext.c
··· 1044 1044 p->scx.dsq_flags &= ~SCX_TASK_DSQ_ON_PRIQ; 1045 1045 } 1046 1046 1047 + list_del_init(&p->scx.dsq_list.node); 1048 + dsq_mod_nr(dsq, -1); 1049 + 1047 1050 if (!(dsq->id & SCX_DSQ_FLAG_BUILTIN) && dsq->first_task == p) { 1048 1051 struct task_struct *first_task; 1049 1052 1050 1053 first_task = nldsq_next_task(dsq, NULL, false); 1051 1054 rcu_assign_pointer(dsq->first_task, first_task); 1052 1055 } 1053 - 1054 - list_del_init(&p->scx.dsq_list.node); 1055 - dsq_mod_nr(dsq, -1); 1056 1056 } 1057 1057 1058 1058 static void dispatch_dequeue(struct rq *rq, struct task_struct *p)