]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
sched_ext: deprecation warn for scx_bpf_cpu_rq()
authorChristian Loehle <christian.loehle@arm.com>
Wed, 3 Sep 2025 21:23:11 +0000 (22:23 +0100)
committerTejun Heo <tj@kernel.org>
Wed, 3 Sep 2025 21:51:57 +0000 (11:51 -1000)
scx_bpf_cpu_rq() works on an unlocked rq which generally isn't safe.
For the common use-cases scx_bpf_locked_rq() and
scx_bpf_cpu_curr() work, so add a deprecation warning
to scx_bpf_cpu_rq() so it can eventually be removed.

Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c
kernel/sched/ext_internal.h

index 4bd9b491b376acc6773fbb8c293398fe65755c0c..4160a4a7af67e6b6e0ca1827b0ba49267d1d15f3 100644 (file)
@@ -6351,9 +6351,18 @@ __bpf_kfunc s32 scx_bpf_task_cpu(const struct task_struct *p)
  */
 __bpf_kfunc struct rq *scx_bpf_cpu_rq(s32 cpu)
 {
+       struct scx_sched *sch = scx_root;
+
        if (!kf_cpu_valid(cpu, NULL))
                return NULL;
 
+       if (!sch->warned_deprecated_rq) {
+               printk_deferred(KERN_WARNING "sched_ext: %s() is deprecated; "
+                               "use scx_bpf_locked_rq() when holding rq lock "
+                               "or scx_bpf_cpu_curr() to read remote curr safely.\n", __func__);
+               sch->warned_deprecated_rq = true;
+       }
+
        return cpu_rq(cpu);
 }
 
index af4c054fb6f852fc19d734d445e35adb67ffc4c4..2e289931e567feb1c449ccfcb956e14c36f274b6 100644 (file)
@@ -872,6 +872,7 @@ struct scx_sched {
        struct scx_sched_pcpu __percpu *pcpu;
 
        bool                    warned_zero_slice;
+       bool                    warned_deprecated_rq;
 
        atomic_t                exit_kind;
        struct scx_exit_info    *exit_info;