linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Don't migrate with src_cpu == dst_cpu
@ 2020-12-03  6:04 Scott Wood
  2020-12-03  8:47 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Wood @ 2020-12-03  6:04 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Vincent Guittot
  Cc: Dietmar Eggemann, Mel Gorman, linux-kernel, linux-rt-users,
	Sebastian Andrzej Siewior, Scott Wood

Besides being a waste of time to try to move tasks to where they already
are, this avoids triggering the WARN_ON_ONCE(is_migration_disabled(p))
in set_task_cpu().

Signed-off-by: Scott Wood <swood@redhat.com>
---
Patch is against tip/master.  Assertion was seen by running rteval on the
RT tree.

 kernel/sched/fair.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e7e21ac479a2..f443626164d4 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7574,7 +7574,8 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
 
 		/* Prevent to re-select dst_cpu via env's CPUs: */
 		for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) {
-			if (cpumask_test_cpu(cpu, p->cpus_ptr)) {
+			if (cpu != env->src_cpu &&
+			    cpumask_test_cpu(cpu, p->cpus_ptr)) {
 				env->flags |= LBF_DST_PINNED;
 				env->new_dst_cpu = cpu;
 				break;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/fair: Don't migrate with src_cpu == dst_cpu
  2020-12-03  6:04 [PATCH] sched/fair: Don't migrate with src_cpu == dst_cpu Scott Wood
@ 2020-12-03  8:47 ` Peter Zijlstra
  2020-12-07 10:21   ` Scott Wood
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2020-12-03  8:47 UTC (permalink / raw)
  To: Scott Wood
  Cc: Ingo Molnar, Vincent Guittot, Dietmar Eggemann, Mel Gorman,
	linux-kernel, linux-rt-users, Sebastian Andrzej Siewior

On Thu, Dec 03, 2020 at 12:04:49AM -0600, Scott Wood wrote:
> Besides being a waste of time to try to move tasks to where they already
> are, this avoids triggering the WARN_ON_ONCE(is_migration_disabled(p))
> in set_task_cpu().
> 
> Signed-off-by: Scott Wood <swood@redhat.com>
> ---
> Patch is against tip/master.  Assertion was seen by running rteval on the
> RT tree.
> 
>  kernel/sched/fair.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e7e21ac479a2..f443626164d4 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7574,7 +7574,8 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
>  
>  		/* Prevent to re-select dst_cpu via env's CPUs: */
>  		for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) {
> -			if (cpumask_test_cpu(cpu, p->cpus_ptr)) {
> +			if (cpu != env->src_cpu &&
> +			    cpumask_test_cpu(cpu, p->cpus_ptr)) {
>  				env->flags |= LBF_DST_PINNED;
>  				env->new_dst_cpu = cpu;
>  				break;

Do we have _any_ clue as to how we ended up in that situation? The above
sounds like it should be a WARN and we should avoid getting here in the
first place.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/fair: Don't migrate with src_cpu == dst_cpu
  2020-12-03  8:47 ` Peter Zijlstra
@ 2020-12-07 10:21   ` Scott Wood
  0 siblings, 0 replies; 3+ messages in thread
From: Scott Wood @ 2020-12-07 10:21 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Vincent Guittot, Dietmar Eggemann, Mel Gorman,
	linux-kernel, linux-rt-users, Sebastian Andrzej Siewior

On Thu, 2020-12-03 at 09:47 +0100, Peter Zijlstra wrote:
> On Thu, Dec 03, 2020 at 12:04:49AM -0600, Scott Wood wrote:
> > Besides being a waste of time to try to move tasks to where they already
> > are, this avoids triggering the WARN_ON_ONCE(is_migration_disabled(p))
> > in set_task_cpu().
> > 
> > Signed-off-by: Scott Wood <swood@redhat.com>
> > ---
> > Patch is against tip/master.  Assertion was seen by running rteval on
> > the
> > RT tree.
> > 
> >  kernel/sched/fair.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index e7e21ac479a2..f443626164d4 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -7574,7 +7574,8 @@ int can_migrate_task(struct task_struct *p, struct
> > lb_env *env)
> >  
> >  		/* Prevent to re-select dst_cpu via env's CPUs: */
> >  		for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) {
> > -			if (cpumask_test_cpu(cpu, p->cpus_ptr)) {
> > +			if (cpu != env->src_cpu &&
> > +			    cpumask_test_cpu(cpu, p->cpus_ptr)) {
> >  				env->flags |= LBF_DST_PINNED;
> >  				env->new_dst_cpu = cpu;
> >  				break;
> 
> Do we have _any_ clue as to how we ended up in that situation? The above
> sounds like it should be a WARN and we should avoid getting here in the
> first place.

My initial impression was that there simply wasn't anything stopping it from
happening, but digging deeper it looks like it's specific to NUMA domains
with overlapping CPUs.

-Scott



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-07 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03  6:04 [PATCH] sched/fair: Don't migrate with src_cpu == dst_cpu Scott Wood
2020-12-03  8:47 ` Peter Zijlstra
2020-12-07 10:21   ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).