From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752118AbdL0SWQ (ORCPT ); Wed, 27 Dec 2017 13:22:16 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60328 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbdL0SWP (ORCPT ); Wed, 27 Dec 2017 13:22:15 -0500 Date: Wed, 27 Dec 2017 19:22:06 +0100 (CET) From: Thomas Gleixner To: Frederic Weisbecker cc: LKML , Anna-Maria Gleixner , Sebastian Siewior , Paul McKenney , Peter Zijlstra , Frederic Weisbecker , Ingo Molnar , stable@vger.kernel.org Subject: Re: [patch 2/4] nohz: Prevent erroneous tick stop invocations In-Reply-To: <20171226151746.GA6560@lerouge> Message-ID: References: <20171222145111.919609918@linutronix.de> <20171222145337.713295508@linutronix.de> <20171226151746.GA6560@lerouge> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Dec 2017, Frederic Weisbecker wrote: > On Fri, Dec 22, 2017 at 03:51:13PM +0100, Thomas Gleixner wrote: > > The conditions in irq_exit() to invoke tick_nohz_irq_exit() are: > > > > if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) > > > > This is too permissive in various aspects: > > > > 1) If need_resched() is set, then the tick cannot be stopped whether > > the CPU is idle or in nohz full mode. > > That's not exactly true. In nohz full mode the tick is not restarted on the > switch from idle to a single task. And if an idle interrupt wakes up a > single task and enqueues a timer, we want that timer to be programmed even > though we have need_resched(). Hrmm, so the check for softirq_pending() should be sufficient, right? --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -382,7 +382,8 @@ static inline void tick_irq_exit(void) int cpu = smp_processor_id(); /* Make sure that timer wheel updates are propagated */ - if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) { + if (((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) && + if ((idle_cpu(cpu) || tick_nohz_full_cpu(cpu)) && + !local_softirq_pending()) { if (!in_interrupt()) tick_nohz_irq_exit(); }