On Wed, Jul 10, 2024 at 03:14:00PM -1000, Tejun Heo wrote: > sched_ext often needs to migrate tasks across CPUs right before execution > and thus uses the balance path to dispatch tasks from the BPF scheduler. > balance_scx() is called with rq locked and pinned but is passed @rf and thus > allowed to unpin and unlock. Currently, @rf is passed down the call stack so > the rq lock is unpinned just when double locking is needed. > > This creates unnecessary complications such as having to explicitly > manipulate lock pinning for core scheduling. We also want to use > dispatch_to_local_dsq_lock() from other paths which are called with rq > locked but unpinned. > > rq lock handling in the dispatch path is straightforward outside the > migration implementation and extending the pinning protection down the > callstack doesn't add enough meaningful extra protection to justify the > extra complexity. > > Unpin and repin rq lock from the outer balance_scx() and drop @rf passing > and lock pinning handling from the inner functions. UP is updated to call > balance_one() instead of balance_scx() to avoid adding NULL @rf handling to > balance_scx(). AS this makes balance_scx() unused in UP, it's put inside a > CONFIG_SMP block. > > No functional changes intended outside of lock annotation updates. > > Signed-off-by: Tejun Heo > Cc: Peter Zijlstra > Cc: Andrea Righi > Cc: David Vernet Acked-by: David Vernet