public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: sched: Provide migrate_disable/enable() inlines
Date: Sun, 9 Feb 2020 20:08:27 +0100	[thread overview]
Message-ID: <20200209190827.GA100648@gmail.com> (raw)
In-Reply-To: <878slclv1u.fsf@nanos.tec.linutronix.de>


* Thomas Gleixner <tglx@linutronix.de> wrote:

> Code which solely needs to prevent migration of a task uses
> preempt_disable()/enable() pairs. This is the only reliable way to do so
> as setting the task affinity to a single CPU can be undone by a
> setaffinity operation from a different task/process.
> 
> RT provides a seperate migrate_disable/enable() mechanism which does not
> disable preemption to achieve the semantic requirements of a (almost) fully
> preemptible kernel.
> 
> As it is unclear from looking at a given code path whether the intention is
> to disable preemption or migration, introduce migrate_disable/enable()
> inline functions which can be used to annotate code which merely needs to
> disable migration. Map them to preempt_disable/enable() for now. The RT
> substitution will be provided later.
> 
> Code which is annotated that way documents that it has no requirement to
> protect against reentrancy of a preempting task. Either this is not
> required at all or the call sites are already serialized by other means.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Juri Lelli <juri.lelli@redhat.com>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ben Segall <bsegall@google.com>
> Cc: Mel Gorman <mgorman@suse.de>
> ---
>  include/linux/preempt.h |   30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> --- a/include/linux/preempt.h
> +++ b/include/linux/preempt.h
> @@ -322,4 +322,34 @@ static inline void preempt_notifier_init
>  
>  #endif
>  
> +/**
> + * migrate_disable - Prevent migration of the current task
> + *
> + * Maps to preempt_disable() which also disables preemption. Use
> + * migrate_disable() to annotate that the intent is to prevent migration
> + * but not necessarily preemption.
> + *
> + * Can be invoked nested like preempt_disable() and needs the corresponding
> + * number of migrate_enable() invocations.
> + */
> +static __always_inline void migrate_disable(void)
> +{
> +	preempt_disable();
> +}
> +
> +/**
> + * migrate_enable - Allow migration of the current task
> + *
> + * Counterpart to migrate_disable().
> + *
> + * As migrate_disable() can be invoked nested only the uttermost invocation
> + * reenables migration.
> + *
> + * Currently mapped to preempt_enable().
> + */
> +static __always_inline void migrate_enable(void)
> +{
> +	preempt_enable();
> +}

I've applied this with s/uttermost/outermost, which I suspect was the 
intention?

Thanks,

	Ingo

  reply	other threads:[~2020-02-09 19:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-08 19:48 sched: Provide migrate_disable/enable() inlines Thomas Gleixner
2020-02-09 19:08 ` Ingo Molnar [this message]
2020-02-09 19:11 ` [tip: sched/core] sched/rt: " tip-bot2 for Thomas Gleixner
2020-02-20 20:20 ` [tip: sched/rt] " tip-bot2 for Thomas Gleixner

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=20200209190827.GA100648@gmail.com \
    --to=mingo@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox