* [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork
@ 2024-09-05 9:04 Xuewen Yan
2024-09-05 12:42 ` Waiman Long
0 siblings, 1 reply; 5+ messages in thread
From: Xuewen Yan @ 2024-09-05 9:04 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, longman
Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel, ke.wang, di.shen, xuewen.yan94
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.
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f3951e4a55e5..2fbae00cd1dc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2666,7 +2666,7 @@ int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src,
* do_set_cpus_allowed().
*/
raw_spin_lock_irqsave(&src->pi_lock, flags);
- if (src->user_cpus_ptr) {
+ if (src->user_cpus_ptr && !src->sched_reset_on_fork) {
swap(dst->user_cpus_ptr, user_mask);
cpumask_copy(dst->user_cpus_ptr, src->user_cpus_ptr);
}
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork
2024-09-05 9:04 [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork Xuewen Yan
@ 2024-09-05 12:42 ` Waiman Long
2024-09-05 13:12 ` Phil Auld
0 siblings, 1 reply; 5+ messages in thread
From: Waiman Long @ 2024-09-05 12:42 UTC (permalink / raw)
To: Xuewen Yan, mingo, peterz, juri.lelli, vincent.guittot
Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel, ke.wang, di.shen, xuewen.yan94
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.
Cheers,
Longman
>
> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
> ---
> kernel/sched/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index f3951e4a55e5..2fbae00cd1dc 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2666,7 +2666,7 @@ int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src,
> * do_set_cpus_allowed().
> */
> raw_spin_lock_irqsave(&src->pi_lock, flags);
> - if (src->user_cpus_ptr) {
> + if (src->user_cpus_ptr && !src->sched_reset_on_fork) {
> swap(dst->user_cpus_ptr, user_mask);
> cpumask_copy(dst->user_cpus_ptr, src->user_cpus_ptr);
> }
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork
2024-09-05 12:42 ` Waiman Long
@ 2024-09-05 13:12 ` Phil Auld
2024-09-05 14:00 ` Waiman Long
0 siblings, 1 reply; 5+ messages in thread
From: Phil Auld @ 2024-09-05 13:12 UTC (permalink / raw)
To: Waiman Long
Cc: Xuewen Yan, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel, ke.wang, di.shen, xuewen.yan94
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.
Cheers,
Phil
> Cheers,
> Longman
>
> >
> > Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
> > ---
> > kernel/sched/core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index f3951e4a55e5..2fbae00cd1dc 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -2666,7 +2666,7 @@ int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src,
> > * do_set_cpus_allowed().
> > */
> > raw_spin_lock_irqsave(&src->pi_lock, flags);
> > - if (src->user_cpus_ptr) {
> > + if (src->user_cpus_ptr && !src->sched_reset_on_fork) {
> > swap(dst->user_cpus_ptr, user_mask);
> > cpumask_copy(dst->user_cpus_ptr, src->user_cpus_ptr);
> > }
>
>
--
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork
2024-09-05 13:12 ` Phil Auld
@ 2024-09-05 14:00 ` Waiman Long
2024-09-05 14:09 ` Phil Auld
0 siblings, 1 reply; 5+ messages in thread
From: Waiman Long @ 2024-09-05 14:00 UTC (permalink / raw)
To: Phil Auld
Cc: Xuewen Yan, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel, ke.wang, di.shen, xuewen.yan94
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork
2024-09-05 14:00 ` Waiman Long
@ 2024-09-05 14:09 ` Phil Auld
0 siblings, 0 replies; 5+ messages in thread
From: Phil Auld @ 2024-09-05 14:09 UTC (permalink / raw)
To: Waiman Long
Cc: Xuewen Yan, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel, ke.wang, di.shen, xuewen.yan94
On Thu, Sep 05, 2024 at 10:00:36AM -0400 Waiman Long wrote:
>
> 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.
>
No, you were clear. I was just providing my opinion, weighing in :)
Cheers,
Phil
> Cheers,
> Longman
>
--
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-05 14:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-05 9:04 [RFC PATCH] sched: Do not copy user_cpus_ptr when parent is reset_on_fork Xuewen Yan
2024-09-05 12:42 ` Waiman Long
2024-09-05 13:12 ` Phil Auld
2024-09-05 14:00 ` Waiman Long
2024-09-05 14:09 ` Phil Auld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®