From nobody Tue Feb 10 17:07:56 2026 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 E08CEC7EE23 for ; Wed, 24 May 2023 07:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239785AbjEXHHl (ORCPT ); Wed, 24 May 2023 03:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239820AbjEXHHF (ORCPT ); Wed, 24 May 2023 03:07:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BAE518C for ; Wed, 24 May 2023 00:07:02 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684912020; 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=LtOGw35GRW9p2fx5MhyE24mUeYiFRQ6uZYmjDalJe0M=; b=J1ihm9QiV4eErwTOiXLtydZzQk3ZK591reJ8uJyZTe8PlOFAGOPpxGKB4PK4S9LUjSiXfx s0IHM/t8ILeKVq8J2Tybkwosbf9Waslq6LF0yICYluaiKWz7tzJgBFRbf/7W/Y3nTbtWtL 9iaRJWDGkF7HxumBGNLnzEeO4WIbq8OgJwF+2Nz7dCXTDT9B6t+YWwHb5NnmF8TkvXiOYu IlMVewgLwFHGSEz38RTO15XSCkKlOMz/7gWCG29FxL3bBFZZkVon6pSgeN6kcXdI1i58sv 0/MDRoCchmw1RCJmf2+fR2AhZBj1MrbscuE9ZqlXm0GN5jI5LQ2kMN9hpd4gOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684912020; 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=LtOGw35GRW9p2fx5MhyE24mUeYiFRQ6uZYmjDalJe0M=; b=soTl8kB1cMiSPqjYY9ZdsFWoSmHOD953MyBsWjikDlSOk0eXI+4qAvO23ttFYxqFpya9TC 3g5Vrw9Fzpu64oAA== 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" , Anna-Maria Behnsen , Frederic Weisbecker Subject: [PATCH v7 10/21] timers: Ease code in run_local_timers() Date: Wed, 24 May 2023 09:06:18 +0200 Message-Id: <20230524070629.6377-11-anna-maria@linutronix.de> In-Reply-To: <20230524070629.6377-1-anna-maria@linutronix.de> References: <20230524070629.6377-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 b7599216d183..749b1570bdcd 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2093,16 +2093,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.30.2