From patchwork Wed Oct 4 12:34:35 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: 148277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp99271vqb; Wed, 4 Oct 2023 05:37:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEI1NtGK8pCoYWBZnKkB6ZPzCU4EnFvHnVhoTKp1chrB844PEJI9Kkn+XjpQ1DgJpl2Vr1K X-Received: by 2002:a05:6a21:a5aa:b0:15d:fc71:1b9e with SMTP id gd42-20020a056a21a5aa00b0015dfc711b9emr2850333pzc.49.1696423050343; Wed, 04 Oct 2023 05:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423050; cv=none; d=google.com; s=arc-20160816; b=fvxJE+xHuMN6wKEGi4tSYpO3l3rLLcu5I2F/g086tsEnCiSPllfcuQXRdaBLH18hEf whcZXO4VfnPHqAOFnxRNZbu3cRohZwifIMTeYgkOTJDSXf6EAg3VrKEpuaV8v8CqQ3gl e3J2MVTsvu2jJYgpkL/zLKGkKWZkvhSuzNqyi5HqRPMF+xY+oROQw3asp03Ilyc+iFVc kAIi/jIe6XyQ2GnsTtPh8VmAV4FGQxIg7exIZUrIbncOUCCh4me25i1Mi9d5yqQwH2Y/ iLzVLvO77K2OotY88mnEWzLhanT6lkaMNje0oFNpg5qdYf5tQNDK+lChKC/lQ9OZXBoh IsaA== 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=W54m7rvqf/KqCMpTV79oOtmZr9LItvdWHEN45lcUeaw=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=vieOwP1SFbs7kwijKG18mxnBygxpR7/DWpqbnWVPbnvqPCRW1IFs2YVRPv+GQJtYQY ycwziJfAA+nBkikaxKIhJZsQszPVpOIOm0SZlwQUiZ97gukc1ctaueSL0863FH6mieBB HLBOKxCxlJuwIzhGBBaE+O7OKNthXqR41K3zT9k8ElvDOy0GMLrirTSSiZLBr4eyhYIm cHku82QXbDtxxqThbHrMAcLoaiAkLDjvUnrvwVp1zh7VcXMgWJaX8lZLHFpZlhDLr8QL 6QjKZn/G4oH5q9U98TVEyiNUvrN9WYEo27wDF8BfTaMy0AG7zhneMUOG1AHjYRtOu2dC mhfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Efrc1xoo; dkim=neutral (no key) header.i=@linutronix.de; 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 j2-20020a056a00174200b0068fe0125a33si3711236pfc.37.2023.10.04.05.37.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:37:30 -0700 (PDT) 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=Efrc1xoo; dkim=neutral (no key) header.i=@linutronix.de; 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 A312A81ADCEB; Wed, 4 Oct 2023 05:37:16 -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 S242381AbjJDMfs (ORCPT + 18 others); Wed, 4 Oct 2023 08:35:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242362AbjJDMfd (ORCPT ); Wed, 4 Oct 2023 08:35:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A438193 for ; Wed, 4 Oct 2023 05:35:30 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422929; 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=W54m7rvqf/KqCMpTV79oOtmZr9LItvdWHEN45lcUeaw=; b=Efrc1xoorJOzy8tsALP1Bhr1M7Nxl+bJb/TLuAn1JJNB+EXwQE2BEjWHaW9r482myE0wWL uyLPSjVJw/V3m5a2xAAfe0w7iX/ytMsCbLv2tlTECGXATITJthK/1y6An9HyHv+7ky8UNx fnHJSOY2T7+agSXCrPYFIOj9ItFLcUo0G7iR/mN98qfQSUB2Ws3EteNzW/outR2GYMFdcx ZFt0ZjSVe6aKa5SGx5o1vMRv+CpHEF2kFZa1OL6kuHQgkcL0dIRC0Sc9kL61V9WnqSZppx f6yrhTvO2oWkhTA1l9pdm8ybiwUDZcfyp9uv9BD0L4FC9nMTEMZCKyY5jcB3Pw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422929; 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=W54m7rvqf/KqCMpTV79oOtmZr9LItvdWHEN45lcUeaw=; b=HnIgZMU7Y2g9X5WBxvEHh86H4zJMqVCS4RU8TGz0WgX52KTUJ1COlkvacxUBh/tihoDYYG 6WDL1TBNzELczOCg== 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 06/25] timers: Split out forward timer base functionality Date: Wed, 4 Oct 2023 14:34:35 +0200 Message-Id: <20231004123454.15691-7-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 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:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828496788253464 X-GMAIL-MSGID: 1778828496788253464 Forwarding timer base is done when the next expiry value is calculated and when a new timer is enqueued. When the next expiry value is calculated the jiffies value is already available and does not need to be reread a second time. Splitting out the forward timer base functionality to make it executable via both contextes - those where jiffies are already known and those, where jiffies need to be read. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 31aed8353db1..2f6afd1da891 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -939,30 +939,34 @@ get_target_base(struct timer_base *base, unsigned tflags) return get_timer_this_cpu_base(tflags); } -static inline void forward_timer_base(struct timer_base *base) +static inline void __forward_timer_base(struct timer_base *base, + unsigned long basej) { - unsigned long jnow = READ_ONCE(jiffies); - /* * Check whether we can forward the base. We can only do that when * @basej is past base->clk otherwise we might rewind base->clk. */ - if (time_before_eq(jnow, base->clk)) + if (time_before_eq(basej, base->clk)) return; /* * If the next expiry value is > jiffies, then we fast forward to * jiffies otherwise we forward to the next expiry value. */ - if (time_after(base->next_expiry, jnow)) { - base->clk = jnow; + if (time_after(base->next_expiry, basej)) { + base->clk = basej; } else { if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk))) return; base->clk = base->next_expiry; } + } +static inline void forward_timer_base(struct timer_base *base) +{ + __forward_timer_base(base, READ_ONCE(jiffies)); +} /* * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means