Re: [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork

From: Waiman Long
Date: Thu Sep 05 2024 - 10:01:02 EST



On 9/5/24 09:12, Phil Auld wrote:
On Thu, Sep 05, 2024 at 08:42:33AM -0400 Waiman Long wrote:
On 9/5/24 05:04, Xuewen Yan wrote:
Now, the task's user_cpus_ptr would dup from parent's user_cpus_ptr.
It is better reset the user_cpus_ptr when parent's reset_on_fork
is set.
According to sched(7):

       Each thread has a reset-on-fork scheduling flag.  When this flag
       is set, children created by fork(2) do not inherit privileged
       scheduling policies.

It can be argued what are considered privileged scheduling policies. AFAICS,
a restricted affinity doesn't seem to be a "privileged" scheduling policy.
That is my own opinion strictly from the definition point of view, I will
let others weigh in on that and I am OK to go either way.

I think that one could argue that clearing a restricted affinity is
increasing the privilege and not preventing inheritence of same.
i.e. it would be the opposite of what reset-on-fork means.

I'd say NAK to this one if I had that power.

Maybe I am not clear enough in my previous mail. My position is the same as yours. I think this patch is not necessary. More reasons should be provided as to why it is right to not inherited the restricted affinity when reset-on-fork flag is reset.

Cheers,
Longman