Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2998401rdb; Tue, 12 Sep 2023 20:57:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvtA6pSpOWIcN86RTOvuYT8gi/tXHhPoOGJxYa+xDswRPsGlg9x3jXFaT4u4rdU9ZCjleh X-Received: by 2002:a17:90b:190e:b0:26d:287f:a545 with SMTP id mp14-20020a17090b190e00b0026d287fa545mr1150800pjb.29.1694577449779; Tue, 12 Sep 2023 20:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694577449; cv=none; d=google.com; s=arc-20160816; b=aB3qWesci+p3c6mYB77W/+gOlPG+B1XEZczPnjX0/pwHFilSaQ+JaYEyno9tIq04IH 3HqOorfpvFaKFUu5h55uhJl+XzBJCPGcgdrRF5YEXHQvwiHBWDUUxlgzzrFlxVo9pmHQ MUQuPn19fMGSHlVW1uj0MSfU5sECWF2TRCm105YBMJZ1U0QftIBvCsq59BixNqyuEB7/ HbkuE8WK1611d/gJsknVjuhz9EmWdDGWK5i1CrxgjT+nRfY1qm9Lapc2+HRusjZ9uieG trhWXD2ZWPpkYrf9ZPRhp+ZKvnzAeYpkcIJFhVx1gxpwxlAJS5HL0YhMzOWVxIVwWCAd p4IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IySCpvlRDtWaBhfevoMuMq4DOFuV0e10hd277zPmJUs=; fh=KZsIGXP5HqVXbsRC9/8uC3fw6jb10xtWDpNz3O4AKxc=; b=YPlk3P52QPL/+2qSKEvuC+5EdraKOtxh/WuHaer5tLi+zYhSZgNppCNKCbWOhcmh8j WGDG2Y40Sc5MzhaLBf/sGbS7lLr1wAXYgMdEb991uXxjQqnPXlj7h/pqQ0cPcVqTT/fl f+r+jYTaLhPqENx3pDOlS16monl3H5geZZpwm5hmHZyEM5rIx0aMO0K5oRNEipcKGf/x xqmkYGqklO09B4U2+MN4zGqdH8F+UvH4oJeOC433vHl3BVcsxyExPpOfbTzYCVUkfbSZ QKVQo2rYlY8GPwxL+ikwvGBQBicS6mjXGWYLekFOCoYoHSNfMabo+RDSe8FLuYU6DQ48 EgJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tEbvCx9u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n5-20020a17090a9f0500b0025bdc2a0b15si693730pjp.135.2023.09.12.20.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 20:57:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tEbvCx9u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0BC59830C336; Tue, 12 Sep 2023 03:45:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234296AbjILKp1 (ORCPT + 99 others); Tue, 12 Sep 2023 06:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234453AbjILKov (ORCPT ); Tue, 12 Sep 2023 06:44:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CCC4172E for ; Tue, 12 Sep 2023 03:44:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52499C433C8; Tue, 12 Sep 2023 10:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694515460; bh=8IMEGNQxJUVrw2F/l3GmN1Ldd+1Byg1w8yqybgZALh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEbvCx9uyF/x3U3frcNYdc0orFnxJFUZf6M65+NQ6QlTsM0zyiPtq33dJaI5zvgYq 3cA/hKUI7sBb8mYwLRFR2XMCSZ7+msxco0rRRkt9b8A2/xU1sr13E23dZC4zrut+xK HO0U+BjZqCW6XqlrCfWeLWcIWM0M1tsVMSpX/ziQumN3H7OGFjs++AR3BZLop5vWHG wI9Z/EeoOlPuw8p2fY95zQR0K0MATtZL3ca6JP9GqZ1+9RSR6lfpoSeUdeZD0PowRe vjbZz3TzGJZIPgeGezEFrQc9an1xqTqUf35Q5mhoz84fTZqWm07At91+Ksyh/JdwQf Il+4zUKLz0v1w== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , vineethrp@gmail.com, Nicholas Piggin Subject: [PATCH 3/5] tick/nohz: Don't shutdown the lowres tick from itself Date: Tue, 12 Sep 2023 12:44:04 +0200 Message-Id: <20230912104406.312185-4-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912104406.312185-1-frederic@kernel.org> References: <20230912104406.312185-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 03:45:33 -0700 (PDT) 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. Fixes: 62c1256d5447 ("timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped") Signed-off-by: Frederic Weisbecker --- 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 95a8d1d118a2..8e9a9dcf60d5 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; -- 2.34.1