From: Qiliang Yuan <realwujing@gmail.com>
To: arighi@nvidia.com
Cc: bsegall@google.com, changwoo@igalia.com, david.dai@linux.dev,
dietmar.eggemann@arm.com, emil@etsalapatis.com,
jake@hillion.co.uk, juri.lelli@redhat.com,
linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com,
newton@meta.com, peterz@infradead.org, realwujing@gmail.com,
rostedt@goodmis.org, schatzberg.dan@gmail.com,
sched-ext@lists.linux.dev, suzhidao@xiaomi.com, tj@kernel.org,
vincent.guittot@linaro.org, void@manifault.com,
vschneid@redhat.com, yuanql9@chinatelecom.cn
Subject: Re: [PATCH] sched/ext: Add cpumask to skip unsuitable dispatch queues
Date: Wed, 4 Feb 2026 04:41:58 -0500 [thread overview]
Message-ID: <20260204094202.3917675-1-realwujing@gmail.com> (raw)
In-Reply-To: <aYGzumDW2sQ8xQSD@gpd4>
Hi Andrea, I have fixed those issues in v2:
https://lore.kernel.org/all/20260204093435.3915393-1-realwujing@gmail.com/
On Tue, Feb 03, 2026 at 09:37:14AM +0100, Andrea Righi wrote:
> Did you run some benchmarks / have some numbers?
I'm working on collecting more detailed benchmark numbers. However, theoretically,
the bitwise cpumask_or() should be much cheaper than a DSQ scan that results in
multiple cache misses during task structure dereferencing, even for small queues.
> It's true that we save the O(N) scan when the DSQ has no eligible tasks, but we're
> adding cost on every enqueue: cpumask_or() on potentially large cpumasks can be
> expensive.
> ... for small queues or mixed workloads, the cpumask overhead probably exceeds
> the savings...
To minimize the enqueue overhead, I've optimized the dispatch_enqueue() path in v2:
- Use cpumask_copy() instead of cpumask_or() when the task is the first one in the DSQ.
- Skip the cpumask_or() update if the DSQ's cpus_allowed mask is already full.
> The cpumask is only updated during enqueue and cleared when the queue empties. If a
> task's affinity changes while it's already in the queue (i.e., sched_setaffinity()),
> the cpus_allowed mask becomes stale.
Fixed in v2. I've added a hook in set_cpus_allowed_scx() to update the DSQ's
cpus_allowed mask whenever a task's affinity changes while it is enqueued in a DSQ.
> I don't see the corresponding kfree() in the cleanup path.
Fixed in v2. I've added an RCU callback (free_dsq_rcu_callback) to explicitly free
dsq->cpus_allowed before freeing the DSQ structure itself.
Also, I've restricted the cpumask allocation to user-defined DSQs only, as built-in
DSQs (local, global, bypass) don't need this optimization.
Thanks,
Qiliang
prev parent reply other threads:[~2026-02-04 11:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 3:03 [PATCH] sched/ext: Add cpumask to skip unsuitable dispatch queues Qiliang Yuan
2026-02-03 8:37 ` Andrea Righi
2026-02-04 9:41 ` Qiliang Yuan [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=20260204094202.3917675-1-realwujing@gmail.com \
--to=realwujing@gmail.com \
--cc=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=david.dai@linux.dev \
--cc=dietmar.eggemann@arm.com \
--cc=emil@etsalapatis.com \
--cc=jake@hillion.co.uk \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=newton@meta.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=schatzberg.dan@gmail.com \
--cc=sched-ext@lists.linux.dev \
--cc=suzhidao@xiaomi.com \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.com \
--cc=yuanql9@chinatelecom.cn \
/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