Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1136268imm; Wed, 1 Aug 2018 10:47:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc72jhux8M6CFfZ/a3m6YP6iqWeCe8Lz5ZimCy4HGrCgwPy4cfBa1baigVtVD06Q1gdiJzn X-Received: by 2002:a63:ec14:: with SMTP id j20-v6mr25073254pgh.28.1533145635752; Wed, 01 Aug 2018 10:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533145635; cv=none; d=google.com; s=arc-20160816; b=DYEUl94zVPAM7Qw5CrklwhvUQURWATGqpLMT094MJt8C+zzw3eQIaT9LtZ8rbGdKRQ buQyB+s0fwKDgRaKh6zGRjM566jRQAxS/+5A8Dw3lKbVKJX5Ts57qL63925MRh663De7 5B7Y55OPAAwC1gwtqNGAkSb9sZJEs3YuSffG7DMUZS/jkVJYBVnqAoV6cKT2twYodzW6 hFYScrbIX5Cka8s8GEmvIXPznEGQRKIrnZyn3W1ztfvRkh7A39rA7EEcWh4gffMMt1Ot aCd8xgKA1IAJoqn5OVryY5qR54IVYY7VPB/R/XkvshXXnkTgT39BgNtGaVPBattggOlS kFfw== 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=TkLDl7VuabpxPRXUmCn5qqPc44+DmjUvVmTEZwtGM6M=; b=Or/TTjX46Jtzj7w6/uxt0BXLUi8qOKy+Qp1R2aRekwxpNoSRRKosyiPRmMrTAQetG5 SBlSoKx9aH95e1GAPKj9E0FPV7/jtUJeWWI+UMq3DI+VCNCTNUMr1rE/haX5ARUpKf1F yPu+ro2oOra2hCnBKqG7fj6L5C0okzgPMYR1gHmY/RgSTnSmS7o1f7JVWseZxNsnbwPy nydwnqGMQZr6gd43vDWFnnEcOm2yVFj4x6HleK0rS1KiWYfPMlFPReFnXUj93IrhScCO 3oxmq8pv+3CqIwvsDho4dZ9meKlgwMR1eFhIUbsDY2D63VtqUtVfXwNF/LgccA+SX9pb q18g== 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 w3-v6si14828873pgp.220.2018.08.01.10.47.01; Wed, 01 Aug 2018 10:47:15 -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 S2403938AbeHATdB (ORCPT + 99 others); Wed, 1 Aug 2018 15:33:01 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:34618 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389887AbeHATdB (ORCPT ); Wed, 1 Aug 2018 15:33:01 -0400 Received: from p4fea5a5a.dip0.t-ipconnect.de ([79.234.90.90] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fkvCN-0005kK-1C; Wed, 01 Aug 2018 19:46:11 +0200 Date: Wed, 1 Aug 2018 19:46:10 +0200 (CEST) From: Thomas Gleixner To: Frederic Weisbecker cc: LKML , Ingo Molnar , Anna-Maria Gleixner 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 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 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()) 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? > 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. 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. Thanks, tglx