]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Add scx_vet_enq_flags() and plumb dsq_id into preamble
authorTejun Heo <tj@kernel.org>
Fri, 13 Mar 2026 19:43:22 +0000 (09:43 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 13 Mar 2026 19:43:22 +0000 (09:43 -1000)
Add scx_vet_enq_flags() stub and call it from scx_dsq_insert_preamble() and
scx_dsq_move(). Pass dsq_id into preamble so the vetting function can
validate flag and DSQ combinations.

No functional change. This prepares for SCX_ENQ_IMMED which will populate the
vetting function.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c

index 774c012831e69beb6eb33cab8eafbeb0ce336469..2f59265b9b579dd553b9e33752d331715a38ecf6 100644 (file)
@@ -7530,8 +7530,13 @@ void __init init_sched_ext_class(void)
 /********************************************************************************
  * Helpers that can be called from the BPF scheduler.
  */
+static bool scx_vet_enq_flags(struct scx_sched *sch, u64 dsq_id, u64 enq_flags)
+{
+       return true;
+}
+
 static bool scx_dsq_insert_preamble(struct scx_sched *sch, struct task_struct *p,
-                                   u64 enq_flags)
+                                   u64 dsq_id, u64 enq_flags)
 {
        if (!scx_kf_allowed(sch, SCX_KF_ENQUEUE | SCX_KF_DISPATCH))
                return false;
@@ -7554,6 +7559,9 @@ static bool scx_dsq_insert_preamble(struct scx_sched *sch, struct task_struct *p
                return false;
        }
 
+       if (!scx_vet_enq_flags(sch, dsq_id, enq_flags))
+               return false;
+
        return true;
 }
 
@@ -7635,7 +7643,7 @@ __bpf_kfunc bool scx_bpf_dsq_insert___v2(struct task_struct *p, u64 dsq_id,
        if (unlikely(!sch))
                return false;
 
-       if (!scx_dsq_insert_preamble(sch, p, enq_flags))
+       if (!scx_dsq_insert_preamble(sch, p, dsq_id, enq_flags))
                return false;
 
        if (slice)
@@ -7661,7 +7669,7 @@ __bpf_kfunc void scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id,
 static bool scx_dsq_insert_vtime(struct scx_sched *sch, struct task_struct *p,
                                 u64 dsq_id, u64 slice, u64 vtime, u64 enq_flags)
 {
-       if (!scx_dsq_insert_preamble(sch, p, enq_flags))
+       if (!scx_dsq_insert_preamble(sch, p, dsq_id, enq_flags))
                return false;
 
        if (slice)
@@ -7788,6 +7796,9 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_kern *kit,
            !scx_kf_allowed(sch, SCX_KF_DISPATCH))
                return false;
 
+       if (!scx_vet_enq_flags(sch, dsq_id, enq_flags))
+               return false;
+
        /*
         * If the BPF scheduler keeps calling this function repeatedly, it can
         * cause similar live-lock conditions as consume_dispatch_q().