Re: [PATCH 5/6] sched_ext: Move scx_tasks_lock handling into scx_task_iter helpers

From: David Vernet
Date: Thu Oct 10 2024 - 15:01:03 EST


On Wed, Oct 09, 2024 at 11:41:01AM -1000, Tejun Heo wrote:
> Iterating with scx_task_iter involves scx_tasks_lock and optionally the rq
> lock of the task being iterated. Both locks can be released during iteration
> and the iteration can be continued after re-grabbing scx_tasks_lock.
> Currently, all lock handling is pushed to the caller which is a bit
> cumbersome and makes it difficult to add lock-aware behaviors. Make the
> scx_task_iter helpers handle scx_tasks_lock.
>
> - scx_task_iter_init/scx_taks_iter_exit() now grabs and releases
> scx_task_lock, respectively. Renamed to
> scx_task_iter_start/scx_task_iter_stop() to more clearly indicate that
> there are non-trivial side-effects.
>
> - Add __ prefix to scx_task_iter_rq_unlock() to indicate that the function
> is internal.
>
> - Add scx_task_iter_unlock/relock(). The former drops both rq lock (if held)
> and scx_tasks_lock and the latter re-locks only scx_tasks_lock.
>
> This doesn't cause behavior changes and will be used to implement stall
> avoidance.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>

Thanks for the nice little cleanup.

Acked-by: David Vernet <void@xxxxxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature