From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7A382356A23 for ; Tue, 27 Jan 2026 14:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769525445; cv=none; b=pPV8DZGfN4Glr4jwUm4YCghctZdyUi+5FrcjCR/Nen05vhP89bst2IFHdzEsKD8lo5EFDPcce23n0KrdpgU0jZSgndVqVatypP9oKerBImTbv1YE6EES/yo2vFkP1BUAvsvqC3C9fcZPYnAMRGdO469BDC2i46XjNY8kBnDc+B4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769525445; c=relaxed/simple; bh=ay3pZQDRF97nNVH8DuaIqALNroUuzZsM+jkTUm5PlCA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o3Et1KBhTnnN/OSjfyBJ02JTH36TVG9eo4UnRAqHdagvV2ThQbQgZSmm1VU8Sk7tRP+RikFIPPzNu1dmCMACkFafyf2QKvySXwjFrgJ5xrTyTWR2pGXMTYtaitpF4C3DLHDuFoj10pp0QFL/6t9cSCBfOz4Evcvmp/BwI2Z1RTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=miUJGYVK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="miUJGYVK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F4AC116C6; Tue, 27 Jan 2026 14:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769525445; bh=ay3pZQDRF97nNVH8DuaIqALNroUuzZsM+jkTUm5PlCA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=miUJGYVKGbfJZ5zytM5ABmshAh17QJTdIpxH41VaSuXPhvEfK0GlbSSHgrEXGtk0E vnsG77wUe3OM+aMRJ9i042UJJK6AeG1GF9hOf+NnuM6mEd9AJZ8uMGBkwoXtIDc3xm kMDUL+RpneKXHw177QghTHdaZWs5WLNCCODJg5XRQ+n8HkF60qHcaIjA21mEembS8j vGR6jpnxahJ4KotEdC/oblp8b0aM5UL9HVcLsJHjlPpTr0/YNiiXFKFUtogy82e9Hk owlHhp3bNMZkWD28Dw8Ai0fHx4k1DM5QI7et3L3onA9/PdDANh50YFXyj1Hl4gzNou 9BCmU5pxuKiPQ== Date: Tue, 27 Jan 2026 15:50:42 +0100 From: Frederic Weisbecker To: Jinjie Ruan Cc: anna-maria@linutronix.de, tglx@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] timers: Replace get_timer_this_cpu_base() with get_timer_cpu_base() Message-ID: References: <20260123084715.365857-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260123084715.365857-1-ruanjinjie@huawei.com> Le Fri, Jan 23, 2026 at 04:47:15PM +0800, Jinjie Ruan a écrit : > get_timer_this_cpu_base() is only used in __mod_timer() where the timer > base lock is already held via raw_spin_lock_irqsave(). In this context, > preemption is disabled and the CPU number cannot change, making > raw_smp_processor_id() safe to use. > > Since get_timer_cpu_base() provides identical functionality using > raw_smp_processor_id(), replace get_timer_this_cpu_base() with > get_timer_cpu_base() to eliminate code duplication. > > No functional change intended. > > Signed-off-by: Jinjie Ruan > --- > kernel/time/timer.c | 16 +--------------- > 1 file changed, 1 insertion(+), 15 deletions(-) > > diff --git a/kernel/time/timer.c b/kernel/time/timer.c > index 1f2364126894..5a827e09cb8f 100644 > --- a/kernel/time/timer.c > +++ b/kernel/time/timer.c > @@ -925,20 +925,6 @@ static inline struct timer_base *get_timer_cpu_base(u32 tflags, u32 cpu) > return per_cpu_ptr(&timer_bases[index], cpu); > } > > -static inline struct timer_base *get_timer_this_cpu_base(u32 tflags) > -{ > - int index = tflags & TIMER_PINNED ? BASE_LOCAL : BASE_GLOBAL; > - > - /* > - * If the timer is deferrable and NO_HZ_COMMON is set then we need > - * to use the deferrable base. > - */ > - if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && (tflags & TIMER_DEFERRABLE)) > - index = BASE_DEF; > - > - return this_cpu_ptr(&timer_bases[index]); > -} > - > static inline struct timer_base *get_timer_base(u32 tflags) > { > return get_timer_cpu_base(tflags, tflags & TIMER_CPUMASK); > @@ -1098,7 +1084,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option > if (!ret && (options & MOD_TIMER_PENDING_ONLY)) > goto out_unlock; > > - new_base = get_timer_this_cpu_base(timer->flags); > + new_base = get_timer_cpu_base(timer->flags, raw_smp_processor_id()); Ok but this should be smp_processor_id() since we expect IRQs to be disabled. Thanks. > > if (base != new_base) { > /* > -- > 2.34.1 > -- Frederic Weisbecker SUSE Labs