* [PATCH] sched/core: Fix a missed update of user_cpus_ptr
@ 2023-02-03 18:18 Waiman Long
2023-02-03 21:04 ` Tejun Heo
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Waiman Long @ 2023-02-03 18:18 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, Will Deacon
Cc: Phil Auld, Tejun Heo, linux-kernel, Waiman Long
Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
cpumask"), a successful call to sched_setaffinity() should always save
the user requested cpu affinity mask in a task's user_cpus_ptr. However,
when the given cpu mask is the same as the current one, user_cpus_ptr
is not updated. Fix this by saving the user mask in this case too.
Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask")
Signed-off-by: Waiman Long <longman@redhat.com>
---
kernel/sched/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 30d9752e2ca5..91255f791df3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
}
if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
- if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
+ if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
+ if (ctx->flags & SCA_USER)
+ swap(p->user_cpus_ptr, ctx->user_mask);
goto out;
+ }
if (WARN_ON_ONCE(p == current &&
is_migration_disabled(p) &&
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] sched/core: Fix a missed update of user_cpus_ptr
2023-02-03 18:18 [PATCH] sched/core: Fix a missed update of user_cpus_ptr Waiman Long
@ 2023-02-03 21:04 ` Tejun Heo
2023-02-03 22:13 ` Waiman Long
2023-02-13 14:56 ` Peter Zijlstra
2023-02-15 10:33 ` [tip: sched/urgent] " tip-bot2 for Waiman Long
2 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2023-02-03 21:04 UTC (permalink / raw)
To: Waiman Long
Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, Will Deacon,
Phil Auld, linux-kernel
On Fri, Feb 03, 2023 at 01:18:49PM -0500, Waiman Long wrote:
> Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
> cpumask"), a successful call to sched_setaffinity() should always save
> the user requested cpu affinity mask in a task's user_cpus_ptr. However,
> when the given cpu mask is the same as the current one, user_cpus_ptr
> is not updated. Fix this by saving the user mask in this case too.
>
> Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
> kernel/sched/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 30d9752e2ca5..91255f791df3 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
> }
>
> if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
> - if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
> + if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
> + if (ctx->flags & SCA_USER)
> + swap(p->user_cpus_ptr, ctx->user_mask);
> goto out;
> + }
>
> if (WARN_ON_ONCE(p == current &&
> is_migration_disabled(p) &&
and this is for a separate bug and should go through the scheduler tree.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] sched/core: Fix a missed update of user_cpus_ptr
2023-02-03 21:04 ` Tejun Heo
@ 2023-02-03 22:13 ` Waiman Long
0 siblings, 0 replies; 5+ messages in thread
From: Waiman Long @ 2023-02-03 22:13 UTC (permalink / raw)
To: Tejun Heo
Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, Will Deacon,
Phil Auld, linux-kernel
On 2/3/23 16:04, Tejun Heo wrote:
> On Fri, Feb 03, 2023 at 01:18:49PM -0500, Waiman Long wrote:
>> Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
>> cpumask"), a successful call to sched_setaffinity() should always save
>> the user requested cpu affinity mask in a task's user_cpus_ptr. However,
>> when the given cpu mask is the same as the current one, user_cpus_ptr
>> is not updated. Fix this by saving the user mask in this case too.
>>
>> Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask")
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> kernel/sched/core.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 30d9752e2ca5..91255f791df3 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
>> }
>>
>> if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
>> - if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
>> + if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
>> + if (ctx->flags & SCA_USER)
>> + swap(p->user_cpus_ptr, ctx->user_mask);
>> goto out;
>> + }
>>
>> if (WARN_ON_ONCE(p == current &&
>> is_migration_disabled(p) &&
> and this is for a separate bug and should go through the scheduler tree.
Yes, this is for Peter to pick up.
Cheers,
Longman
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sched/core: Fix a missed update of user_cpus_ptr
2023-02-03 18:18 [PATCH] sched/core: Fix a missed update of user_cpus_ptr Waiman Long
2023-02-03 21:04 ` Tejun Heo
@ 2023-02-13 14:56 ` Peter Zijlstra
2023-02-15 10:33 ` [tip: sched/urgent] " tip-bot2 for Waiman Long
2 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2023-02-13 14:56 UTC (permalink / raw)
To: Waiman Long
Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, Will Deacon,
Phil Auld, Tejun Heo, linux-kernel
On Fri, Feb 03, 2023 at 01:18:49PM -0500, Waiman Long wrote:
> Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
> cpumask"), a successful call to sched_setaffinity() should always save
> the user requested cpu affinity mask in a task's user_cpus_ptr. However,
> when the given cpu mask is the same as the current one, user_cpus_ptr
> is not updated. Fix this by saving the user mask in this case too.
>
> Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
> kernel/sched/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 30d9752e2ca5..91255f791df3 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
> }
>
> if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
> - if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
> + if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
> + if (ctx->flags & SCA_USER)
> + swap(p->user_cpus_ptr, ctx->user_mask);
> goto out;
> + }
>
> if (WARN_ON_ONCE(p == current &&
> is_migration_disabled(p) &&
Indeed. Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread* [tip: sched/urgent] sched/core: Fix a missed update of user_cpus_ptr
2023-02-03 18:18 [PATCH] sched/core: Fix a missed update of user_cpus_ptr Waiman Long
2023-02-03 21:04 ` Tejun Heo
2023-02-13 14:56 ` Peter Zijlstra
@ 2023-02-15 10:33 ` tip-bot2 for Waiman Long
2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Waiman Long @ 2023-02-15 10:33 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Waiman Long, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: df14b7f9efcda35e59bb6f50351aac25c50f6e24
Gitweb: https://git.kernel.org/tip/df14b7f9efcda35e59bb6f50351aac25c50f6e24
Author: Waiman Long <longman@redhat.com>
AuthorDate: Fri, 03 Feb 2023 13:18:49 -05:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 13 Feb 2023 16:36:14 +01:00
sched/core: Fix a missed update of user_cpus_ptr
Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
cpumask"), a successful call to sched_setaffinity() should always save
the user requested cpu affinity mask in a task's user_cpus_ptr. However,
when the given cpu mask is the same as the current one, user_cpus_ptr
is not updated. Fix this by saving the user mask in this case too.
Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask")
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230203181849.221943-1-longman@redhat.com
---
kernel/sched/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e838feb..2a4918a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
}
if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
- if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
+ if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
+ if (ctx->flags & SCA_USER)
+ swap(p->user_cpus_ptr, ctx->user_mask);
goto out;
+ }
if (WARN_ON_ONCE(p == current &&
is_migration_disabled(p) &&
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-15 10:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 18:18 [PATCH] sched/core: Fix a missed update of user_cpus_ptr Waiman Long
2023-02-03 21:04 ` Tejun Heo
2023-02-03 22:13 ` Waiman Long
2023-02-13 14:56 ` Peter Zijlstra
2023-02-15 10:33 ` [tip: sched/urgent] " tip-bot2 for Waiman Long
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox