From patchwork Wed May 25 21:15:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 818842 Received: from canuck.infradead.org (canuck.infradead.org [134.117.69.58]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4Q050kE008337 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 26 May 2011 00:05:21 GMT Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QPN4Q-00016X-VY; Wed, 25 May 2011 23:00:55 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPMzZ-0000Sh-SL for linux-arm-kernel@canuck.infradead.org; Wed, 25 May 2011 22:55:54 +0000 Received: from j77219.upc-j.chello.nl ([24.132.77.219] helo=twins) by casper.infradead.org with esmtpsa (Exim 4.76 #1 (Red Hat Linux)) id 1QPLR8-0003gK-Jy; Wed, 25 May 2011 21:16:14 +0000 Received: by twins (Postfix, from userid 1000) id B8DAE81BF4DD; Wed, 25 May 2011 23:15:28 +0200 (CEST) Subject: Re: [BUG] "sched: Remove rq->lock from the first half of ttwu()" locks up on ARM From: Peter Zijlstra To: Marc Zyngier In-Reply-To: <1306343335.21578.65.camel@twins> References: <1306260792.27474.133.camel@e102391-lin.cambridge.arm.com> <1306272750.2497.79.camel@laptop> <1306343335.21578.65.camel@twins> Date: Wed, 25 May 2011 23:15:28 +0200 Message-ID: <1306358128.21578.107.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Cc: Frank Rowand , Ingo Molnar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Oleg Nesterov X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 26 May 2011 00:05:21 +0000 (UTC) On Wed, 2011-05-25 at 19:08 +0200, Peter Zijlstra wrote: > Ooh, shiny, whilst typing this I got an NMI-watchdog error reporting me > that CPU1 got stuck in try_to_wake_up(), so it looks like I can indeed > reproduce some funnies. > > /me goes dig in. Does the below make your ARM box happy again? It restores the old ttwu behaviour for this case and seems to not mess up my x86 with __ARCH_WANT_INTERRUPTS_ON_CTXSW. Figuring out why the existing condition failed and writing a proper changelog requires a mind that is slightly less deprived of sleep and I shall attempt that tomorrow -- provided this does indeed work for you. diff --git a/kernel/sched.c b/kernel/sched.c index 2d12893..6976eac 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -2573,7 +2573,19 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu) if (!next) smp_send_reschedule(cpu); } -#endif + +#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW +static void ttwu_activate_remote(struct task_struct *p, int wake_flags) +{ + struct rq *rq = __task_rq_lock(p); + + ttwu_activate(rq, p, ENQUEUE_WAKEUP | ENQUEUE_WAKING); + ttwu_do_wakeup(rq, p, wake_flags); + + __task_rq_unlock(rq); +} +#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ +#endif /* CONFIG_SMP */ static void ttwu_queue(struct task_struct *p, int cpu) { @@ -2630,18 +2642,11 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) */ while (p->on_cpu) { #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW - /* - * If called from interrupt context we could have landed in the - * middle of schedule(), in this case we should take care not - * to spin on ->on_cpu if p is current, since that would - * deadlock. - */ - if (p == current) { - ttwu_queue(p, cpu); - goto stat; - } -#endif + ttwu_activate_remote(p, wake_flags); + goto stat; +#else cpu_relax(); +#endif } /* * Pairs with the smp_wmb() in finish_lock_switch().