Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp278049pxb; Mon, 25 Apr 2022 09:50:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrhvMQ+glBcBco3bynbFN+lWPlo6e5rNJXRKk0/JA+YOwtEzmxDiTlqOp4T+newwrXhDqW X-Received: by 2002:a17:906:8585:b0:6f3:99f0:d061 with SMTP id v5-20020a170906858500b006f399f0d061mr4437238ejx.436.1650905420731; Mon, 25 Apr 2022 09:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650905420; cv=none; d=google.com; s=arc-20160816; b=RQHXyzZ6ODRYR8eJxN4vUFkRje+Fq7vOfxddUmDIa9egnQGtvVHeaZU/mM5Lr8cKCN Nrw3Jfb+byQwLBVKgxKJhfzEsMz5YVSiSK/9xEeqDYuAUB2oeV+FYxdiOMtPxc7RpHB/ bxa3GQANjVcWP+NmASHnUN8t44WgnHpIOZ3reXXEaYQI4CMZtTb9h8vGke8nzUZEhkGs IWZoEtSMSQpo1y4c6jCTBLaGSTe9ODVyGSumRKTFtNMJUYC9OBekO7OotruQrh1W+VZF RUw36IL34NGCd9LiEvGrtUK1gumX7UwKRxbgKvWH4qfi76vf22cDIOW196CRw9BWCjnV oAtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ZOr8NZGy5gwYgHJYgd46ZelGZZzi7C8Ouk3t0T6VexQ=; b=ht1VfhrQwj/ZVF3q4bJ+vu6YYuUL/x3JfNOcqqNhwXFXobjZ/tZRym8x1RcLzJ8p0V PtCXu++/nRQbSyQZaAXMPIBYqpsa7W1PMS5cNv//FpqHUoo45LHeauQvm5794q7Bt5Il 2qp3ini+1gvk9byRthRWUWuYLLfYdva1uKu/u/M/LvKCiBaw0Ibko01zpt05wF7jrXVw ZY+6V07WXjdXfrvzbFd4GzCJL4ZLLZ/gljYc9aDBpKjm1v0P4WIMKFqcFsl6nfpj/zqo s/Bs7HcPI8xgdckaZvphSGW7lERnlIKIS5+z3+eouxpQLsGnqAISRPxSGquCLdWj87WF Z+6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Lh5QGVP4; dkim=neutral (no key) header.i=@linutronix.de header.b="WoDBts/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020a170906721600b006e7fe1e4eb4si14243953ejk.847.2022.04.25.09.49.55; Mon, 25 Apr 2022 09:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Lh5QGVP4; dkim=neutral (no key) header.i=@linutronix.de header.b="WoDBts/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240081AbiDYMyS (ORCPT + 99 others); Mon, 25 Apr 2022 08:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242008AbiDYMyE (ORCPT ); Mon, 25 Apr 2022 08:54:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EEEB1CB27; Mon, 25 Apr 2022 05:50:59 -0700 (PDT) Date: Mon, 25 Apr 2022 12:50:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1650891057; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZOr8NZGy5gwYgHJYgd46ZelGZZzi7C8Ouk3t0T6VexQ=; b=Lh5QGVP4Fb9K6umAzR8PupJ7EJoygkpstwG6+vZXJ6MFcsRQuEskr5U1YWAHO6IyUaDuvl JY3WiJzxExvoxGnhZxXDPTNiSBc2kgcktmrwihSTXyI/h8H9nrDeTkdX5hjrbUcK+6y6bn zXEIM8SiKZzaaWR1GIIZaxI18t7lvAsEYAIpz8POwEwvYTH1Gh6GKZ0LVn6xCq4XePjrkT HAiX0Jh3G/ltrClhG6svZ8F6kztq96WqeaC2MseeurFuy/privhJrTSLJU2iQJHsOyaB46 VQGauM3XxXU6afdyCSBzeFo5bC5hjpxnKqIpO913j+PWBSLrxpH8lX+fIEHFFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1650891057; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZOr8NZGy5gwYgHJYgd46ZelGZZzi7C8Ouk3t0T6VexQ=; b=WoDBts/BZsCdWFYmMC9lXvLOOpxB5Cr6AY2+Qmj4fWOdLrVb5LJFvvlLHlH2gnFjuR/v+W 6E2TktxWW1LvgdAQ== From: "tip-bot2 for Nicholas Piggin" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped Cc: Nicholas Piggin , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220422141446.915024-1-npiggin@gmail.com> References: <20220422141446.915024-1-npiggin@gmail.com> MIME-Version: 1.0 Message-ID: <165089105607.4207.3022534114716811208.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 62c1256d544747b38e77ca9b5bfe3a26f9592576 Gitweb: https://git.kernel.org/tip/62c1256d544747b38e77ca9b5bfe3a26f9592576 Author: Nicholas Piggin AuthorDate: Sat, 23 Apr 2022 00:14:46 +10:00 Committer: Thomas Gleixner CommitterDate: Mon, 25 Apr 2022 14:45:22 +02:00 timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped When tick_nohz_stop_tick() stops the tick and high resolution timers are disabled, then the clock event device is not put into ONESHOT_STOPPED mode. This can lead to spurious timer interrupts with some clock event device drivers that don't shut down entirely after firing. Eliminate these by putting the device into ONESHOT_STOPPED mode at points where it is not being reprogrammed. When there are no timers active, then tick_program_event() with KTIME_MAX can be used to stop the device. When there is a timer active, the device can be stopped at the next tick (any new timer added by timers will reprogram the tick). Signed-off-by: Nicholas Piggin Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20220422141446.915024-1-npiggin@gmail.com --- kernel/time/tick-sched.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 2d76c91..b1b105d 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -928,6 +928,8 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) if (unlikely(expires == KTIME_MAX)) { if (ts->nohz_mode == NOHZ_MODE_HIGHRES) hrtimer_cancel(&ts->sched_timer); + else + tick_program_event(KTIME_MAX, 1); return; } @@ -1364,9 +1366,15 @@ static void tick_nohz_handler(struct clock_event_device *dev) tick_sched_do_timer(ts, now); tick_sched_handle(ts, regs); - /* No need to reprogram if we are running tickless */ - if (unlikely(ts->tick_stopped)) + if (unlikely(ts->tick_stopped)) { + /* + * The clockevent device is not reprogrammed, so change the + * clock event device to ONESHOT_STOPPED to avoid spurious + * interrupts on devices which might not be truly one shot. + */ + tick_program_event(KTIME_MAX, 1); return; + } hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1);