Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2574185rdb; Wed, 4 Oct 2023 05:38:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFob6a9qPaLyvD+p6/w6V7/T1Jl8z/6jHeRKq5sqdtWAHWZO00cYQNNSN5WRCD4+tlBMZPB X-Received: by 2002:a05:6a00:1781:b0:690:2e46:aca3 with SMTP id s1-20020a056a00178100b006902e46aca3mr2690316pfg.25.1696423080090; Wed, 04 Oct 2023 05:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423080; cv=none; d=google.com; s=arc-20160816; b=d/fNpLM/+LsyWYDSqzvOhCVC5Cw57cwc13EwNQZJzVoRxMMmF/0lbbYO8nCRvRMgC6 TH5ZchHuQZF1RxG+3OMlNBEJnIUZyN19p5qpI1Xm08duFji+rMffrflCIJg0Gwh/ClYH 0UMvhHMhmMaNNg9LzPu41CSbYvo5w/RT6Gy1YGGotpjmcKSoiEYTzjux49kZ0jGdNwlF K+DfJnsxCSdH8mz026xC614CCVF65bWT3X4c2ALBSMeObttqHS695qyMLBSw5oWR66Bn otzupGrl5DGnDivWB2mWM2SCIhqnVMNetuhCE0B46M3Sapu4gfIeLClQPgEsNSiolkz0 4/GQ== 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=PYE4qjcpMvpvRPLtFGjkbKuz071Vlys4ffOshPkJzPM=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=A77cbnTuVD2SPhv9sXj3EU/H3XAiFnTpmlAfR7FrohPMDZCLNLAPVNePWObO9ZesGn B0By63YvJ/HE1rTlr0Ou3NnqbIKJ/h0eeOFJj/+PALt3h93JbBhMSdeNJPVZbQam87CN ASRqa5EXr1P7ccpnPY9vLbN1xZPF+zGG4Ieaqu2aFdswPWyC4BxV+P304gkAQyy0USuu Gs4lqJq2QJQTDqGI+tPPEPxk5CKnpcNhR8k9DJ3M83oiH4gxitK1WoBgKRGsohH8WSf5 I4iL5CpvYiEI1epzCOV+nB6LZy2ioRS01JeBBcm2S+lCSwwqEWEgHQVKW0hOiELIFMyp ayaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zB4VvhF4; 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 i5-20020a635405000000b00563d9ff5158si3517881pgb.350.2023.10.04.05.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:38:00 -0700 (PDT) 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=zB4VvhF4; 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 6B4F581ADCF1; Wed, 4 Oct 2023 05:37:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242544AbjJDMgX (ORCPT + 99 others); Wed, 4 Oct 2023 08:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242419AbjJDMfp (ORCPT ); Wed, 4 Oct 2023 08:35:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73EE106 for ; Wed, 4 Oct 2023 05:35:37 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422936; 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=PYE4qjcpMvpvRPLtFGjkbKuz071Vlys4ffOshPkJzPM=; b=zB4VvhF4vv/KNyy86ETm1uDqt4dNpl+dbiQYCpi/lMo7g23qLXbl+5zA2C1beMPiSDCANe 2D7HoBlrCPy0eMmmdBOVpyOiL2ZeB7DTpwGfE21dRqWZ4mtVuYXFlDzfl97wIDSsxTq5pX nUuX7qltUVYUlnelarpkoRqdX4r28jCSXB31y9GZPIV4nDXa8UAhl6yqbUhcL8UqX7lt3r Wnhj7QLc1fPVzZy/gWASE1JaclowXo6p0LJVMKeYWsvIqMjAjqHt8RUz0f4fyHAdnqkllW 6CMPygGZH8/cgCN3AnmoDC6mChROdKVMkFoSmb2NZGy5lmipXlts3+mw0yHbIg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422936; 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=PYE4qjcpMvpvRPLtFGjkbKuz071Vlys4ffOshPkJzPM=; b=gc7NqSHIVqrsBUySm1W+IZ8NZ7pgDH+rnNSRCK+1NYOTkHPp0LqWHr7uGCFD1W1iynhq1+ zgk4tZDZXYsdnTDw== 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 18/25] timer: Split out "get next timer interrupt" functionality Date: Wed, 4 Oct 2023 14:34:47 +0200 Message-Id: <20231004123454.15691-19-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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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]); Wed, 04 Oct 2023 05:37:44 -0700 (PDT) The functionality for getting the next timer interrupt in get_next_timer_interrupt() is split into a separate function fetch_next_timer_interrupt() to be usable by other call sites. This is preparatory work for the conversion of the NOHZ timer placement to a pull at expiry time model. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v6: s/splitted/split v5: Update commit message v4: Fix typo in comment --- kernel/time/timer.c | 51 +++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 4230fc6fa1ed..c3061b28214e 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1976,12 +1976,12 @@ static unsigned long next_timer_interrupt(struct timer_base *base) return base->next_expiry; } -static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64 basem, - struct timer_base *base_local, - struct timer_base *base_global, - struct timer_events *tevt) +static unsigned long fetch_next_timer_interrupt(unsigned long basej, u64 basem, + struct timer_base *base_local, + struct timer_base *base_global, + struct timer_events *tevt) { - unsigned long nextevt, nextevt_local, nextevt_global; + unsigned long nextevt_local, nextevt_global; bool local_first; nextevt_local = next_timer_interrupt(base_local); @@ -2000,21 +2000,6 @@ static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64 else local_first = base_local->timers_pending; - nextevt = local_first ? nextevt_local : nextevt_global; - - /* - * If the @nextevt is at max. one tick away, use @nextevt and store - * it in the local expiry value. The next global event is irrelevant in - * this case and can be left as KTIME_MAX. - */ - if (time_before_eq(nextevt, basej + 1)) { - /* If we missed a tick already, force 0 delta */ - if (time_before(nextevt, basej)) - nextevt = basej; - tevt->local = basem + (u64)(nextevt - basej) * TICK_NSEC; - return tevt->local; - } - /* * Update tevt->* values: * @@ -2028,6 +2013,32 @@ static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64 if (base_local->timers_pending) tevt->local = basem + (u64)(nextevt_local - basej) * TICK_NSEC; + return local_first ? nextevt_local : nextevt_global; +} + +static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64 basem, + struct timer_base *base_local, + struct timer_base *base_global, + struct timer_events *tevt) +{ + unsigned long nextevt; + + nextevt = fetch_next_timer_interrupt(basej, basem, + base_local, base_global, tevt); + + /* + * If the nextevt is at max. one tick away, use the @nextevt and store + * it in the local expiry value. Reset of next global event to KTIME_MAX + * to make sure it is ignored. + */ + if (time_before_eq(nextevt, basej + 1)) { + /* If we missed a tick already, force 0 delta */ + if (time_before(nextevt, basej)) + nextevt = basej; + tevt->local = basem + (u64)(nextevt - basej) * TICK_NSEC; + tevt->global = KTIME_MAX; + } + return nextevt; } -- 2.39.2