From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org, sched-ext@lists.linux.dev,
void@manifault.com, changwoo@igalia.com, emil@etsalapatis.com
Subject: Re: [PATCH 10/15] sched_ext: Add per-CPU data to DSQs
Date: Fri, 6 Mar 2026 23:56:48 +0100 [thread overview]
Message-ID: <aatbsAPM9J7fqHH3@gpd4> (raw)
In-Reply-To: <aatbDPw3wcY0b0Lx@gpd4>
On Fri, Mar 06, 2026 at 11:54:15PM +0100, Andrea Righi wrote:
> Hi Tejun,
>
> On Fri, Mar 06, 2026 at 09:06:18AM -1000, Tejun Heo wrote:
> > Add per-CPU data structure to dispatch queues. Each DSQ now has a percpu
> > scx_dsq_pcpu which contains a back-pointer to the DSQ. This will be used by
> > future changes to implement per-CPU reenqueue tracking for user DSQs.
> >
> > init_dsq() now allocates the percpu data and can fail, so it returns an
> > error code. All callers are updated to handle failures. exit_dsq() is added
> > to free the percpu data and is called from all DSQ cleanup paths.
> >
> > In scx_bpf_create_dsq(), init_dsq() is called before rcu_read_lock() since
> > alloc_percpu() requires GFP_KERNEL context, and dsq->sched is set
> > afterwards.
> >
> > Signed-off-by: Tejun Heo <tj@kernel.org>
> > ---
> ...
> > @@ -5849,8 +5884,11 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
> > goto err_free_pnode;
> > }
> >
> > - for_each_possible_cpu(cpu)
> > - init_dsq(bypass_dsq(sch, cpu), SCX_DSQ_BYPASS, sch);
> > + for_each_possible_cpu(cpu) {
> > + ret = init_dsq(bypass_dsq(sch, cpu), SCX_DSQ_BYPASS, sch);
> > + if (ret)
> > + goto err_free_pcpu;
>
> If we fail here...
>
> > + }
> >
> > for_each_possible_cpu(cpu) {
> > struct scx_sched_pcpu *pcpu = per_cpu_ptr(sch->pcpu, cpu);
> > @@ -5932,6 +5970,10 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
> > err_stop_helper:
> > kthread_destroy_worker(sch->helper);
> > err_free_pcpu:
> > + for_each_possible_cpu(cpu) {
> > + if (bypass_dsq(sch, cpu))
> > + exit_dsq(bypass_dsq(sch, cpu));
> > + }
>
> ...we are still calling exit_dsq() for all the CPUs. We should probably
> call it only on the initialized ones, or we may touch uninitialized mem.
Moreover, bypass_dsq() is always non-NULL so we can remove the redundant
check if bypass_dsq().
Thanks,
-Andrea
next prev parent reply other threads:[~2026-03-06 22:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 19:06 [PATCHSET sched_ext/for-7.1] sched_ext: Overhaul DSQ reenqueue infrastructure Tejun Heo
2026-03-06 19:06 ` [PATCH 01/15] sched_ext: Relocate scx_bpf_task_cgroup() and its BTF_ID to the end of kfunc section Tejun Heo
2026-03-06 20:45 ` Emil Tsalapatis
2026-03-06 23:20 ` Daniel Jordan
2026-03-06 19:06 ` [PATCH 02/15] sched_ext: Wrap global DSQs in per-node structure Tejun Heo
2026-03-06 20:52 ` Emil Tsalapatis
2026-03-06 23:20 ` Daniel Jordan
2026-03-06 19:06 ` [PATCH 03/15] sched_ext: Factor out pnode allocation and deallocation into helpers Tejun Heo
2026-03-06 20:54 ` Emil Tsalapatis
2026-03-06 23:21 ` Daniel Jordan
2026-03-06 19:06 ` [PATCH 04/15] sched_ext: Change find_global_dsq() to take CPU number instead of task Tejun Heo
2026-03-06 21:06 ` Emil Tsalapatis
2026-03-06 22:33 ` [PATCH v2 " Tejun Heo
2026-03-06 23:21 ` [PATCH " Daniel Jordan
2026-03-06 19:06 ` [PATCH 05/15] sched_ext: Relocate reenq_local() and run_deferred() Tejun Heo
2026-03-06 21:09 ` Emil Tsalapatis
2026-03-06 23:34 ` Daniel Jordan
2026-03-07 0:12 ` [PATCH v2 05/15] sched_ext: Relocate run_deferred() and its callees Tejun Heo
2026-03-06 19:06 ` [PATCH 06/15] sched_ext: Convert deferred_reenq_locals from llist to regular list Tejun Heo
2026-03-09 17:12 ` Emil Tsalapatis
2026-03-09 17:16 ` Emil Tsalapatis
2026-03-06 19:06 ` [PATCH 07/15] sched_ext: Wrap deferred_reenq_local_node into a struct Tejun Heo
2026-03-09 17:16 ` Emil Tsalapatis
2026-03-06 19:06 ` [PATCH 08/15] sched_ext: Introduce scx_bpf_dsq_reenq() for remote local DSQ reenqueue Tejun Heo
2026-03-09 17:33 ` Emil Tsalapatis
2026-03-06 19:06 ` [PATCH 09/15] sched_ext: Add reenq_flags plumbing to scx_bpf_dsq_reenq() Tejun Heo
2026-03-09 17:47 ` Emil Tsalapatis
2026-03-06 19:06 ` [PATCH 10/15] sched_ext: Add per-CPU data to DSQs Tejun Heo
2026-03-06 22:54 ` Andrea Righi
2026-03-06 22:56 ` Andrea Righi [this message]
2026-03-06 23:09 ` [PATCH v2 " Tejun Heo
2026-03-06 19:06 ` [PATCH 11/15] sched_ext: Factor out nldsq_cursor_next_task() and nldsq_cursor_lost_task() Tejun Heo
2026-03-06 19:06 ` [PATCH 12/15] sched_ext: Implement scx_bpf_dsq_reenq() for user DSQs Tejun Heo
2026-03-06 19:06 ` [PATCH 13/15] sched_ext: Optimize schedule_dsq_reenq() with lockless fast path Tejun Heo
2026-03-06 19:06 ` [PATCH 14/15] sched_ext: Simplify task state handling Tejun Heo
2026-03-06 19:06 ` [PATCH 15/15] sched_ext: Add SCX_TASK_REENQ_REASON flags Tejun Heo
2026-03-06 23:14 ` [PATCHSET sched_ext/for-7.1] sched_ext: Overhaul DSQ reenqueue infrastructure Andrea Righi
2026-03-07 15:38 ` Tejun Heo
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=aatbsAPM9J7fqHH3@gpd4 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox