From patchwork Wed Sep 27 15:01:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 145450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2738054vqu; Wed, 27 Sep 2023 09:12:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQQbCccMvgbNNd8j2jOPSbjLronvOIxtaSrCdjU3inWxIzzyw/ZOijYWLOMKsFw8o48ErK X-Received: by 2002:a05:6808:1b06:b0:3a4:225f:a15b with SMTP id bx6-20020a0568081b0600b003a4225fa15bmr3444511oib.31.1695831144124; Wed, 27 Sep 2023 09:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695831144; cv=none; d=google.com; s=arc-20160816; b=FIxoNdbxaAsEigdgfkjOEyRoQaqOLTfdz48BVOo1Lp+mxpPYG79ab1u8NmUekDEUuc Id0hXgTH5+1QvyEw5nEU3MTd5Q8cI3PemT1UGxBtajj/mx8vbd8JpB8ccMAD59XxdvOB 0eokWmyZGvjxFahcGksPxLpCTFmdbOnSKL0oOgnD+eCuPs8epj41Td1e2ry4Frm66oPw oEXusxO4bUFk5+aXfEnWMfX2hU6gvva1/B0usJMqmLPExxNIAVsmxREFZbqYENbHoHSE 7WxJMDAuXVG2VNqK1Q0ZU+nxskiRlFstXQxBDu1sgEdTbZaFRHQmqgzorwkgKkDF1xo3 Eyow== 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=gBwqXzZPblG1ncLS43lGYrnNbOnW3bAsFhI96LBlU5g=; fh=AAnB8n3BQqQbeD3JBhCxFZya7F9ZuxdpKurn41kX2Qg=; b=sILEfvkEJ29i11DRsGuODxi6aKzNd68RHvwO11yInFShA/OkCuey3E39OTC5lI8suQ OvmX4ymfhZTC8W1Arht8QNDE+I9iV0QG4rW/jvcz0kW92YUiF8nlpdpFm5dxLrePv6St dHMQG4tDgX5/yCk9tYeYBmq6Q5N38YE/u1oHpqa+1PMFxNRy3AKWit+c3mV+9pB4pcXd ThidT6O9Q1/vu7/5NtNCaW6mAg5WNHhN7p3r55XGHxTk7UECXIRzl2OR3ZVW34GXAzXh gtDb0Ztp5xfkpmQ3H3BHsJV8SnNDQiW/b+j1K/b0vCUUH6L9D/FucW6ribgRTXU7ywFb kkuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qsABm6HZ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ck8-20020a056a00328800b00690f9ca0f99si455303pfb.12.2023.09.27.09.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 09:12:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qsABm6HZ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 61305802F7D1; Wed, 27 Sep 2023 08:02:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232307AbjI0PBx (ORCPT + 19 others); Wed, 27 Sep 2023 11:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232273AbjI0PBg (ORCPT ); Wed, 27 Sep 2023 11:01:36 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDF79192; Wed, 27 Sep 2023 08:01:33 -0700 (PDT) Date: Wed, 27 Sep 2023 15:01:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695826891; 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=gBwqXzZPblG1ncLS43lGYrnNbOnW3bAsFhI96LBlU5g=; b=qsABm6HZX825o3E4bTX7obwAWDl8AyY0rA8V7oM17PTAEhR6NJwhUWsVNBbMHgzWpc06MM mycdeStLix6qZykrVFB/LzofUfDNWAXSDgKOsIA3WCN6vSvtL0giWoSeEaPA5Hgd+BTAp1 A2zBzx8On0FygkkIpsGZL/pYNGddFwzCBtulgbdODylPTRqm8u+xc21pqzz1w75iuy859c Z/3pQvI5rb7qYZkSNZT/p7q8iW7DYHyp0vpcxq4hWXbXWkyt7RfNMzNOOmaJ65EczzWZ9z VSNnLFJqSogHk552vtPIxwl2pqycMER3IpK7gtBrExEkzFvb3P/VZkF2mmc1wQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695826891; 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=gBwqXzZPblG1ncLS43lGYrnNbOnW3bAsFhI96LBlU5g=; b=x/AD695BFQ3drhzQtTnKnOxEzb3gXPzTW7HsVCdOOeXlaMXmQTMMWFYVkBT++0CZfp92X+ VLza9VVUNpyxerCg== From: "tip-bot2 for Frederic Weisbecker" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] tick/nohz: Don't shutdown the lowres tick from itself Cc: Frederic Weisbecker , Thomas Gleixner , "Joel Fernandes (Google)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230912104406.312185-4-frederic@kernel.org> References: <20230912104406.312185-4-frederic@kernel.org> MIME-Version: 1.0 Message-ID: <169582689055.27769.5495044168356785862.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:02:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776835828097024247 X-GMAIL-MSGID: 1778207837852640582 The following commit has been merged into the timers/core branch of tip: Commit-ID: 4f7f4409af289715f44685f250e380ce2cbffc7e Gitweb: https://git.kernel.org/tip/4f7f4409af289715f44685f250e380ce2cbffc7e Author: Frederic Weisbecker AuthorDate: Tue, 12 Sep 2023 12:44:04 +02:00 Committer: Thomas Gleixner CommitterDate: Wed, 27 Sep 2023 16:58:10 +02:00 tick/nohz: Don't shutdown the lowres tick from itself In lowres dynticks mode, just like in highres dynticks mode, when there is no tick to program in the future, the tick eventually gets deactivated either: * From the idle loop if in idle mode. * From the IRQ exit if in full dynticks mode. Therefore there is no need to deactivate it from the tick itself. This just just brings more overhead in the idle tick path for no reason. Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Reviewed-by: Joel Fernandes (Google) Link: https://lore.kernel.org/r/20230912104406.312185-4-frederic@kernel.org --- kernel/time/tick-sched.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 95a8d1d..8e9a9dc 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1403,18 +1403,16 @@ static void tick_nohz_lowres_handler(struct clock_event_device *dev) tick_sched_do_timer(ts, now); tick_sched_handle(ts, regs); - 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; + /* + * In dynticks mode, tick reprogram is deferred: + * - to the idle task if in dynticks-idle + * - to IRQ exit if in full-dynticks. + */ + if (likely(!ts->tick_stopped)) { + hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); + tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); } - hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); - tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); } static inline void tick_nohz_activate(struct tick_sched *ts, int mode) @@ -1519,7 +1517,11 @@ static enum hrtimer_restart tick_nohz_highres_handler(struct hrtimer *timer) else ts->next_tick = 0; - /* No need to reprogram if we are in idle or full dynticks mode */ + /* + * In dynticks mode, tick reprogram is deferred: + * - to the idle task if in dynticks-idle + * - to IRQ exit if in full-dynticks. + */ if (unlikely(ts->tick_stopped)) return HRTIMER_NORESTART;