[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABFh=a4faAi0_GNQQrFQKfLFtKrOFDBEBoCFUC4dvHf2taCkFA@mail.gmail.com>
Date: Sat, 25 Oct 2025 19:19:05 -0400
From: Emil Tsalapatis <linux-lists@...alapatis.com>
To: Tejun Heo <tj@...nel.org>
Cc: David Vernet <void@...ifault.com>, Andrea Righi <andrea.righi@...ux.dev>, 
	Changwoo Min <changwoo@...lia.com>, linux-kernel@...r.kernel.org, 
	sched-ext@...ts.linux.dev, Peter Zijlstra <peterz@...radead.org>, 
	Wen-Fang Liu <liuwenfang@...or.com>
Subject: Re: [PATCH 2/3] sched_ext: Factor out reenq_local() from scx_bpf_reenqueue_local()
On Fri, Oct 24, 2025 at 8:18 PM Tejun Heo <tj@...nel.org> wrote:
>
> Factor out the core re-enqueue logic from scx_bpf_reenqueue_local() into a
> new reenq_local() helper function. scx_bpf_reenqueue_local() now handles the
> BPF kfunc checks and calls reenq_local() to perform the actual work.
>
> This is a prep patch to allow reenq_local() to be called from other contexts.
>
> Signed-off-by: Tejun Heo <tj@...nel.org>
> ---
Reviewed-by: Emil Tsalapatis <emil@...alapatis.com>
>  kernel/sched/ext.c | 50 +++++++++++++++++++++++++++++---------------------
>  1 file changed, 29 insertions(+), 21 deletions(-)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 111111111111..222222222222 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -5881,32 +5881,12 @@ static const struct btf_kfunc_id_set scx_kfunc_set_dispatch = {
>         .set                    = &scx_kfunc_ids_dispatch,
>  };
>
> -__bpf_kfunc_start_defs();
> -
> -/**
> - * scx_bpf_reenqueue_local - Re-enqueue tasks on a local DSQ
> - *
> - * Iterate over all of the tasks currently enqueued on the local DSQ of the
> - * caller's CPU, and re-enqueue them in the BPF scheduler. Returns the number of
> - * processed tasks. Can only be called from ops.cpu_release().
> - */
> -__bpf_kfunc u32 scx_bpf_reenqueue_local(void)
> +static u32 reenq_local(struct rq *rq)
>  {
> -       struct scx_sched *sch;
>         LIST_HEAD(tasks);
>         u32 nr_enqueued = 0;
> -       struct rq *rq;
>         struct task_struct *p, *n;
>
> -       guard(rcu)();
> -       sch = rcu_dereference(scx_root);
> -       if (unlikely(!sch))
> -               return 0;
> -
> -       if (!scx_kf_allowed(sch, SCX_KF_CPU_RELEASE))
> -               return 0;
> -
> -       rq = cpu_rq(smp_processor_id());
>         lockdep_assert_rq_held(rq);
>
>         /*
> @@ -5943,6 +5923,34 @@ __bpf_kfunc u32 scx_bpf_reenqueue_local(void)
>         return nr_enqueued;
>  }
>
> +__bpf_kfunc_start_defs();
> +
> +/**
> + * scx_bpf_reenqueue_local - Re-enqueue tasks on a local DSQ
> + *
> + * Iterate over all of the tasks currently enqueued on the local DSQ of the
> + * caller's CPU, and re-enqueue them in the BPF scheduler. Returns the number of
> + * processed tasks. Can only be called from ops.cpu_release().
> + */
> +__bpf_kfunc u32 scx_bpf_reenqueue_local(void)
> +{
> +       struct scx_sched *sch;
> +       struct rq *rq;
> +
> +       guard(rcu)();
> +       sch = rcu_dereference(scx_root);
> +       if (unlikely(!sch))
> +               return 0;
> +
> +       if (!scx_kf_allowed(sch, SCX_KF_CPU_RELEASE))
> +               return 0;
> +
> +       rq = cpu_rq(smp_processor_id());
> +       lockdep_assert_rq_held(rq);
> +
> +       return reenq_local(rq);
> +}
> +
>  __bpf_kfunc_end_defs();
>
>  BTF_KFUNCS_START(scx_kfunc_ids_cpu_release)
> --
> 2.47.1
>
Powered by blists - more mailing lists
 
