]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sched_ext: Unpin and repin rq lock from balance_scx()
authorTejun Heo <tj@kernel.org>
Fri, 12 Jul 2024 18:20:32 +0000 (08:20 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 12 Jul 2024 18:20:32 +0000 (08:20 -1000)
commit3cf78c5d01d61e6a4289c5856198235011f5e84b
treebb2dbac5c86eb3bb5a671c2e8a2862300a980783
parentd6a05910d25e1518cb34d9f79b2313587890c5e0
sched_ext: Unpin and repin rq lock from balance_scx()

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 <tj@kernel.org>
Acked-by: David Vernet <void@manifault.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrea Righi <righi.andrea@gmail.com>
kernel/sched/ext.c