[PATCH v3 0/2] sched_ext: Introduce rq lock tracking

Andrea Righi posted 2 patches 7 months, 3 weeks ago
kernel/sched/ext.c      | 179 +++++++++++++++++++++++++++++++-----------------
kernel/sched/ext_idle.c |   2 +-
2 files changed, 118 insertions(+), 63 deletions(-)
[PATCH v3 0/2] sched_ext: Introduce rq lock tracking
Posted by Andrea Righi 7 months, 3 weeks ago
Add rq lock tracking to sched_ext ops callbacks to enable scx_bpf_*()
kfuncs to detect whether a specific rq is currently locked and safely
operate with it.

If no rq is locked, the target rq lock can be acquired. If a different rq
is already locked, the operation can either fail (triggering an ops error),
deferred using IRQ work, or managed accordingly to avoid deadlocks.

This patchset is also available in the following git branch:

 git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-rq-lock-tracking

Changes in v3:
 - remove unnecessary rq != NULL optimization check in SCX_CALL_OP()
 - reorder SCX_CALL_OP*() arguments to group static args together
 - link to v2: https://lore.kernel.org/all/20250420193106.42533-1-arighi@nvidia.com/

Changes in v2:
 - store currently locked rq in a percpu variable
 - link to v1: https://lore.kernel.org/all/20250419123536.154469-1-arighi@nvidia.com

Andrea Righi (2):
      sched_ext: Track currently locked rq
      sched_ext: Fix missing rq lock in scx_bpf_cpuperf_set()

 kernel/sched/ext.c      | 179 +++++++++++++++++++++++++++++++-----------------
 kernel/sched/ext_idle.c |   2 +-
 2 files changed, 118 insertions(+), 63 deletions(-)
Re: [PATCH v3 0/2] sched_ext: Introduce rq lock tracking
Posted by Tejun Heo 7 months, 3 weeks ago
On Tue, Apr 22, 2025 at 10:26:31AM +0200, Andrea Righi wrote:
> Add rq lock tracking to sched_ext ops callbacks to enable scx_bpf_*()
> kfuncs to detect whether a specific rq is currently locked and safely
> operate with it.
> 
> If no rq is locked, the target rq lock can be acquired. If a different rq
> is already locked, the operation can either fail (triggering an ops error),
> deferred using IRQ work, or managed accordingly to avoid deadlocks.
> 
> This patchset is also available in the following git branch:
> 
>  git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-rq-lock-tracking

Applied to sched_ext/for-6.15-fixes and merged into for-6.16. It had a
couple minor conflictsapplying to for-6.15-fixes but the merged result on
for-6.16 is identical to applying directly to for-6.16, so it should be
okay.

Thanks.

-- 
tejun