Re: [PATCH] sched: cgroup: Move task_can_attach() to cpuset.c

From: Andrea Righi
Date: Fri Oct 03 2025 - 12:54:26 EST


On Fri, Oct 03, 2025 at 12:43:00PM -0400, Steven Rostedt wrote:
...
> > > +static inline int task_can_attach(struct task_struct *p)
> > > +{
> > > + int ret = 0;
> > > +
> > > + /*
> > > + * Kthreads which disallow setaffinity shouldn't be moved
> > > + * to a new cpuset; we don't want to change their CPU
> > > + * affinity and isolating such threads by their set of
> > > + * allowed nodes is unnecessary. Thus, cpusets are not
> > > + * applicable for such threads. This prevents checking for
> > > + * success of set_cpus_allowed_ptr() on all attached tasks
> > > + * before cpus_mask may be changed.
> > > + */
> > > + if (p->flags & PF_NO_SETAFFINITY)
> > > + ret = -EINVAL;
> > > +
> > > + return ret;
> >
> > As we're cleaning up, we could just return -EINVAL and 0 directly and get
> > rid of that ret variable.
>
> That should be a separate patch. Moves should really not do much else. I
> even wondered about making it a static inline too, but figured that wasn't
> touching the logic, and the function was going to become static anyway.

Oh yes, good point. In the meantime, FWIW:

Tested-by: Andrea Righi <arighi@xxxxxxxxxx>

Thanks,
-Andrea