From: Tejun Heo <tj@kernel.org>
To: Vishal Chourasia <vishalc@linux.ibm.com>
Cc: David Vernet <void@manifault.com>, linux-kernel@vger.kernel.org
Subject: Re: sched_ext/for-6.11: cpu validity check in ops_cpu_valid
Date: Sun, 14 Jul 2024 19:17:32 -1000 [thread overview]
Message-ID: <ZpSw7PvW1Teh6tNV@slm.duckdns.org> (raw)
In-Reply-To: <ZpLSEHskvXXv4EoR@linux.ibm.com>
Hello, Vishal.
On Sun, Jul 14, 2024 at 12:44:24AM +0530, Vishal Chourasia wrote:
> Currently, the BPF scheduler can return a CPU that is marked as possible
> in the system configurations, but this doesn't guarantee that the CPU is
> actually present or online at the time. This behavior can lead to
> scenarios where the scheduler attempts to assign tasks to CPUs that are
> not available, causing the fallback mechanism to activate and
> potentially leading to an uneven load distribution across the system.
ops.select_cpu() is allowed to return any CPU and then the scheduler will
pick a fallback CPU. This is mostly because that's how
sched_class->select_task_rq() behaves. Here, SCX is just inheriting the
behavior.
Dispatching to foreign local DSQ using SCX_DSQ_LOCAL_ON also does
auto-fallback. This is because it's difficult for the BPF scheduler to
strongly synchronize its dispatch operation against CPU hotplug operations.
> By defalut, When a "not possible" CPU is returned, sched_ext gracefully
> exits the bpf scheduler.
>
> static bool ops_cpu_valid(s32 cpu, const char *where)
> {
> if (likely(cpu >= 0 && cpu < nr_cpu_ids && cpu_possible(cpu))) {
> return true;
> } else {
> scx_ops_error("invalid CPU %d%s%s", cpu,
> where ? " " : "", where ?: "");
> return false;
> }
> }
>
> On POWER, a system can have differences in cpu_present and cpu_possible
> mask. Not present, but possible CPUs can be added later but once added
> will also be marked set in the cpu present mask.
>
> Looks like cpu_present() is a better check.
We can consider tightening each path separately but I'm not sure making
ops_cpu_valid() more strict is a good idea. For example, there's no reason
to abort because a scheduler is calling scx_bpf_dsq_nr_queued() on an
offline CPU especially given that the kfunc is allowed from any context
without any synchronization. It can create aborting bugs which are really
difficult to reproduce.
Thanks.
--
tejun
next prev parent reply other threads:[~2024-07-15 5:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-13 19:14 Vishal Chourasia
2024-07-15 5:17 ` Tejun Heo [this message]
2024-07-16 6:49 ` Vishal Chourasia
2024-07-16 21:44 ` Tejun Heo
2024-07-17 7:59 ` Vishal Chourasia
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=ZpSw7PvW1Teh6tNV@slm.duckdns.org \
--to=tj@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishalc@linux.ibm.com \
--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
all inboxes | Powered by JetHome®