From patchwork Wed Oct 4 12:34:47 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: 148270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp98775vqb; Wed, 4 Oct 2023 05:36:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX+4KXDgvvzQjqopHk7lYuEo9TSULAaSf7SeW3SEJBZVhNHlz8w2/ZhtNUK7XcnxUC/VVo X-Received: by 2002:a05:6a00:1993:b0:68e:2c3a:8775 with SMTP id d19-20020a056a00199300b0068e2c3a8775mr2433057pfl.33.1696423011469; Wed, 04 Oct 2023 05:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423011; cv=none; d=google.com; s=arc-20160816; b=FR92V1AVWSLZZbqedpqCwSznFgmsw4FEjjdHNQd6I54ZzkJOcqbrctUGOt4mXZOTWJ SpfucnVpOO5CULawQJMNme2kLfV/TeBuMJYzoQo9DDECn4B2G/TQVvlUJquHxJK8rjBo woXWJAywSKb99iju+pbxWSR6J5sx192gqBrT0LPxmd02VwG8sjW7YXVmmjcsQhsmCEdp aDEYJe19oYZL7p4xx/E48569HGL2/28ZL1wKK99XnE3//GBIBqg0AdEHeyKq/1dFKQnV Zn5AlyLlEAZYqwzvypGV2hvYUS2AGlPYlQyDG6sxzECyW3X+UwbOb5UytnZVQR9Bg15M OCfQ== 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 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id t23-20020a62d157000000b00690de92ffe3si3383530pfl.309.2023.10.04.05.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; 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 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 5581882516FB; Wed, 4 Oct 2023 05:36:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242465AbjJDMgY (ORCPT + 18 others); Wed, 4 Oct 2023 08:36:24 -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 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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:36:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828455806137398 X-GMAIL-MSGID: 1778828455806137398 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; }