From patchwork Fri Dec 1 09:26:38 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: 172352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp991827vqy; Fri, 1 Dec 2023 01:28:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKlaoZwBLX5ezGHmdjSHhbWnKWyB5a1wlcS+UlWaeq7N+w/2zhHUOXSv/KKgivq3Fd7uPJ X-Received: by 2002:a17:90b:1d83:b0:285:adca:e8e7 with SMTP id pf3-20020a17090b1d8300b00285adcae8e7mr19146090pjb.5.1701422893134; Fri, 01 Dec 2023 01:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422893; cv=none; d=google.com; s=arc-20160816; b=Eo5NKMkVEHpyJ9OyPSA6QJVH3I/nEfSekBTSkEOuP7iWmoXrL/CxPt1g/nh0nvwl9l aZQCWqXWvkpWq4VZkw3VmF4yS2493N2GxmBfx2Teh2dM+7VACuhJ2XbTSgvqo738qz/O 3FLaVR/OondJ7iALkLnckweBOv9CnJ6Zh12TX2JLVbQaMfU2j+eBFTlHMgTXE4twYLgE mo5NzGFGnjzqO/1FGkYOJ4JbvR5VhrHFBQeBmzDkx0BislBXYrGFy8Ktpo75sb/rI4lJ E3WEcZceNbIqsXyycyXejm3D4C5p0KzkuaMCjdKNgBzhIaedYuVx4gddGgNIB1MDQ4Ln Rpaw== 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=nS3of1gsjpadmlTzOeKtxhnS0y1kmX6N3aik41bHBiA=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=i8PWzu8NNUDXsOocGUO3T/ugxKr7iTg8p7eB6G++xAekHByKKFxOUMIQhj5hXjfZfs t5aBBo94lB8wfqskVfU/cF152C3WbMaX7C8rJudx9nFeN32lmWo79U9YR6aFbdFmM/3V 2KDn/9OhW+MMdr5wV0Bg3Kc38WwI3r7bHL/bsxalqmRWSEJaEdEjkyUBSoMM/4wM3LHX 8SfAhk//L09iITize68k53Ay+9XeRoqJsnMkvCLbYLidXKZFLDL7KRiEe96mkluYt8LK VhYUNdEZ+tT2jwhp0Qi6rfFfd4W/09tsX8OBUknj/RSSrl26STXL8YkxNUzOPPOh6zXP pCyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jd8JdSo6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w8-20020a170902904800b001cfd4c10e47si2852892plz.8.2023.12.01.01.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:28:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jd8JdSo6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id D0B1A83D9B66; Fri, 1 Dec 2023 01:28:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378069AbjLAJ1y (ORCPT + 99 others); Fri, 1 Dec 2023 04:27:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378071AbjLAJ12 (ORCPT ); Fri, 1 Dec 2023 04:27:28 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE00B173B for ; Fri, 1 Dec 2023 01:27:18 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422837; 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=nS3of1gsjpadmlTzOeKtxhnS0y1kmX6N3aik41bHBiA=; b=jd8JdSo6RSMAzUQGD0eFZtqqXum4T5DNbkhKfHsGgfKrpZeYgvPMRbitqOvajGAVnOXjI6 CUwVNu95rNCy/L5GzK63NOh365EDVDrf9ayAK4msa7dXSpEa80xXUWomRi6duxWLFm+VbM qCr1hrcESNQGxbIdSVpGa6B5nMD7U+enDcqohqFlaqh/MYvEqE3lCzl2P2uDwny8GJ0pZb e+Y7Q5UkpxPIXt7kcmWi+U4AE9QBHs0PlQvwXPRBOBrT+RaB+0SEBxJG882s2281fx76As 0B3s31n61vB24z+VP0fxZkI3ZAtKnfsQ0JzpWsdc4wBnNvNXxSgu/bYlY0W5kw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422837; 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=nS3of1gsjpadmlTzOeKtxhnS0y1kmX6N3aik41bHBiA=; b=XvAVoft42FnLB6t8nWzHoq+keWMNp0u+ZuAOQmacO5++zBupzj5qe3N+KJ0loGqLT7o1ZZ rrBvtWXBA6WYHMAg== 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 16/32] timers: Optimization for timer_base_try_to_set_idle() Date: Fri, 1 Dec 2023 10:26:38 +0100 Message-Id: <20231201092654.34614-17-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=-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,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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:28:07 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784071211965782339 X-GMAIL-MSGID: 1784071211965782339 When tick is stopped also the timer base is_idle flag is set. When reentering the timer_base_try_to_set_idle() with the tick stopped, there is no need to check whether the timer base needs to be set idle again. When a timer was enqueued in the meantime, this is already handled by the nohz_get_next_event() call which was executed before tick_nohz_stop_tick(). Signed-off-by: Anna-Maria Behnsen --- v9: New, as this optimization was splitted from the patch before. --- kernel/time/tick-sched.c | 2 +- kernel/time/timer.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 3e1cdb7c6966..c6b415052c56 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -886,7 +886,7 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); unsigned long basejiff = ts->last_jiffies; u64 basemono = ts->timer_expires_base; - bool timer_idle; + bool timer_idle = ts->tick_stopped; u64 expires; /* Make sure we won't be trying to stop it twice in a row. */ diff --git a/kernel/time/timer.c b/kernel/time/timer.c index df6558f62e6f..177bcde8a2c0 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1996,13 +1996,18 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases * @basej: base time jiffies * @basem: base time clock monotonic - * @idle: pointer to store the value of timer_base->is_idle + * @idle: pointer to store the value of timer_base->is_idle on return; + * *idle contains the information whether tick was already stopped * - * Returns the tick aligned clock monotonic time of the next pending - * timer or KTIME_MAX if no timer is pending. + * Returns the tick aligned clock monotonic time of the next pending timer or + * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is + * returned as well. */ u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle) { + if (*idle) + return KTIME_MAX; + return __get_next_timer_interrupt(basej, basem, idle); }