]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched_ext: Make explicit scx_task_iter_relock() calls unnecessary
authorTejun Heo <tj@kernel.org>
Wed, 3 Sep 2025 21:33:28 +0000 (11:33 -1000)
committerTejun Heo <tj@kernel.org>
Wed, 3 Sep 2025 21:33:28 +0000 (11:33 -1000)
commitb7975c48695cdc2cc308df342f85ccaf9dac0888
treed225a21e4e838bc08a1614c89971ca059b921bf6
parentde68c05189cc4508c3ac4e1e44da1ddb16b1bceb
sched_ext: Make explicit scx_task_iter_relock() calls unnecessary

During tasks iteration, the locks can be dropped using
scx_task_iter_unlock() to perform e.g. sleepable allocations. Afterwards,
scx_task_iter_relock() has to be called prior to other iteration operations,
which is error-prone. This can be easily automated by tracking whether
scx_tasks_lock is held in scx_task_iter and re-acquiring when necessary. It
already tracks whether the task's rq is locked after all.

- Add scx_task_iter->list_locked which remembers whether scx_tasks_lock is
  held.

- Rename scx_task_iter->locked to scx_task_iter->locked_task to better
  distinguish it from ->list_locked.

- Replace scx_task_iter_relock() with __scx_task_iter_maybe_relock() which
  is automatically called by scx_task_iter_next() and scx_task_iter_stop().

- Drop explicit scx_task_iter_relock() calls.

The resulting behavior should be equivalent.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c