Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/sched_ext: Add compat helper for scx_bpf_cpu_curr()

Introduce a compatibility helper that allows BPF schedulers to use
scx_bpf_cpu_curr() on older kernels.

Fixes: 20b158094a1ad ("sched_ext: Introduce scx_bpf_cpu_curr()")
Cc: Christian Loehle <christian.loehle@arm.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Andrea Righi and committed by
Tejun Heo
a08b4dca 5c48d88f

+18 -1
+1 -1
tools/sched_ext/include/scx/common.bpf.h
··· 104 104 s32 scx_bpf_task_cpu(const struct task_struct *p) __ksym; 105 105 struct rq *scx_bpf_cpu_rq(s32 cpu) __ksym; 106 106 struct rq *scx_bpf_locked_rq(void) __ksym; 107 - struct task_struct *scx_bpf_cpu_curr(s32 cpu) __ksym; 107 + struct task_struct *scx_bpf_cpu_curr(s32 cpu) __ksym __weak; 108 108 struct cgroup *scx_bpf_task_cgroup(struct task_struct *p) __ksym __weak; 109 109 u64 scx_bpf_now(void) __ksym __weak; 110 110 void scx_bpf_events(struct scx_event_stats *events, size_t events__sz) __ksym __weak;
+17
tools/sched_ext/include/scx/compat.bpf.h
··· 231 231 scx_bpf_pick_any_cpu(cpus_allowed, flags)) 232 232 233 233 /* 234 + * v6.18: Add a helper to retrieve the current task running on a CPU. 235 + * 236 + * Keep this helper available until v6.20 for compatibility. 237 + */ 238 + static inline struct task_struct *__COMPAT_scx_bpf_cpu_curr(int cpu) 239 + { 240 + struct rq *rq; 241 + 242 + if (bpf_ksym_exists(scx_bpf_cpu_curr)) 243 + return scx_bpf_cpu_curr(cpu); 244 + 245 + rq = scx_bpf_cpu_rq(cpu); 246 + 247 + return rq ? rq->curr : NULL; 248 + } 249 + 250 + /* 234 251 * Define sched_ext_ops. This may be expanded to define multiple variants for 235 252 * backward compatibility. See compat.h::SCX_OPS_LOAD/ATTACH(). 236 253 */