From patchwork Fri Dec 1 09:26:28 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: 172343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp991591vqy; Fri, 1 Dec 2023 01:27:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlmNnuOuO1SC/IZ9PYfEItZnVD75LqXgaRY94Hg0vFDwg1clYh5ApFOORevouYhlBj7CL4 X-Received: by 2002:a17:903:647:b0:1d0:5247:e505 with SMTP id kh7-20020a170903064700b001d05247e505mr1786318plb.14.1701422859800; Fri, 01 Dec 2023 01:27:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422859; cv=none; d=google.com; s=arc-20160816; b=OrC7u7e1Hf+I2KqbRRu0L/LkwuZrfvU6OECEa03ZV0+2k7KxMQT9Tj/+hnnZKFpuEM JAMgL16F6ogHSpmB3orrGWInkY8RVpKDR0qZjflc9qnVfTU9azv50PIVj9X6CW6PDTJj 1GXvNtSCENofeSaAZ6PGvstoWOaatujEbnp1FyMf2s/Ig1sQVXMT9jNn7IPtf+SKlZcI Bz6EAoJlaTWG0j0JTkQmVaKkuVmCaXEgM7hKkvcYaUFhdEFuusJxAOwaY9MoafSL0o5d JL1g5Mtw/yi68Y41bIUovFRciMB/l20vadkN14cuW0sNHiVzxmi05//piEU2Hu/P58Vy r/cw== 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=l1TO/DAtk+CCicSFDRPTxsBfrzcdsd2AUHicFvATynM=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=b89AvmbMKG1Y+Gt+gDI9fP16ZY/DNVV2Bcb6uluUiirF6b8XOUiCNYl9PbQL4PhpUM pjMN5b89f47c15Xo0zaJmf7QWZntyurURAqyrouBtjpHsDB2bLGnYI64rCfO9O1oshcg rgmSiaJVPz8hDCLmAZZGYQYHHo0UHDhythpb5S9Q+eHoXyOBIsqHa+9QRTLaVaDbZ78o mPphqCkHhyvxJHCb+/BOMeitCAcS1dQCpj/jCSPtqzbZSIEkL+TFgkle1Ec67/WIFQmV tMmyplUZBeOdMNs98lbpk8fOcIGRwjZdI8W/hTd3B8aeUxdigv5F2+Hpfa8X52IFY8Is Di8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lum7zhuf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=H7J7pHY4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b7-20020a655cc7000000b005c6034ba3f4si3087905pgt.419.2023.12.01.01.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:27:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lum7zhuf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=H7J7pHY4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 81E8180ECF32; Fri, 1 Dec 2023 01:27:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378044AbjLAJ1W (ORCPT + 99 others); Fri, 1 Dec 2023 04:27:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378026AbjLAJ1F (ORCPT ); Fri, 1 Dec 2023 04:27:05 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96970A0 for ; Fri, 1 Dec 2023 01:27:11 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422830; 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=l1TO/DAtk+CCicSFDRPTxsBfrzcdsd2AUHicFvATynM=; b=lum7zhufPRoUPgr02L0+nr6ewMLlA4ZRnPpDBOK7AYfwxMTiURnHboUx9eXPXfeoKFWlWj 6K+fqA2/enXeTY+rxTb1bTvUDQYkIxGrDrSeYCwkD//wVE4rieb8koOh1FJ9VKWKxJwN8c q5GIv3tz1v6iJiiz2G8tevShutyRoQfx3C46SmF+O6uXo3GD6xEn8IhesLlwiSlwRNdOqM FawdCuytlVmtP3sAwki1uQ19SKXShRHkMkfB05uFcoe2elWHOYpMt7SLi2qpM36+ZHZwOy k7zjR6RvzhBQMC/lMuSWkxYfSLELuEZ774PPMwGX9rXn+QzoqxVdTm8Aw805Kw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422830; 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=l1TO/DAtk+CCicSFDRPTxsBfrzcdsd2AUHicFvATynM=; b=H7J7pHY41+OQTTMvDQDwvpdtt26MF/g+9en13VW2NJaVstqWvRjxzwwVa7UwAS0FehJC09 PPxAiRB4LLN99jBQ== 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 v9 06/32] timers: Do not IPI for deferrable timers Date: Fri, 1 Dec 2023 10:26:28 +0100 Message-Id: <20231201092654.34614-7-anna-maria@linutronix.de> In-Reply-To: <20231201092654.34614-1-anna-maria@linutronix.de> References: <20231201092654.34614-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,T_SCC_BODY_TEXT_LINE 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 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:27:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784071176682938173 X-GMAIL-MSGID: 1784071176682938173 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 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 --- v9: Only a typo fix 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 46a9b96a3976..a6e31b09637c 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 the CPU from entering dynticks and + * are not taken into account on the 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 + * the 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