Sched_ext development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 2/3] sched_ext: Track bits[] storage size in struct scx_cmask
Date: Sun, 17 May 2026 18:50:46 +0000	[thread overview]
Message-ID: <20260517185046.D2E5FC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260517181022.1184056-3-tj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The per-CPU `scx_set_cmask_scratch` variable is never initialized, causing `scx_cpumask_to_cmask()` to silently pass empty CPU masks to the BPF scheduler.
--

commit c63d115e3f87dfb00acdde042926edb85a5907eb
Author: Tejun Heo <tj@kernel.org>

sched_ext: Track bits[] storage size in struct scx_cmask

This commit adds an alloc_words field to struct scx_cmask to track the
allocation size of the bits[] array, and splits the bit-range API into 
initialization, reframing, and clearing helpers.

> diff --git a/kernel/sched/ext_cid.c b/kernel/sched/ext_cid.c
> index bdd8ef8eae3dc..f50319c5c65e1 100644
> --- a/kernel/sched/ext_cid.c
> +++ b/kernel/sched/ext_cid.c

[ ... ]

> @@ -275,10 +275,10 @@ void scx_cpumask_to_cmask(const struct cpumask *src, struct scx_cmask *dst)
>  {
>  	s32 cpu;
>  
> -	scx_cmask_init(dst, 0, num_possible_cpus());
> +	scx_cmask_clear(dst);

Can this regression cause scx_cpumask_to_cmask() to generate empty masks
when dst is scx_set_cmask_scratch?

Since scx_set_cmask_scratch is allocated zero-filled, its nr_cids defaults
to 0.

With scx_cmask_init() removed here, if scx_set_cmask_scratch is passed as
dst without being initialized elsewhere, scx_cmask_clear() will see
!dst->nr_cids and return immediately doing nothing.

The subsequent loop then calls __scx_cmask_set(dst, cid) for each CPU.
Because __scx_cmask_contains() evaluates to cid >= 0 && cid < 0, which is
always false, no bits are ever set.

Could this result in the BPF scheduler receiving an empty cmask for
operations like set_cpumask?

>  	for_each_cpu(cpu, src) {
>  		s32 cid = __scx_cpu_to_cid(cpu);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260517181022.1184056-1-tj@kernel.org?part=2

  reply	other threads:[~2026-05-17 18:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-17 18:10 [PATCHSET v2 INTERNAL] bpf/arena: Direct kernel-side access Tejun Heo
2026-05-17 18:10 ` [PATCH 1/3] sched_ext: Rename scx_cmask.nr_bits to nr_cids Tejun Heo
2026-05-17 18:20   ` sashiko-bot
2026-05-17 18:10 ` [PATCH 2/3] sched_ext: Track bits[] storage size in struct scx_cmask Tejun Heo
2026-05-17 18:50   ` sashiko-bot [this message]
2026-05-17 18:10 ` [PATCH 3/3] sched_ext: Add cmask mask ops Tejun Heo
2026-05-17 18:11 ` [PATCHSET v2 INTERNAL] bpf/arena: Direct kernel-side access Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2026-05-17 18:36 [PATCHSET RESEND sched_ext/for-7.2] sched_ext: cmask improvements Tejun Heo
2026-05-17 18:36 ` [PATCH 2/3] sched_ext: Track bits[] storage size in struct scx_cmask Tejun Heo
2026-05-17 19:14   ` sashiko-bot

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=20260517185046.D2E5FC2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    /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