Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp765982imm; Wed, 1 Aug 2018 05:05:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcEQU6IP7YXsSLYUjp0DDUCu2deWM7fMO3NsD475JXAyuSQiuO3DDycydL4XxZN2CSbQThO X-Received: by 2002:a17:902:a508:: with SMTP id s8-v6mr24753408plq.223.1533125105393; Wed, 01 Aug 2018 05:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533125105; cv=none; d=google.com; s=arc-20160816; b=NAGsBM6Db5/bNrEqbIhhSAr5c+D2p10pzHeUaXzWe/rtgFxqBfmKn5Ui1CSQcZPfDQ 4NW8ViPFMsf164yp4ChOnY1R1vIHWmJW4Lr9py2fcv8mAekBfzPu0OSHJ4LnrihbANws JS+J8pb1OTGFgUhgJKK9zskj07zYxMRYBP0KCeGrt8/FMP84OUKLuvOatQb8U9BHsWjz Abc0GOtfna4B70S1RJTn0XBWUiMlPO/s0ukluNHsgQ3ukcxIJmW+B9dj7mveUytZKkim C+Zo9rwrToi5GPlqefbOEJ6sLavKSIyMayPVNLjDbVcYwOyWwprzDHMJ3a7AfSiagn5z oQOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=oqR9+0sRDX5DAx8aZSSUXeRq+r8YSlIdYPO3Vz4Fp9I=; b=nIbJIEpKvZqs3dGzbQV/FaW5mmoFuPa3fOdzjeUnuuiCDdUL0i0tYGV0SG8s0DRNn7 v07zchQpgpxQyN7OSFVd8pstId7Blp/MxUYGqYnI1jru+QF7J3ePhkbohMCNzaPIQFxb +p5IV/luPT7E75Oz2vCpjgMW8RkiptDyHeRVS/Vir7t5OKFrNX4ing7ugMWzJKEIr8yq HFBLAjxaYYfZAidtE9yJi4DvGXtIYVpYWtb8ZRFDOhKLqiflD3MjBuV+OUkxIBf+myMx a4GVu4LX3jMQQ/6y06LWCOdSvqFBNZsikSZNLzJJV3Yt7Peo8U+dFg1L3Y9CJkPPc8Pe f89A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2-v6si14319119pgc.447.2018.08.01.05.04.51; Wed, 01 Aug 2018 05:05:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389101AbeHANsm (ORCPT + 99 others); Wed, 1 Aug 2018 09:48:42 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:33854 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387575AbeHANsl (ORCPT ); Wed, 1 Aug 2018 09:48:41 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=[10.100.61.72]) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fkpqR-0005Tv-Gx; Wed, 01 Aug 2018 14:03:11 +0200 Date: Wed, 1 Aug 2018 14:03:11 +0200 (CEST) From: Anna-Maria Gleixner To: Frederic Weisbecker cc: Thomas Gleixner , LKML , Ingo Molnar Subject: Re: [PATCH] nohz: Fix missing tick reprog while interrupting inline timer softirq In-Reply-To: <1533077570-9169-1-git-send-email-frederic@kernel.org> Message-ID: References: <1533077570-9169-1-git-send-email-frederic@kernel.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()) > 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. > > 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. > > Reported-by: Anna-Maria Gleixner > Signed-off-by: Frederic Weisbecker > Cc: Thomas Gleixner > Cc: Ingo Molnar Tested-by: Anna-Maria Gleixner Thanks, Anna-Maria