History

sched_ext: Use rcu_access_pointer() for the first_task comparison

dsq->first_task is __rcu for the lockless scx_bpf_dsq_peek(). The task removal path compares it against the departing task with a plain load, which sparse flags. The comparison runs under the dsq lock and only tests identity, so rcu_access_pointer() is the fit.

Tejun Heo committed 3 months ago

Commit 6ee471b1 parent ce228341 file · +1 −1Browse files

Unified · Split

kernel/sched/ext/ext.c+1−1
@@ -1654,7 +1654,7 @@ static void task_unlink_from_dsq(struct task_struct *p, · 1653 unmodified lines
16541654 list_del_init(&p->scx.dsq_list.node);
16551655 dsq_dec_nr(dsq, p);
16561656
1657− if (!(dsq->id & SCX_DSQ_FLAG_BUILTIN) && dsq->first_task == p) {
1657+ if (!(dsq->id & SCX_DSQ_FLAG_BUILTIN) && rcu_access_pointer(dsq->first_task) == p) {
16581658 struct task_struct *first_task;
16591659
16601660 first_task = nldsq_next_task(dsq, NULL, false);