]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Disallow loading BPF scheduler if isolcpus= domain isolation is in effect
authorTejun Heo <tj@kernel.org>
Thu, 27 Jun 2024 01:27:02 +0000 (15:27 -1000)
committerTejun Heo <tj@kernel.org>
Mon, 8 Jul 2024 19:30:13 +0000 (09:30 -1000)
sched_domains regulate the load balancing for sched_classes. A machine can
be partitioned into multiple sections that are not load-balanced across
using either isolcpus= boot param or cpuset partitions. In such cases, tasks
that are in one partition are expected to stay within that partition.

cpuset configured partitions are always reflected in each member task's
cpumask. As SCX always honors the task cpumasks, the BPF scheduler is
automatically in compliance with the configured partitions.

However, for isolcpus= domain isolation, the isolated CPUs are simply
omitted from the top-level sched_domain[s] without further restrictions on
tasks' cpumasks, so, for example, a task currently running in an isolated
CPU may have more CPUs in its allowed cpumask while expected to remain on
the same CPU.

There is no straightforward way to enforce this partitioning preemptively on
BPF schedulers and erroring out after a violation can be surprising.
isolcpus= domain isolation is being replaced with cpuset partitions anyway,
so keep it simple and simply disallow loading a BPF scheduler if isolcpus=
domain isolation is in effect.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20240626082342.GY31592@noisy.programming.kicks-ass.net
Cc: David Vernet <void@manifault.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
kernel/sched/build_policy.c
kernel/sched/ext.c

index 9223c49ddcf362ed6c414943c775f5713b99bd8f..fae1f5c921eb370dfbff0317dcf102a352d864a9 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/sched/clock.h>
 #include <linux/sched/cputime.h>
 #include <linux/sched/hotplug.h>
+#include <linux/sched/isolation.h>
 #include <linux/sched/posix-timers.h>
 #include <linux/sched/rt.h>
 
index 3eb7169e3973dc9ce9ac7b1c4e322524cf11dbf5..406b05a4d866e045f8228bbd2b814e9b5ef5b6d9 100644 (file)
@@ -4399,6 +4399,12 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
        unsigned long timeout;
        int i, cpu, ret;
 
+       if (!cpumask_equal(housekeeping_cpumask(HK_TYPE_DOMAIN),
+                          cpu_possible_mask)) {
+               pr_err("sched_ext: Not compatible with \"isolcpus=\" domain isolation");
+               return -EINVAL;
+       }
+
        mutex_lock(&scx_ops_enable_mutex);
 
        if (!scx_ops_helper) {