Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1334818imm; Wed, 1 Aug 2018 14:10:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeH5Cyz5/Jb6+fjInwsA4DQ/CFiGJTBX0fFyAiEgMAf6Qwty/Rgrv5abpBY+BbJytGqyZ1l X-Received: by 2002:a62:c410:: with SMTP id y16-v6mr28527384pff.161.1533157836898; Wed, 01 Aug 2018 14:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533157836; cv=none; d=google.com; s=arc-20160816; b=mSnOBiZbKsP0nCcadsDkiq+t3zszLuqSjz53VShKogrYkPrfLOaWkehhit9/qU8F6R KZMF3sRjjrbSIEILB6c1IR1IGCUnCHk1pi1DnVCb/jTOMCCRH902BumNfVC39WfES8QX D/Bd1TTr3SFRZ0Bm9tCow+Rl7IwAzKaWRyDa6stz8FPanmAGaoN1nkvqpuP8Fim3GXHV Uay3JqX36Fffl1zq5Osi45OGj7jkkWBgqZZ7kCdBKVcQNOw1wqZmoIGYQrDC7YAHOT4L ZhGYryzMoNezBywzu25ML1eEJLFp2VSzXnrcZzzsGRc5pbohr0qFpPMvc3qGmA8mtvYt rgfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=m9MTdSSJUUVEVgK7JtHCIuk/WbjrnLcx5xPR138NYA4=; b=V/k3w6Rwy+5cg5Fol1A98yOhSAp4JcXJTyprcB5lgIgGRCqfB7kaknkXVZS9JgL/Pe CA7BCdAYWF15htr/U42U4D2wlS95yYYj+4eUdUJlCPY697OrclztwLSDh1Snx6sGNv5p l65/JrtjwhiF4B9aMjSFU1Gg3zBuwKcJkGopI57oofhy152ur+uATVlpjzVdj3aKE0Uj Cpov/0W3lVrt9iGBLY+CWkLGXvMJUAvehhR8bM04d9FTz9v1HDCGgU4xsQ88mfvf/WCY 7+fSr6D7n2nKb6qLoZiEqO109BT81xt1/EbcPx9CJY4C7OVXid7JxCGjpNAWW508sJDe k/aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O4WY1k+m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11-v6si17167plp.33.2018.08.01.14.10.21; Wed, 01 Aug 2018 14:10:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O4WY1k+m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732281AbeHAW4H (ORCPT + 99 others); Wed, 1 Aug 2018 18:56:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:54238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbeHAW4H (ORCPT ); Wed, 1 Aug 2018 18:56:07 -0400 Received: from localhost (LFbn-NCY-1-241-207.w83-194.abo.wanadoo.fr [83.194.85.207]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 193E8208A3; Wed, 1 Aug 2018 21:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533157706; bh=dvd1bgd6Cp6l2Qnao5MXj+DB44/IYYzXa7d1T8QP2pI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O4WY1k+mYmAqVkW9h+Anmh24oz+qayYE8epqvll34b4aukSMFVELfEM+tY9LSC+RO 4aZv09HQzqucG4YYZcVJ5xoUfezuatm3Yj0DM1LWLUYODv2rMWQiLRbclKm6B5LDYA 762T1E405X5Gw57IHSMStKkauOonDiORrxMHD6/Q= Date: Wed, 1 Aug 2018 23:08:23 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Ingo Molnar , Anna-Maria Gleixner Subject: Re: [PATCH] nohz: Fix missing tick reprog while interrupting inline timer softirq Message-ID: <20180801210822.GA20627@lerouge> References: <1533077570-9169-1-git-send-email-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 01, 2018 at 07:46:10PM +0200, Thomas Gleixner wrote: > On Wed, 1 Aug 2018, Frederic Weisbecker wrote: > > Before updating the full nohz tick or the idle time on IRQ exit, we > > check first if we are not in a nesting interrupt, whether the inner > > interrupt is a hard or a soft IRQ. > > > > There is a historical reason for that: the dyntick idle mode used to > > reprogram the tick on IRQ exit, after softirq processing, and there was > > no point in doing that job in the outer nesting interrupt because the > > tick update will be performed through the end of the inner interrupt > > eventually, with even potential new timer updates. > > > > One corner case could show up though: if an idle tick interrupts a softirq > > executing inline in the idle loop (through a call to local_bh_enable()) > > Where does this happen? Why is anything in the idle loop doing a > local_bh_disable/enable() pair? > > Or are you talking about NOHZ FULL and arbitrary task context? It's about the idle loop. But I'm not aware of any example in practice, this is a purely theoretical, and more importantly it doesn't concern upstream anymore since we don't stop the tick from IRQ-tail anymore in dynticks-idle mode after Rafael's changes. > > > after we entered in dynticks mode, the IRQ won't reprogram the tick > > because it assumes the softirq executes on an inner IRQ-tail. As a > > result we might put the CPU in sleep mode with the tick completely > > stopped whereas a timer can still be enqueued. Indeed there is no tick > > reprogramming in local_bh_enable(). We probably asssumed there was no bh > > disabled section in idle, although there didn't seem to be debug code > > ensuring that. In fact I should remove this whole paragraph, it's about code history that's not relevant anymore and it confuses the whole explanation which should concern nohz_full only. > > > > Nowadays the nesting interrupt optimization still stands but only concern > > full dynticks. The tick is stopped on IRQ exit in full dynticks mode > > and we want to wait for the end of the inner IRQ to reprogramm the tick. > > But in_interrupt() doesn't make a difference between softirqs executing > > on IRQ tail and those executing inline. What was to be considered a > > corner case in dynticks-idle mode now becomes a serious opportunity for > > a bug in full dynticks mode: if a tick interrupts a task executing > > softirq inline, the tick reprogramming will be ignored and we may exit > > to userspace after local_bh_enable() with an enqueued timer that will > > never fire. > > > > To fix this, simply keep reprogramming the tick if we are in a hardirq > > interrupting softirq. We can still figure out a way later to restore > > this optimization while excluding inline softirq processing. > > I'm not really happy with that 'fix' because what happens if: > > .... > local_bh_enable() > do_softirq() > --> interrupt() > tick_nohz_irq_exit(); > arm_timer(); > > So if that new timer is the only one on the CPU, what is going to arm the > timer hardware which was just switched off in tick_nohz_irq_exit()? > > I haven't looked deep enough, but a simple unconditional call to > tick_irq_exit() at the end of do_softirq() might do the trick. Nope it should be ok, nohz_full is supposed to support timers queued on the fly while the tick is stopped, we issue a self-IPI if necessary: internal_add_timer() -> trigger_dyntick_cpu() -> wake_up_nohz_cpu() Thanks.