sched_ext: Fix scx_bpf_dsq_reenq() kerneldoc claiming NMI calls are allowed
Subsystems (2)
Tejun Heo
reviewerPATCH 1/1 sched_ext: Fix scx_bpf_dsq_reenq() kerneldoc claiming NMI calls are allowed
c659e506f9a7 ("sched_ext: Reject NMI calls to lock-taking kfuncs") made scx_bpf_dsq_reenq() abort the scheduler when called from NMI. The kerneldocs of scx_bpf_dsq_reenq() and of its wrapper scx_bpf_reenqueue_local___v2() still say the kfuncs can be called from anywhere. Update both to exclude NMI.
While at it, fix the wrapper's kerneldoc, which says it re-enqueues the calling CPU's local DSQ rather than the one SCX_DSQ_LOCAL resolves to, and the SCX_RENQ_* typo in the scx_bpf_dsq_reenq() kerneldoc.
--- kernel/sched/ext/ext.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
kernel/sched/ext/ext.c +8 -6
@@ -11115,7 +11115,7 @@ __bpf_kfunc struct task_struct *scx_bpf_dsq_peek(u64 dsq_id,/** * scx_bpf_dsq_reenq - Re-enqueue tasks on a DSQ * @dsq_id: DSQ to re-enqueue -* @reenq_flags: %SCX_RENQ_* +* @reenq_flags: %SCX_REENQ_* * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs * * Iterate over all of the tasks currently enqueued on the DSQ identified by
@@ -11125,8 +11125,9 @@ __bpf_kfunc struct task_struct *scx_bpf_dsq_peek(u64 dsq_id,* - Local DSQs (%SCX_DSQ_LOCAL or %SCX_DSQ_LOCAL_ON | $cpu) * - User DSQs * -* Re-enqueues are performed asynchronously. Can be called from anywhere. A -* re-enqueue of an inactive cpu's local DSQ is ignored. +* Re-enqueues are performed asynchronously. Can be called from any context +* except NMI. A call from NMI aborts the scheduler. A re-enqueue of an inactive +* cpu's local DSQ is ignored. * * %SCX_DSQ_LOCAL resolves to the local DSQ of the rq the current scheduler * operation is locked to - e.g. the rq being dispatched for in ops.dispatch() -
@@ -11223,9 +11224,10 @@ __bpf_kfunc bool scx_bpf_dsq_reenq_task(struct bpf_iter_scx_dsq *it__iter,* scx_bpf_reenqueue_local___v2 - Re-enqueue tasks on a local DSQ * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs * -* Iterate over all of the tasks currently enqueued on the local DSQ of the -* caller's CPU, and re-enqueue them in the BPF scheduler. Can be called from -* anywhere. +* Iterate over all of the tasks currently enqueued on the local DSQ of the rq +* the current scheduler operation is locked to, or the calling CPU's when no rq +* is locked, and re-enqueue them in the BPF scheduler. Can be called from any +* context except NMI. A call from NMI aborts the scheduler. * * This is now a special case of scx_bpf_dsq_reenq() and may be removed in the * future.
Signature · 1 line
2.56.0
Quoted 11 lines · Tejun Heo
c659e506f9a7("sched_ext: Reject NMI calls to lock-taking kfuncs") madescx_bpf_dsq_reenq()abort the scheduler when called from NMI. The kerneldocs ofscx_bpf_dsq_reenq()and of its wrapperscx_bpf_reenqueue_local___v2()still say the kfuncs can be called from anywhere. Update both to exclude NMI.While at it, fix the wrapper's kerneldoc, which says it re-enqueues the calling CPU's local DSQ rather than the one
SCX_DSQ_LOCALresolves to, and the SCX_RENQ_* typo in thescx_bpf_dsq_reenq()kerneldoc.Signed-off-by Tejun Heo <[email protected]>
Thanks,
-Andrea
Quoted 46 lines
--- kernel/sched/ext/ext.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)kernel/sched/ext/ext.c +8
-6@@ -11115,7 +11115,7 @@ __bpf_kfunc struct task_struct *scx_bpf_dsq_peek(u64 dsq_id,/** * scx_bpf_dsq_reenq - Re-enqueue tasks on a DSQ * @dsq_id: DSQ to re-enqueue -* @reenq_flags: %SCX_RENQ_* +* @reenq_flags: %SCX_REENQ_* * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs * * Iterate over all of the tasks currently enqueued on the DSQ identified by @@ -11125,8 +11125,9 @@ __bpf_kfunc struct task_struct *scx_bpf_dsq_peek(u64 dsq_id,* - Local DSQs (%SCX_DSQ_LOCAL or %SCX_DSQ_LOCAL_ON | $cpu) * - User DSQs * -* Re-enqueues are performed asynchronously. Can be called from anywhere. A -* re-enqueue of an inactive cpu's local DSQ is ignored. +* Re-enqueues are performed asynchronously. Can be called from any context +* except NMI. A call from NMI aborts the scheduler. A re-enqueue of an inactive +* cpu's local DSQ is ignored. * * %SCX_DSQ_LOCAL resolves to the local DSQ of the rq the current scheduler * operation is locked to - e.g. the rq being dispatched for in ops.dispatch() - @@ -11223,9 +11224,10 @@ __bpf_kfunc bool scx_bpf_dsq_reenq_task(struct bpf_iter_scx_dsq *it__iter,* scx_bpf_reenqueue_local___v2 - Re-enqueue tasks on a local DSQ * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs * -* Iterate over all of the tasks currently enqueued on the local DSQ of the -* caller's CPU, and re-enqueue them in the BPF scheduler. Can be called from -* anywhere. +* Iterate over all of the tasks currently enqueued on the local DSQ of the rq +* the current scheduler operation is locked to, or the calling CPU's when no rq +* is locked, and re-enqueue them in the BPF scheduler. Can be called from any +* context except NMI. A call from NMI aborts the scheduler. * * This is now a special case of scx_bpf_dsq_reenq() and may be removed in the * future. Signature · 1 line
2.56.0
Applied to sched_ext/for-7.4-fixes with the following tags added:
Thanks.
--
tejun