All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Christian Loehle <christian.loehle@arm.com>
Cc: sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org,
	tj@kernel.org, void@manifault.com, changwoo@igalia.com,
	gnq25@mails.tsinghua.edu.cn
Subject: Re: [PATCH] sched_ext: Remove deprecated scx_bpf_cpu_rq()
Date: Fri, 19 Jun 2026 20:53:56 +0200	[thread overview]
Message-ID: <ajWQRLnfpnFtHmTs@gpd4> (raw)
In-Reply-To: <20260619155920.156257-1-christian.loehle@arm.com>

Hi Christian,

On Fri, Jun 19, 2026 at 04:59:20PM +0100, Christian Loehle wrote:
> scx_bpf_cpu_rq() exposes rq pointers without requiring the rq lock and
> has emitted a deprecation warning since commit
> 5c48d88fe004 ("sched_ext: deprecation warn for scx_bpf_cpu_rq()").
> The supported replacements cover the intended uses:
> scx_bpf_locked_rq() for locked rq access and
> scx_bpf_cpu_curr() for remote curr lookup.
> 
> Remove the kfunc, its BTF registrations, the deprecation warning
> state, and the BPF-side prototype and compat fallback.
> 
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>

It looks like none of the schedulers in the scx repo are using scx_bpf_cpu_rq()
anymore, so I think we can safely remove it.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
>  kernel/sched/ext.c                       | 30 ------------------------
>  kernel/sched/ext_internal.h              |  1 -
>  tools/sched_ext/include/scx/common.bpf.h |  5 ++--
>  tools/sched_ext/include/scx/compat.bpf.h | 17 --------------
>  4 files changed, 2 insertions(+), 51 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 0db6fa2daea3..72d99dd3fe89 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -10222,34 +10222,6 @@ __bpf_kfunc s32 scx_bpf_task_cid(const struct task_struct *p)
>  	return tbl[task_cpu(p)];
>  }
>  
> -/**
> - * scx_bpf_cpu_rq - Fetch the rq of a CPU
> - * @cpu: CPU of the rq
> - * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs
> - */
> -__bpf_kfunc struct rq *scx_bpf_cpu_rq(s32 cpu, const struct bpf_prog_aux *aux)
> -{
> -	struct scx_sched *sch;
> -
> -	guard(rcu)();
> -
> -	sch = scx_prog_sched(aux);
> -	if (unlikely(!sch))
> -		return NULL;
> -
> -	if (!scx_cpu_valid(sch, 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);
> -}
> -
>  /**
>   * scx_bpf_locked_rq - Return the rq currently locked by SCX
>   * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs
> @@ -10540,7 +10512,6 @@ BTF_ID_FLAGS(func, scx_bpf_put_cpumask, KF_RELEASE)
>  BTF_ID_FLAGS(func, scx_bpf_task_running, KF_RCU)
>  BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_RCU)
>  BTF_ID_FLAGS(func, scx_bpf_task_cid, KF_RCU)
> -BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS)
>  BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_IMPLICIT_ARGS | KF_RET_NULL)
>  BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED)
>  BTF_ID_FLAGS(func, scx_bpf_cid_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED)
> @@ -10575,7 +10546,6 @@ static const struct btf_kfunc_id_set scx_kfunc_set_any = {
>  BTF_KFUNCS_START(scx_kfunc_ids_cpu_only)
>  BTF_ID_FLAGS(func, scx_bpf_kick_cpu, KF_IMPLICIT_ARGS)
>  BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_RCU)
> -BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS)
>  BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED)
>  BTF_ID_FLAGS(func, scx_bpf_cpu_node, KF_IMPLICIT_ARGS)
>  BTF_ID_FLAGS(func, scx_bpf_cpuperf_cap, KF_IMPLICIT_ARGS)
> diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h
> index b04701190b23..38f099ccd24f 100644
> --- a/kernel/sched/ext_internal.h
> +++ b/kernel/sched/ext_internal.h
> @@ -1165,7 +1165,6 @@ struct scx_sched {
>  	 * but it doesn't really matter.
>  	 */
>  	bool			warned_zero_slice:1;
> -	bool			warned_deprecated_rq:1;
>  	bool			warned_unassoc_progs:1;
>  
>  	struct list_head	all;
> diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
> index 9591a6e778ce..bd51986c4c42 100644
> --- a/tools/sched_ext/include/scx/common.bpf.h
> +++ b/tools/sched_ext/include/scx/common.bpf.h
> @@ -96,7 +96,6 @@ s32 scx_bpf_pick_any_cpu_node(const cpumask_t *cpus_allowed, int node, u64 flags
>  s32 scx_bpf_pick_any_cpu(const cpumask_t *cpus_allowed, u64 flags) __ksym;
>  bool scx_bpf_task_running(const struct task_struct *p) __ksym;
>  s32 scx_bpf_task_cpu(const struct task_struct *p) __ksym;
> -struct rq *scx_bpf_cpu_rq(s32 cpu) __ksym;
>  struct rq *scx_bpf_locked_rq(void) __ksym;
>  struct task_struct *scx_bpf_cpu_curr(s32 cpu) __ksym __weak;
>  struct task_struct *scx_bpf_tid_to_task(u64 tid) __ksym __weak;
> @@ -983,8 +982,8 @@ extern struct irqtime___local cpu_irqtime __ksym __weak;
>  static inline struct rq___local *get_current_rq(u32 cpu)
>  {
>  	/*
> -	 * This is a workaround to get an rq pointer since we decided to
> -	 * deprecate scx_bpf_cpu_rq().
> +	 * This is a workaround to get an rq pointer now that
> +	 * scx_bpf_cpu_rq() has been removed.
>  	 *
>  	 * WARNING: The caller must hold the rq lock for @cpu. This is
>  	 * guaranteed when called from scheduling callbacks (ops.running,
> diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
> index 87f15f296234..133058578668 100644
> --- a/tools/sched_ext/include/scx/compat.bpf.h
> +++ b/tools/sched_ext/include/scx/compat.bpf.h
> @@ -233,23 +233,6 @@ static inline bool __COMPAT_is_enq_cpu_selected(u64 enq_flags)
>  	 scx_bpf_pick_any_cpu_node(cpus_allowed, node, flags) :			\
>  	 scx_bpf_pick_any_cpu(cpus_allowed, flags))
>  
> -/*
> - * v6.18: Add a helper to retrieve the current task running on a CPU.
> - *
> - * Keep this helper available until v6.20 for compatibility.
> - */
> -static inline struct task_struct *__COMPAT_scx_bpf_cpu_curr(int cpu)
> -{
> -	struct rq *rq;
> -
> -	if (bpf_ksym_exists(scx_bpf_cpu_curr))
> -		return scx_bpf_cpu_curr(cpu);
> -
> -	rq = scx_bpf_cpu_rq(cpu);
> -
> -	return rq ? rq->curr : NULL;
> -}
> -
>  /*
>   * v6.19: To work around BPF maximum parameter limit, the following kfuncs are
>   * replaced with variants that pack scalar arguments in a struct. Wrappers are
> -- 
> 2.34.1
> 

      reply	other threads:[~2026-06-19 18:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 15:59 [PATCH] sched_ext: Remove deprecated scx_bpf_cpu_rq() Christian Loehle
2026-06-19 18:53 ` Andrea Righi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ajWQRLnfpnFtHmTs@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=christian.loehle@arm.com \
    --cc=gnq25@mails.tsinghua.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.