[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250903212311.369697-4-christian.loehle@arm.com>
Date: Wed, 3 Sep 2025 22:23:11 +0100
From: Christian Loehle <christian.loehle@....com>
To: tj@...nel.org,
arighi@...dia.com,
void@...ifault.com
Cc: linux-kernel@...r.kernel.org,
sched-ext@...ts.linux.dev,
changwoo@...lia.com,
hodgesd@...a.com,
mingo@...hat.com,
peterz@...radead.org,
jake@...lion.co.uk,
Christian Loehle <christian.loehle@....com>
Subject: [PATCH v7 3/3] sched_ext: deprecation warn for scx_bpf_cpu_rq()
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@....com>
---
kernel/sched/ext.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 6ea81b6a6b2d..1a0afdf5fcf5 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -873,6 +873,7 @@ struct scx_sched {
struct scx_event_stats __percpu *event_stats_cpu;
bool warned_zero_slice;
+ bool warned_deprecated_rq;
atomic_t exit_kind;
struct scx_exit_info *exit_info;
@@ -7424,9 +7425,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);
}
--
2.34.1
Powered by blists - more mailing lists