Re: [PATCH] sched: Fix PF_NO_SETAFFINITY blind inheritance

From: Valentin Schneider
Date: Wed May 26 2021 - 06:10:23 EST



Hi Frederic,

Sorry about that one; thanks for having dug into it.

On 26/05/21 01:58, Frederic Weisbecker wrote:
> One way to solve the PF_NO_SETAFFINITY issue is to not inherit this flag
> on copy_process() at all. The cases where it matters are:
>
> * fork_idle(): explicitly set the flag already.
> * fork() syscalls: userspace tasks that shouldn't be concerned by that.
> * create_io_thread(): the callers explicitly attribute the flag to the
> newly created tasks.
> * kernel_thread():
> _ Fix the issues on init/1 and kthreadd
> _ Fix the issues on kthreadd children.
> _ Usermode helper created by an unbound workqueue. This shouldn't
> matter. In the worst case it gives more control to userspace
> on setting affinity to these short living tasks although this can
> be tuned with inherited unbound workqueues affinity already.
>

(I just saw it got shoved into tip already, but in any case:)

That makes sense to me. Regarding the UMH point, I don't believe there are
others like it creeping around; otherwise we might've had to go with e.g.

p->flags &= ~(... | (PF_NO_SETAFFINITY * !!(p->flags & PF_IDLE)))

but per the above that doesn't seem necessary.

Reviewed-by: Valentin Schneider <valentin.schneider@xxxxxxx>