All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Mike Galbraith <efault@gmx.de>, Ingo Molnar <mingo@elte.hu>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>
Subject: Re: [RFC PATCH] kernel: sched: Provide a pointer to the valid CPU mask
Date: Thu, 6 Apr 2017 10:01:39 +0200	[thread overview]
Message-ID: <20170406080139.GA22069@gmail.com> (raw)
In-Reply-To: <20170406073832.e7bu4ldpfuq44ui6@linutronix.de>


* Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> On 2017-04-06 08:16:22 [+0200], Ingo Molnar wrote:
> > 
> > * Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> > 
> > > On 2017-04-05 09:39:43 [+0200], Ingo Molnar wrote:
> > > > 
> > > > So maybe we could add the following facility:
> > > > 
> > > > 	ptr = sched_migrate_to_cpu_save(cpu);
> > > > 
> > > > 	...
> > > > 
> > > > 	sched_migrate_to_cpu_restore(ptr);
> > 
> > BTW., and I'm sure this has come up before, but why doesn't migrate_disable() use 
> > a simple per task flag that the scheduler migration code takes into account?
> 
> we could add that. But right now there are two spots which look at the
> counter to decide whether or not migration is disabled.
> 
> > It should be functionally equivalent to the current solution, and it appears to 
> > have a heck of a smaller cross section with the rest of the scheduler.
> > 
> > I.e.:
> > 
> > 	static inline void migrate_disable(void)
> > 	{
> > 		current->migration_disabled++;
> > 	}
> > 
> > 	...
> > 
> > 	static inline void migrate_enable(void)
> > 	{
> > 		current->migration_disabled--;
> > 	}
> > 
> > or so? Then add this flag as a condition to can_migrate_task() et al.
> > 
> > While we generally dislike such flags as they wreck havoc with the scheduler if 
> > overused, the cpus_allowed based solution has the exact same effect so it's not 
> > like it's a step backwards - and it should also be much faster and less intrusive.
> 
> So you are saying that we drop the cpus_ptr + cpus_mask fields again and
> instead add a task-flag to ensure that the scheduler does not migrate
> the task to another CPU?

Yeah - but no need to add a per-task flag if we already have a counter.

> > Am I missing some complication?
> 
> We do have the counter. We have need to ensure that the CPU is not going away 
> while we are in a migrate_disable() region since we can be scheduled out. So the 
> CPU can't go offline until we leave that region.

Yeah. But it should be relatively straightforward to extend the logic that makes 
sure that a CPU does not go away from under tasks pinned to that CPU alone, right?

> #define migrate_disable()	sched_migrate_to_cpu_save(-1)
> 
> int sched_migrate_to_cpu_save(int cpu)

So if we have a ->migration_disabled counter then we don't need the 
sched_migrate_to_cpu_save()/restore() complication, right?

Sorry if this is a back and forth - I was somehow convinced that we do need to 
frob the cpus_allowed mask to get this functionality - but in hindsight I think 
the counter should be enough.

I.e. just have a counter and these two APIs:

        static inline void migrate_disable(void)
        {
                current->migration_disabled++;
        }

        ...

        static inline void migrate_enable(void)
        {
                current->migration_disabled--;
        }

... and make sure the scheduler migration code plus the CPU hotplug code considers 
the counter.

Would this work, and would this be the simplest all around solution?

Thanks,

	Ingo

  reply	other threads:[~2017-04-06  8:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 18:42 [RFC PATCH] kernel: sched: Provide a pointer to the valid CPU mask Sebastian Andrzej Siewior
2017-04-05  7:39 ` Ingo Molnar
2017-04-05  8:37   ` Sebastian Andrzej Siewior
2017-04-06  6:16     ` Ingo Molnar
2017-04-06  7:38       ` Sebastian Andrzej Siewior
2017-04-06  8:01         ` Ingo Molnar [this message]
2017-04-06  9:25           ` Sebastian Andrzej Siewior
2017-04-06  9:46             ` Peter Zijlstra
2017-04-06 10:58               ` Thomas Gleixner
2017-04-06 11:41                 ` Peter Zijlstra
2017-04-06  9:35           ` Peter Zijlstra
2017-04-06  9:42             ` Peter Zijlstra
2017-04-06 10:36           ` Thomas Gleixner
2017-04-06 11:02             ` Ingo Molnar
2017-04-06 11:10               ` Thomas Gleixner
2017-04-07  7:13                 ` Ingo Molnar
2017-04-06  9:34   ` Peter Zijlstra
2017-04-06  9:32 ` Peter Zijlstra
2017-04-06  9:46   ` Sebastian Andrzej Siewior
2017-04-06 10:35     ` Peter Zijlstra
2017-04-06 10:47       ` Thomas Gleixner
2017-04-06 10:57         ` Peter Zijlstra
2017-04-06 11:03           ` Thomas Gleixner
2017-04-06 11:50             ` Peter Zijlstra
2017-04-06 11:56               ` Thomas Gleixner
2017-04-06 12:31                 ` Peter Zijlstra
2017-04-11  1:38 ` [lkp-robot] [kernel] c1f943ee40: kernel_BUG_at_kernel/smpboot.c kernel test robot
2017-04-11  1:38   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170406080139.GA22069@gmail.com \
    --to=mingo@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.