From patchwork Wed Mar 1 14:17:34 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: 62910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3657663wrd; Wed, 1 Mar 2023 06:21:11 -0800 (PST) X-Google-Smtp-Source: AK7set+TvG2NQ1cNo74q0CGaONjzdRllkU2TL8+VKrmWk83Mc8YTua8kWSgVlT4dbXAVsJRF22Da X-Received: by 2002:a17:907:2ce2:b0:874:e17e:2526 with SMTP id hz2-20020a1709072ce200b00874e17e2526mr8995379ejc.72.1677680471730; Wed, 01 Mar 2023 06:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677680471; cv=none; d=google.com; s=arc-20160816; b=RW5/NhadoZdJXww5tHfBE522RNDxJCRgyseOu4eZRR72cPHyv2fvM/yAZiYftZtwkZ UOtK5qOXJ0ktSckdESaLT0j+nMdP109SaUl45q7lm1kvsnx8QIRRakzazEdw917qth4s DMj9tZ/bjvERP5ti3r8HuItBn+IMpf2hie709JNon9f2WHrCxv1xgVMaenSD7EkqlReb 1CJAH+2ubN8ULkvnJDkmUeS86NGmnhpVc2fNjZbRKHHMip7Vb3xAVibbPZK6B/slRSdJ eF3X/T+9jTiiQeP7lAbZTxD3Lp8LqtACT1LpUBnUG1RWFxyXBJo9BJGlE30e4P/OhJyH mMVQ== 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=DTQzvJTD2qoYsldLldPQ4blVqjcabsGVyHc0OvLoC/I=; b=KE9vsLo0qy5Nm/tutt21NS+EIF/0u+g7m5ncNcuEZzIG92mU2K7ltZEFIOQjSRePNK oG8W5Wtq8Ce9Aimfy+I6zd/USNA3NEO2riN3lizcdYV+XTyt9QrpyE7HlrfVhoH6OFhS yXeM0azySxbngfr4DGgmji0nyL4CC8hGZkvQoehnSSKMq27mW3tNPeeOiZ04J9u8rwb5 KUaroVUN/U3vAqPSQRIj52RDbD8SGBGDtrcTkBWGyzK1xhycwEH+L4oMMwo0KdXIMxpy H4Y2TmiBzORVEV8Ro9bPIYFB9UUK/4UTP7SDQ6Yeq7a2UgA77SBSFV7xaIk+7apUbMu6 ozmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SmV1bpGL; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gx1-20020a1709068a4100b008dd83608278si1228266ejc.933.2023.03.01.06.20.48; Wed, 01 Mar 2023 06:21:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SmV1bpGL; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbjCAOSv (ORCPT + 99 others); Wed, 1 Mar 2023 09:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjCAOSJ (ORCPT ); Wed, 1 Mar 2023 09:18:09 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF2732FCC3 for ; Wed, 1 Mar 2023 06:18:07 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1677680286; 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=DTQzvJTD2qoYsldLldPQ4blVqjcabsGVyHc0OvLoC/I=; b=SmV1bpGLnAae9OlLTD1SsP39Ud6P4rQIb994A1U9VKBb/SJZl6xNzz1ZYJzP5wRqB3IT9Z 35oxpmI1i+UnVHUhbtz89fgJJASZ9e11ITJJcn9IKFO4+ePY5Fd7fQ/Q4Ksw2vXeYD7ZMJ C+8R7Le8DvWN4n7o6ZJmMbnomaYq+0XUjXwTHt7umvwdQrZ+x9kDq4qc7fArljDpEmkPsU iXgSD9upMvchB1VTV//NTrwRNrWxjDxqJLDRJq2IxRbaI1a3Nk/G7ugV3gmeYWqIV9xkN/ S1Djvqv53WKQGJwBjlNyDTNfSpsxWXf7dhMyiIfc2WE39VTfXW4dhZPfb3NHYA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1677680286; 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=DTQzvJTD2qoYsldLldPQ4blVqjcabsGVyHc0OvLoC/I=; b=Zyfi9TyrvM+Yp7g0q5mAPA+mQMbBrNyodh5McLxyN6tsfNnYQCU1aSEhKwu3kzMjUejJi2 Njzexu+OoLjhKFBw== 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 , Anna-Maria Behnsen Subject: [PATCH v5 08/18] timers: Create helper function to forward timer base clk Date: Wed, 1 Mar 2023 15:17:34 +0100 Message-Id: <20230301141744.16063-9-anna-maria@linutronix.de> In-Reply-To: <20230301141744.16063-1-anna-maria@linutronix.de> References: <20230301141744.16063-1-anna-maria@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759175478227832784?= X-GMAIL-MSGID: =?utf-8?q?1759175478227832784?= The logic for forwarding timer base clock is splitted into a separte function to make it accessible for other call sites. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v5: New patch to simplify next patch --- kernel/time/timer.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index d3e1776b505b..1629ccf24dd0 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1921,6 +1921,21 @@ static unsigned long next_timer_interrupt(struct timer_base *base) return base->next_expiry; } +/* + * Forward base clock is done only when @basej is past base->clk, otherwise + * base-clk might be rewind. + */ +static void forward_base_clk(struct timer_base *base, unsigned long nextevt, + unsigned long basej) +{ + if (time_after(basej, base->clk)) { + if (time_after(nextevt, basej)) + base->clk = basej; + else if (time_after(nextevt, base->clk)) + base->clk = nextevt; + } +} + /** * get_next_timer_interrupt - return the time (clock mono) of the next timer * @basej: base time jiffies @@ -1952,15 +1967,9 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) /* * We have a fresh next event. Check whether we can forward the - * base. We can only do that when @basej is past base->clk - * otherwise we might rewind base->clk. + * base. */ - if (time_after(basej, base->clk)) { - if (time_after(nextevt, basej)) - base->clk = basej; - else if (time_after(nextevt, base->clk)) - base->clk = nextevt; - } + forward_base_clk(base, nextevt, basej); /* * Base is idle if the next event is more than a tick away. Also