linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 4/7] preempt: Disable preemption from preempt_schedule*() callers
Date: Mon, 11 May 2015 17:51:25 +0200	[thread overview]
Message-ID: <20150511155125.GX21418@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1431356904-4624-5-git-send-email-fweisbec@gmail.com>

On Mon, May 11, 2015 at 05:08:21PM +0200, Frederic Weisbecker wrote:
> Lets gather the preempt operations (set PREEMPT_ACTIVE and disable
> preemption) in a single operation. This way we prepare to remove the
> preemption disablement in __schedule() in order to omptimize this
> duty on the caller.
> 
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
>  include/linux/preempt.h | 12 ++++++++++++
>  kernel/sched/core.c     | 20 ++++++--------------
>  2 files changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/preempt.h b/include/linux/preempt.h
> index 4689ef2..45da394 100644
> --- a/include/linux/preempt.h
> +++ b/include/linux/preempt.h
> @@ -137,6 +137,18 @@ extern void preempt_count_sub(int val);
>  #define preempt_count_inc() preempt_count_add(1)
>  #define preempt_count_dec() preempt_count_sub(1)
>  
> +#define preempt_active_enter() \
> +do { \
> +	preempt_count_add(PREEMPT_ACTIVE + PREEMPT_DISABLE_OFFSET); \
> +	barrier(); \
> +} while (0)
> +
> +#define preempt_active_exit() \
> +do { \
> +	barrier(); \
> +	preempt_count_sub(PREEMPT_ACTIVE + PREEMPT_DISABLE_OFFSET); \
> +} while (0)
> +
>  #ifdef CONFIG_PREEMPT_COUNT
>  
>  #define preempt_disable() \
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 8027cfd..182127a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2859,15 +2859,14 @@ void __sched schedule_preempt_disabled(void)
>  static void __sched notrace preempt_schedule_common(void)
>  {
>  	do {
> -		__preempt_count_add(PREEMPT_ACTIVE);
> +		preempt_active_enter();
>  		__schedule();
> -		__preempt_count_sub(PREEMPT_ACTIVE);
> +		preempt_active_exit();
>  
>  		/*
>  		 * Check again in case we missed a preemption opportunity
>  		 * between schedule and now.
>  		 */
> -		barrier();
>  	} while (need_resched());
>  }

So this patch adds a level of preempt_disable; I suspect the goal is to
remove the preempt_disable() inside __schedule(), but as it stands this
patch is broken, no?

  reply	other threads:[~2015-05-11 15:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 15:08 [RFC PATCH 0/7] preempt: A few headers cleanups and preempt_schedule*() optimizations Frederic Weisbecker
2015-05-11 15:08 ` [PATCH 1/7] preempt: Merge preempt_mask.h into preempt.h Frederic Weisbecker
2015-05-11 15:08 ` [PATCH 2/7] preempt: Rearrange a few symbols after headers merge Frederic Weisbecker
2015-05-11 15:08 ` [PATCH 3/7] preempt: Rename PREEMPT_CHECK_OFFSET to PREEMPT_DISABLE_OFFSET Frederic Weisbecker
2015-05-11 15:08 ` [PATCH 4/7] preempt: Disable preemption from preempt_schedule*() callers Frederic Weisbecker
2015-05-11 15:51   ` Peter Zijlstra [this message]
2015-05-11 15:08 ` [PATCH 5/7] sched: Pull preemption disablement duty up to __schedule() callers Frederic Weisbecker
2015-05-11 15:52   ` Peter Zijlstra
2015-05-11 15:56     ` Frederic Weisbecker
2015-05-11 15:08 ` [PATCH 6/7] preempt: Fix out of date comment Frederic Weisbecker
2015-05-11 15:08 ` [PATCH 7/7] preempt: Remove PREEMPT_ACTIVE unmasking off in_atomic() Frederic Weisbecker

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=20150511155125.GX21418@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).