From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755309AbbKWR7a (ORCPT ); Mon, 23 Nov 2015 12:59:30 -0500 Received: from casper.infradead.org ([85.118.1.10]:59720 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753617AbbKWR73 (ORCPT ); Mon, 23 Nov 2015 12:59:29 -0500 Date: Mon, 23 Nov 2015 18:59:26 +0100 From: Peter Zijlstra To: Lianwei Wang Cc: linux-kernel@vger.kernel.org, linux-pm@lists.linux-foundation.org, rjw@rjwysocki.net, mingo@redhat.com Subject: Re: [PATCH] sched: idle: move need_resched check after function rcu_idle_enter Message-ID: <20151123175926.GM17308@twins.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 21, 2015 at 01:02:02AM -0800, Lianwei Wang wrote: > The rcu_idle_endter may call wakeup_softirqd to set the need resched > flag on idle process. But if we don't check it after that, then the > cpu will enter idle state with RESCHED flag set and can not be woken > up by wakeup/resched call anymore. > > Check need_resched after rcu_idle_enter to make sure the cpu is able > to be out of idle immediatley to run other tasks. > > Signed-off-by: Lianwei Wang > --- > kernel/sched/idle.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > index 4a2ef5a02fd3..6e96a1f41041 100644 > --- a/kernel/sched/idle.c > +++ b/kernel/sched/idle.c > @@ -137,21 +137,21 @@ static void cpuidle_idle_call(void) > int next_state, entered_state; > > /* > + * Tell the RCU framework we are entering an idle section, > + * so no more rcu read side critical sections and one more > + * step to the grace period > + */ > + rcu_idle_enter(); > + > + /* > * Check if the idle task must be rescheduled. If it is the > * case, exit the function after re-enabling the local irq. > */ > if (need_resched()) { > local_irq_enable(); > - return; > + goto exit_idle; > } > > - /* > - * Tell the RCU framework we are entering an idle section, > - * so no more rcu read side critical sections and one more > - * step to the grace period > - */ > - rcu_idle_enter(); > - > if (cpuidle_not_available(drv, dev)) { > default_idle_call(); > goto exit_idle; FWIW your patch is whitespace mangled; I could not apply if I wanted to.