From patchwork Wed Oct 4 12:34:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 148255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp98439vqb; Wed, 4 Oct 2023 05:36:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuFXOb5afkaSNXx/BU1MDSAm/McHURHXvKEh4gRoxUNjfmQGc48B/5d5Kwb3x7Widv4Wnl X-Received: by 2002:a17:90b:33cc:b0:277:4497:f0c2 with SMTP id lk12-20020a17090b33cc00b002774497f0c2mr1998606pjb.39.1696422990449; Wed, 04 Oct 2023 05:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696422990; cv=none; d=google.com; s=arc-20160816; b=0pNd0xtrcOlVx+b1oWD5hpRlNkWknrrFYE5G7I2hwDRXTR4d2HBb+LMxoUFXNfjQwr 43g3vqLsYbZZHi0nKANtFKsFDAsL4IYtfZ5PvzrgaDrhDQhDlSzB2gtLpFO3msR8DQAF aWRzK7JWx6JSEKlxOnacEpnwz0mJuREbvGUyI7vco21uZ9Aq98JV5+M4uD1+FKU/bfbu XiNBg+cOLdVjYnFXnggrLD6ZKU7xU+ciGGDJ1QWB8QyjZ1UTlyYTLKpDZY1jeSR+OiCa rIb4wn6JOhukM93p/P9HzFD+ctu3eNFRRumIYe5Tw1uVbi++LXez48aFnPK4R6kykidR ktdg== 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:dkim-signature :dkim-signature:from; bh=AXGP/cV38TkuwT0IRhJ9YYY7aFG2G6iSF6EqZ7aAS+o=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=U1Gbn9e2bh0PEJoi3mlJy3NpbbYf02Nd5oIOq1uaW5pofYou+rL+CM2kN9CxIUP9fo kH1UFbgkbdKaLdR0hsulTfhMywajU/7Bgj+whQQ1UCjbjp95TbPQXZAdywxzKcmzUSwi nSF2kzHjiXMSpTD5khw5yHjLSU5/pGxikbR5dvF47+YPxcxHv0k3kAACaW0x90UW9w64 GqY4pEuRzIbTUZwxVUBWaZqmTBQw5WXxaZJxphOwm30bLC2vTwsEkvemQ0igk+GVpfTp JTfD5RXJPL7iBxm8z+JlSJ2zrbq9UjiRG7sYMLTze8BBhJIeIUPX1Vsn10RH6W7Wz8pn opoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mCLdP9Sz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GWXVBCrm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id pi4-20020a17090b1e4400b00277636a9e5csi1484563pjb.96.2023.10.04.05.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mCLdP9Sz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GWXVBCrm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 05E0380B1BDA; Wed, 4 Oct 2023 05:35:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242383AbjJDMfi (ORCPT + 18 others); Wed, 4 Oct 2023 08:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242313AbjJDMfc (ORCPT ); Wed, 4 Oct 2023 08:35:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19EF8BF for ; Wed, 4 Oct 2023 05:35:29 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AXGP/cV38TkuwT0IRhJ9YYY7aFG2G6iSF6EqZ7aAS+o=; b=mCLdP9Sz8EnBzXJX1cpWsLaMbxR7yBHBthK1dXImUp5/1a4RJY6/2zTW9g9VG6gxLbEvqB LB2zeTRuEBPLCCKi+VE7dWf6Wv9JBXfrDO9D74AyVgcMYJ1gHqXZ3ts5N4npijeFIx3DVS kTJg98s0HfyGgpqdC6SeijQ4uy3dwi9efOfXk7q9gxXvoafo61HdiFs9pEt3Nbusy4hbT1 hH9wZJshZI6kvoop02euzfKTrCm+kFU8NvNWVmxqx7us6gPr+eWw1YzCfCTS4vZTqB5HCj dFFL4hQ39Gyt2IiUpM+3QqV5+wBEcqceFz5bL0JMvqgypKiG4NA8en71090VcQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AXGP/cV38TkuwT0IRhJ9YYY7aFG2G6iSF6EqZ7aAS+o=; b=GWXVBCrmoEVjjFNM0cucO6c5WGmhbmj1qsAX4zXMVXYQfZsTYVYDDA0RuF72hw13/S3+U5 UmBtuN00urfORyBw== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak , Anna-Maria Behnsen Subject: [PATCH v8 03/25] timer: Do not IPI for deferrable timers Date: Wed, 4 Oct 2023 14:34:32 +0200 Message-Id: <20231004123454.15691-4-anna-maria@linutronix.de> In-Reply-To: <20231004123454.15691-1-anna-maria@linutronix.de> References: <20231004123454.15691-1-anna-maria@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:35:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828433938674293 X-GMAIL-MSGID: 1778828433938674293 Deferrable timers do not prevent CPU from going idle and are not taken into account on idle path. Sending an IPI to a remote CPU when a new first deferrable timer was enqueued will wake up the remote CPU and but nothing will be done regarding the deferrable timers. Drop IPI completely when a new first deferrable timer was enqueued. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v8: Update comment v6: new patch --- kernel/time/timer.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 63a8ce7177dd..7d06351aff54 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -571,18 +571,15 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk, static void trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) { - if (!is_timers_nohz_active()) - return; - /* - * TODO: This wants some optimizing similar to the code below, but we - * will do that when we switch from push to pull for deferrable timers. + * Deferrable timers do not prevent CPU from entering dynticks and are + * not taken into account on idle/nohz_full path. An IPI when a new + * deferrable timer is enqueued will wake up the remote CPU but nothing + * will be done with the deferrable timer base. Therefore skip remote + * IPI for deferrable timers completely. */ - if (timer->flags & TIMER_DEFERRABLE) { - if (tick_nohz_full_cpu(base->cpu)) - wake_up_nohz_cpu(base->cpu); + if (!is_timers_nohz_active() || timer->flags & TIMER_DEFERRABLE) return; - } /* * We might have to IPI the remote CPU if the base is idle and the