Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp904658rdb; Fri, 1 Dec 2023 01:28:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5s3h7IrEbkvyjqKWJZ+74pkU4LoCj2OckhKNxn7X04vjJwtZg4VLqwrpYPvNwKjq6eA0i X-Received: by 2002:a05:6a20:d704:b0:18b:3297:3e1a with SMTP id iz4-20020a056a20d70400b0018b32973e1amr28225111pzb.47.1701422905074; Fri, 01 Dec 2023 01:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422905; cv=none; d=google.com; s=arc-20160816; b=tY2rIjNl5X/3g17daSsT75AF886pcSs9g8vVN5Zgy/GAIIeZmofpFFbMIDqt8c3+6q STjlisRvMnTiy94gt0brq07y+86YDt/5z4z32JgQotX0NY6AN3WIDZkncyvhhDhX+vpt eJ4SPpf9+6Fto0ezwUM+ZOyzJU+XGk2zT5PqNeiKu1hGdmpnyPi4VkUpT6kUpo2pndgu 5Lj82VhEi2MIyndxL0VYRdy4oJixLQ8FZnWh2/5OaFRhnYnmLYrhLO1+7+xmw6GEiy4C KteMDWGIeHkVVA5VS8FIVJ20SHNWzeYBeLGZY0mf3kw8u4wqVOarM1ClSYos0YLPEuEt cL6g== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id f10-20020a056a0022ca00b006cddd78a8f1si3043694pfj.27.2023.12.01.01.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:28:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 176E383D9B6B; Fri, 1 Dec 2023 01:28:18 -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 Content-Transfer-Encoding: 8bit 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=unavailable 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:18 -0800 (PST) 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); } -- 2.39.2