• Tejun Heo's avatar
    sched_ext: Move scx_tasks_lock handling into scx_task_iter helpers · 967da578
    Tejun Heo authored
    
    
    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: default avatarTejun Heo <tj@kernel.org>
    Acked-by: default avatarDavid Vernet <void@manifault.com>
    967da578
ext.c 204 KB