]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
sched_ext: Relocate check_hotplug_seq() call in scx_ops_enable()
authorTejun Heo <tj@kernel.org>
Fri, 27 Sep 2024 20:02:39 +0000 (10:02 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 27 Sep 2024 20:02:39 +0000 (10:02 -1000)
check_hotplug_seq() is used to detect CPU hotplug event which occurred while
the BPF scheduler is being loaded so that initialization can be retried if
CPU hotplug events take place before the CPU hotplug callbacks are online.

As such, the best place to call it is in the same cpu_read_lock() section
that enables the CPU hotplug ops. Currently, it is called in the next
cpus_read_lock() block in scx_ops_enable(). The side effect of this
placement is a small window in which hotplug sequence detection can trigger
unnecessarily, which isn't critical.

Move check_hotplug_seq() invocation to the same cpus_read_lock() block as
the hotplug operation enablement to close the window and get the invocation
out of the way for planned locking updates.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>
kernel/sched/ext.c

index d6f6bf6caecc8b59095cf3a5986f56e850d12641..e8ab7e5ee2dde4a521bc532e3aa98b39c4e74dc4 100644 (file)
@@ -5050,6 +5050,7 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
                if (((void (**)(void))ops)[i])
                        static_branch_enable_cpuslocked(&scx_has_op[i]);
 
+       check_hotplug_seq(ops);
        cpus_read_unlock();
 
        ret = validate_ops(ops);
@@ -5098,8 +5099,6 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
        cpus_read_lock();
        scx_cgroup_lock();
 
-       check_hotplug_seq(ops);
-
        for (i = SCX_OPI_NORMAL_BEGIN; i < SCX_OPI_NORMAL_END; i++)
                if (((void (**)(void))ops)[i])
                        static_branch_enable_cpuslocked(&scx_has_op[i]);