Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp473807rdb; Thu, 22 Feb 2024 09:13:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpspmK9jFxrguXE/13gd360jyG+4cfc2VOAmU7f1mr1+qqje6kapiP6li0ZBMdOSHdlJ/f/kpRvsCzVOv8Bmz0IwxYtnq12L0WLxIYDg== X-Google-Smtp-Source: AGHT+IEbq5F2UGk9X6Kx2byshQfMCZclLouFh9BtwnUPbk5hFikgwxCU/KfEWzyecLfFduHuaBkE X-Received: by 2002:a05:6871:2b0f:b0:21f:22a6:c0e5 with SMTP id dr15-20020a0568712b0f00b0021f22a6c0e5mr8797000oac.52.1708622022829; Thu, 22 Feb 2024 09:13:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622022; cv=pass; d=google.com; s=arc-20160816; b=BgwOi4FZnTNX7EKCqDJjoFREFBpFd2IGui+8clD6sEutJf0Ry5FcOklXzNCixPLi1o cXgrqObzwWvWSWmHLwEpRVyJVmfx15Rv3dFDYM36fKJzkULMGfVyYkw6qBKd0lwUoGYE c+DK2KKzr8pr31lxglS6k0JdoMaINYlXvr+VPVmktjwf3wYhcNTfGl5j2DQAgEAf18V6 yNiKvTroNwZSXQdBEU8vKTiIRML1XPD5W5Awrb9d1cEB1DvwpqAEOSkLFuS0XZqnMYKE e9wmtiTOCg7FncCuU5zQGF7nlyBihjgxOMqX4d374n7GIKxqT9dkhy+/+mOpI5mwJ3Je W1bQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=gxu6BvrUkKydEe7CgoO8F5VBZOS7beatE9R6vgMaZZg=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=SPBjoJE1GI9SPDt8JJb7sXhzgz/xopRCAedhq1/gbdHjSU+h/DLDg3N5z9yf/HJv2Z kDKqccqOiVPUGqfbLiGFoSYDogmaFOyNWMX87Gpu31ObuviTqhbHrlPOgVwRxYt+B0Zb Hob07pWEBU/4VO6Ty9IJjR89UL+z44DwBnQYMJyBAh0SiaIgj6mbGAqrz5SjSd6bZXBZ cBY0N+/aBnkrRwCx6QvP1gDdUZnYh/sfOvZL3r8OdmRExbC56STjueCwqiyPtzkJPGXU muOE/4tZGDFzqPNdQmbviuIPzZLoYUaxdOvVIkEKN26MlX9LUMOldnjC2qKX6JmccAHG m89w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R+6jPuIe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=L+egk84S; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-76942-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n21-20020a638f15000000b005dc8a2e415dsi10696693pgd.480.2024.02.22.09.13.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76942-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R+6jPuIe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=L+egk84S; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-76942-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7EA4628B56F for ; Thu, 22 Feb 2024 17:13:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA21D1586F6; Thu, 22 Feb 2024 17:12:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="R+6jPuIe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="L+egk84S" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C7E3157E66; Thu, 22 Feb 2024 17:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621936; cv=none; b=SgC264zp9mh9CbL5+xOfvXSRkLO6Zi8/iUdO9ByRSR1eazbhDj8BS5gGfuaihu06whL2zIzfzYSTbreNYeuQw5v8D5yZSim3IonbDfoaXzRN9P3LmMCF75Us2lFAXesNv/kvRPdpHOgtDDxqmFK4QnbYgLpN5ey6Elciy/caEUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621936; c=relaxed/simple; bh=ywyKU2i+iIGKnVYxExQHGgbYNFBNoBGEoymVEtbF69E=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=dlviTPZVornhswU3UAfpa667v5dLqCe2maby+Fi9Zdydt8szAe+zu/2QnCbT6wsdeD3ahK5coHrWk+V5+/qmGK9QvRkaPY0+h078VI6BnQBImptxjSJiPivxeaHJD6sqmP01SrOM9DgYCIQdxSigMJjM7wUxOQFwjcSvKJ8dhtA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=R+6jPuIe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=L+egk84S; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Thu, 22 Feb 2024 17:12:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708621932; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gxu6BvrUkKydEe7CgoO8F5VBZOS7beatE9R6vgMaZZg=; b=R+6jPuIe2QUokAGPZIKVMvGz6XVQeDd9EpDNW11l7hJelaHiwps3yNRUrym8cFShpAt0P2 ERCFgdE0NCsV2+VxmPbyRYJ1W8mIqJpmGTk1qkCyxRMUAB2PlDY+ckM6+Y3cDFTqb2GEYu aOopgRAKvDVJ8usqR/7pSx77nkAm/elY4yGgL9xmVKT9+isOl+SUvPNahGiyqXe6We2WfY HCFFzMgZ/ucryK0XOedaBaVRscNIUuYlA1dAxZZn44i35c8PSvfMP6mmuQv0pYcNmrkIiE 1FJj2LChrj+X3eGwBnD5aOuV9JN8grI/Hpr3fQ3fDH8GmI1iGgAAEaQx7GAVqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708621932; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gxu6BvrUkKydEe7CgoO8F5VBZOS7beatE9R6vgMaZZg=; b=L+egk84S5Xai24ptoWB2pC38UwwLlzT31Rpo70tyofCId+MQgTEDO7utqiWYMfF6ZiAP09 tHELDETPI5l9mpAQ== From: "tip-bot2 for Anna-Maria Behnsen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Split next timer interrupt logic Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221090548.36600-10-anna-maria@linutronix.de> References: <20240221090548.36600-10-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170862193196.398.1092617001269334520.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the timers/core branch of tip: Commit-ID: 9f6a3c602c235c3cccbe673fb7e1cca30ca4be0d Gitweb: https://git.kernel.org/tip/9f6a3c602c235c3cccbe673fb7e1cca30ca4be0d Author: Anna-Maria Behnsen AuthorDate: Wed, 21 Feb 2024 10:05:37 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 22 Feb 2024 17:52:31 +01:00 timers: Split next timer interrupt logic Split the logic for getting next timer interrupt (no matter of recalculated or already stored in base->next_expiry) into a separate function named next_timer_interrupt(). Make it available to local call sites only. No functional change. Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20240221090548.36600-10-anna-maria@linutronix.de --- kernel/time/timer.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 9c8443d..748f4b7 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1996,12 +1996,29 @@ static u64 cmp_next_hrtimer_event(u64 basem, u64 expires) return DIV_ROUND_UP_ULL(nextevt, TICK_NSEC) * TICK_NSEC; } +static unsigned long next_timer_interrupt(struct timer_base *base, + unsigned long basej) +{ + if (base->next_expiry_recalc) + next_expiry_recalc(base); + + /* + * Move next_expiry for the empty base into the future to prevent an + * unnecessary raise of the timer softirq when the next_expiry value + * will be reached even if there is no timer pending. + */ + if (!base->timers_pending) + base->next_expiry = basej + NEXT_TIMER_MAX_DELTA; + + return base->next_expiry; +} + static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem, bool *idle) { struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); - unsigned long nextevt = basej + NEXT_TIMER_MAX_DELTA; u64 expires = KTIME_MAX; + unsigned long nextevt; /* * Pretend that there is no timer pending if the cpu is offline. @@ -2014,24 +2031,13 @@ static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem, } raw_spin_lock(&base->lock); - if (base->next_expiry_recalc) - next_expiry_recalc(base); + nextevt = next_timer_interrupt(base, basej); if (base->timers_pending) { - nextevt = base->next_expiry; - /* If we missed a tick already, force 0 delta */ if (time_before(nextevt, basej)) nextevt = basej; expires = basem + (u64)(nextevt - basej) * TICK_NSEC; - } else { - /* - * Move next_expiry for the empty base into the future to - * prevent a unnecessary raise of the timer softirq when the - * next_expiry value will be reached even if there is no timer - * pending. - */ - base->next_expiry = nextevt; } /*