From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965402AbcAUMyP (ORCPT ); Thu, 21 Jan 2016 07:54:15 -0500 Received: from www.linutronix.de ([62.245.132.108]:37608 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965132AbcAUMyJ convert rfc822-to-8bit (ORCPT ); Thu, 21 Jan 2016 07:54:09 -0500 Date: Thu, 21 Jan 2016 13:54:05 +0100 From: Sebastian Andrzej Siewior To: Mike Galbraith Cc: Thomas Gleixner , LKML , linux-rt-users Subject: Re: [rfc patch v4.4-rt2] sched: fix up preempt lazy forward port Message-ID: <20160121125405.GA11749@linutronix.de> References: <1453108103.4123.4.camel@gmail.com> <20160118201828.GE12309@linutronix.de> <1453170597.3740.7.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <1453170597.3740.7.camel@gmail.com> X-Key-Id: 2A8CF5D1 X-Key-Fingerprint: 6425 4695 FFF0 AA44 66CC 19E6 7B96 E816 2A8C F5D1 User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mike Galbraith | 2016-01-19 03:29:57 [+0100]: >> And this is a new piece. So you forbid that tasks leave the CPU if >> lazy_count > 0. Let me look closed why this is happening and if this is >> v4.1 … v4.4 or not. > >We should probably just add the lazy bits to preemptible(). Subject: preempt-lazy: Add the lazy-preemption check to preempt_schedule() Probably in the rebase onto v4.1 this check got moved into less commonly used preempt_schedule_notrace(). This patch ensures that both functions use it. Reported-by: Mike Galbraith Signed-off-by: Sebastian Andrzej Siewior --- kernel/sched/core.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3461,6 +3461,30 @@ static void __sched notrace preempt_sche } while (need_resched()); } +#ifdef CONFIG_PREEMPT_LAZY +/* + * If TIF_NEED_RESCHED is then we allow to be scheduled away since this is + * set by a RT task. Oterwise we try to avoid beeing scheduled out as long as + * preempt_lazy_count counter >0. + */ +static int preemptible_lazy(void) +{ + if (test_thread_flag(TIF_NEED_RESCHED)) + return 1; + if (current_thread_info()->preempt_lazy_count) + return 0; + return 1; +} + +#else + +static int preemptible_lazy(void) +{ + return 1; +} + +#endif + #ifdef CONFIG_PREEMPT /* * this is the entry point to schedule() from in-kernel preemption @@ -3475,6 +3499,8 @@ asmlinkage __visible void __sched notrac */ if (likely(!preemptible())) return; + if (!preemptible_lazy()) + return; preempt_schedule_common(); } @@ -3501,15 +3527,9 @@ asmlinkage __visible void __sched notrac if (likely(!preemptible())) return; - -#ifdef CONFIG_PREEMPT_LAZY - /* - * Check for lazy preemption - */ - if (current_thread_info()->preempt_lazy_count && - !test_thread_flag(TIF_NEED_RESCHED)) + if (!preemptible_lazy()) return; -#endif + do { preempt_disable_notrace(); /*