diff options
| author | Andrea Righi <arighi@nvidia.com> | 2025-09-04 07:57:16 +0200 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2025-10-13 08:45:01 -1000 |
| commit | 0128c850513a7f5199397a79da9c39558a5558cb (patch) | |
| tree | 83c2ed75f21c979f2ff733309fe367bfe3b1a304 | |
| parent | 14c1da3895a116f4e32c20487046655f26d3999b (diff) | |
sched_ext: Exit early on hotplug events during attach
There is no need to complete the entire scx initialization if a
scheduler is failing to be attached due to a hotplug event.
Exit early to avoid unnecessary work and simplify the attach flow.
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
| -rw-r--r-- | kernel/sched/ext.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index c645d47124e7..9b2ab67951e6 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -4513,7 +4513,7 @@ err_free_sch: return ERR_PTR(ret); } -static void check_hotplug_seq(struct scx_sched *sch, +static int check_hotplug_seq(struct scx_sched *sch, const struct sched_ext_ops *ops) { unsigned long long global_hotplug_seq; @@ -4530,8 +4530,11 @@ static void check_hotplug_seq(struct scx_sched *sch, SCX_ECODE_ACT_RESTART | SCX_ECODE_RSN_HOTPLUG, "expected hotplug seq %llu did not match actual %llu", ops->hotplug_seq, global_hotplug_seq); + return -EBUSY; } } + + return 0; } static int validate_ops(struct scx_sched *sch, const struct sched_ext_ops *ops) @@ -4633,7 +4636,11 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link) if (((void (**)(void))ops)[i]) set_bit(i, sch->has_op); - check_hotplug_seq(sch, ops); + ret = check_hotplug_seq(sch, ops); + if (ret) { + cpus_read_unlock(); + goto err_disable; + } scx_idle_update_selcpu_topology(ops); cpus_read_unlock(); |
