Re: [PATCH 01/16] sched_ext: Exit early on hotplug events during attach

From: Andrea Righi
Date: Wed Sep 03 2025 - 17:41:04 EST


On Wed, Sep 03, 2025 at 09:44:32AM -1000, Tejun Heo wrote:
> Hello,
>
> On Wed, Sep 03, 2025 at 11:33:27AM +0200, Andrea Righi wrote:
> > static int validate_ops(struct scx_sched *sch, const struct sched_ext_ops *ops)
> > @@ -5627,11 +5630,15 @@ 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);
> > - scx_idle_update_selcpu_topology(ops);
> > + ret = check_hotplug_seq(sch, ops);
> > + if (!ret)
> > + scx_idle_update_selcpu_topology(ops);
> >
> > cpus_read_unlock();
> >
> > + if (ret)
> > + goto err_disable;
>
> The double testing is a bit jarring. Maybe just add cpus_read_unlock() in
> the error block so that error return can take place right after
> check_hotplug_seq()? Alternatively, create a new error jump target - e.g.
> err_disable_unlock_cpus and share it between here and the init failure path?

Makes sense, I'll adjust this in the next version.

Actually, this patch doesn't necessarily need to be part of this series,
I'll probably submit it separately.

Thanks,
-Andrea