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

Showing the changes to kernel (1 of 1 file). Show all

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
1654 list_del_init(&p->scx.dsq_list.node);1654 list_del_init(&p->scx.dsq_list.node);
1655 dsq_dec_nr(dsq, p);1655 dsq_dec_nr(dsq, p);
1656 1656
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) {
1658 struct task_struct *first_task;1658 struct task_struct *first_task;
1659 1659
1660 first_task = nldsq_next_task(dsq, NULL, false);1660 first_task = nldsq_next_task(dsq, NULL, false);