From nobody Wed Sep 10 02:01:38 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B52FE7B604 for ; Wed, 4 Oct 2023 12:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233238AbjJDMgH (ORCPT ); Wed, 4 Oct 2023 08:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242399AbjJDMfn (ORCPT ); Wed, 4 Oct 2023 08:35:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 670A8E8 for ; Wed, 4 Oct 2023 05:35:35 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422934; 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=mz5QdBnNgn288WAkuPYs1KdwbgiRL6T25mdaPooSrW8=; b=dcV/kah2sZANpyHtK1hKbSQiHNfz+pTcJF2EgsNt7jDpGibYjJsseIJ7OFgnJMkHFiv3p2 /pbWKF0G4x6E3qkx2rEANukPZvRYE1LHnMXvnEc0VSk7n1BnDGThcVuwfs7+fWy4PGfXiF m6Ktz2/fpAJR4AEpNbwPzA176y6uo/OHjupwRhUnC6boE1L07Gbka/dayr5kIc4PQt9GMu EUk86yjNl4sTOh8cfbdkIOKy6o99zD2Dx/pZ+BSZgQIMQY6U9PMg94SFos12YntSw1yhmY j3nz4JCISPYPboOLSG0QxW5N7DpZKPC0PrBxcGPqnCNwGh0taOVkx5dZTfFZpw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422934; 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=mz5QdBnNgn288WAkuPYs1KdwbgiRL6T25mdaPooSrW8=; b=6yDPT0oLpbTKkm3ZNkk1/ZTUhSmoN0AelRNlyHvFGnRA2sh9eda4y8KSlCP0/klza4pdeO o+ABVbI11HfuZcAA== 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 14/25] timers: Ease code in run_local_timers() Date: Wed, 4 Oct 2023 14:34:43 +0200 Message-Id: <20231004123454.15691-15-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The logic for raising a softirq the way it is implemented right now, is readable for two timer bases. When increasing numbers of timer bases, code gets harder to read. With the introduction of the timer migration hierarchy, there will be three timer bases. Therefore ease the code. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v5: New patch to decrease patch size of follow up patches --- kernel/time/timer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 853a8ee48ffc..1aafa0edc74c 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2123,16 +2123,14 @@ static void run_local_timers(void) struct timer_base *base =3D this_cpu_ptr(&timer_bases[BASE_STD]); =20 hrtimer_run_queues(); - /* Raise the softirq only if required. */ - if (time_before(jiffies, base->next_expiry)) { - if (!IS_ENABLED(CONFIG_NO_HZ_COMMON)) - return; - /* CPU is awake, so check the deferrable base. */ - base++; - if (time_before(jiffies, base->next_expiry)) + + for (int i =3D 0; i < NR_BASES; i++, base++) { + /* Raise the softirq only if required. */ + if (time_after_eq(jiffies, base->next_expiry)) { + raise_softirq(TIMER_SOFTIRQ); return; + } } - raise_softirq(TIMER_SOFTIRQ); } =20 /* --=20 2.39.2