From nobody Mon Dec 29 05:03:57 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 520FDC4167B for ; Fri, 1 Dec 2023 09:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378215AbjLAJ2T (ORCPT ); Fri, 1 Dec 2023 04:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378145AbjLAJ1x (ORCPT ); Fri, 1 Dec 2023 04:27:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94EEC19BA for ; Fri, 1 Dec 2023 01:27:21 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422840; 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=1gYaVFuPoy5UW7Ox9DtRT+q6BrvDn/y7/UpgVZp13oQ=; b=PAq/TcXiBr3vZ/bkP9wgwgb+f+unPFLW+vAXzRt+6k89zhx2iT2ghtEO3DDzYolFQNZOSV Dca4vwfGYpZBDms4ilYjqB8hCoVv4jZuEZgU0QzHrKNk/pGZQgajCQo0/Aek2w1bmQfPC/ 5j4+ejwW8gzdI+22p3K0gko4dopIc4xJmfa4JJaKSzGLhapw4mozgr5/AE8c84BjKIWsFW +0VqVw+gdHK/+qHoLWNSRGcBUSLz/GJFhC9yJO/P42yvOvG6j1Jx5SEdqYP1ysDymvxjUo YmERn21/1bO1ajNJRbIUovB2JPf81tx2v0ls0z/9nr6Djonmo1rE3Eqao/xqcQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422840; 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=1gYaVFuPoy5UW7Ox9DtRT+q6BrvDn/y7/UpgVZp13oQ=; b=CMqrDpwUb7eN+9HpKDodq8mpQY1W2MPkSZ2JjOUoBa5afMYeE9Fk/f8rGRM2JQgxmB4BPk YINYi1ThYLanF4CA== 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 v9 19/32] timers: add_timer_on(): Make sure TIMER_PINNED flag is set Date: Fri, 1 Dec 2023 10:26:41 +0100 Message-Id: <20231201092654.34614-20-anna-maria@linutronix.de> In-Reply-To: <20231201092654.34614-1-anna-maria@linutronix.de> References: <20231201092654.34614-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" When adding a timer to the timer wheel using add_timer_on(), it is an implicitly pinned timer. With the timer pull at expiry time model in place, TIMER_PINNED flag is required to make sure timers end up in proper base. Add TIMER_PINNED flag unconditionally when add_timer_on() is executed. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 0ce0e6b25482..ea94479ee7e2 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1284,7 +1284,10 @@ EXPORT_SYMBOL(add_timer_global); * @timer: The timer to be started * @cpu: The CPU to start it on * - * Same as add_timer() except that it starts the timer on the given CPU. + * Same as add_timer() except that it starts the timer on the given CPU and + * the TIMER_PINNED flag is set. When timer shouldn't be a pinned timer in + * the next round, add_timer_global() should be used instead as it unsets + * the TIMER_PINNED flag. * * See add_timer() for further details. */ @@ -1298,6 +1301,9 @@ void add_timer_on(struct timer_list *timer, int cpu) if (WARN_ON_ONCE(timer_pending(timer))) return; =20 + /* Make sure timer flags have TIMER_PINNED flag set */ + timer->flags |=3D TIMER_PINNED; + new_base =3D get_timer_cpu_base(timer->flags, cpu); =20 /* --=20 2.39.2