From: Tejun Heo <tj@kernel.org>
To: Tianyi Chen <hi@tychen.cc>
Cc: tj@kernel.org, David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>, Shuah Khan <shuah@kernel.org>,
sched-ext@lists.linux.dev, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Emil Tsalapatis <emil@etsalapatis.com>
Subject: Re: [PATCH] selftests/sched_ext: Validate select_cpu_and mask constraints
Date: Tue, 08 Sep 2026 08:01:34 -1000 [thread overview]
Message-ID: <53d04980eecb0e5f6eeea25a5cf0dcf5@kernel.org> (raw)
In-Reply-To: <20260906144029.848978-1-hi@tychen.cc>
Hello, Tianyi.
On Sun, Sep 06, 2026 at 10:40:29PM +0800, Tianyi Chen wrote:
> + if (cpu >= 0 &&
> + (!bpf_cpumask_test_cpu(cpu, cast_mask(mask)) ||
> + !bpf_cpumask_test_cpu(cpu, p->cpus_ptr)))
> + cpu = -ERANGE;
The syscall runs with migration disabled. With CONFIG_PREEMPT_RCU,
preemption between selection and this check can make
migrate_disable_switch() narrow p->cpus_ptr to the running CPU, rejecting a
valid selection on another CPU. Please check the requested affinity instead.
> + SCX_FAIL_IF(sched_getaffinity(0, sizeof(original), &original),
> + "Failed to get affinity (%d)", errno);
Please use dynamically allocated masks. The fixed cpu_set_t makes
sched_getaffinity() fail with EINVAL when nr_cpu_ids exceeds 1024, even if
the task only uses low-numbered CPUs.
Thanks.
--
tejun
prev parent reply other threads:[~2026-09-08 18:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 14:40 [PATCH] selftests/sched_ext: Validate select_cpu_and mask constraints Tianyi Chen
2026-09-08 18:01 ` Tejun Heo [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=53d04980eecb0e5f6eeea25a5cf0dcf5@kernel.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--cc=hi@tychen.cc \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--cc=shuah@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.