From nobody Fri Jun 19 08:36:03 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 E6EEBC4321E for ; Wed, 6 Apr 2022 00:26:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1588436AbiDFAP7 (ORCPT ); Tue, 5 Apr 2022 20:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573544AbiDETUH (ORCPT ); Tue, 5 Apr 2022 15:20:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B73DEBB90 for ; Tue, 5 Apr 2022 12:18:07 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649186285; 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=69oCF78NKr1jl3sMedzA5+keaKCiGKe+Lwryd6u9+Y4=; b=iooJrb7NzGc5sceMz1JIDxoTm5+DArmCDQ1EzZzHPd14qYEvpZ3hzotJ6lvR6kaLUZHd0x vDTF283VzULVRwCDEM8azIbwiC/jHa1zkgEtP3OMvBkpHa3XSC1rWFSE/XWuyHCj9Hquyv 7OwZvi3c+959JDcLo9LUyMjtAv2ulb+KY+AFtLI/pVd5V1B9XNpbuO277F6xaxg2Xyb0bK zZ7vrxdVAXRnxtrBRkfLRpyrYKSyG2pRWL+pqibppfweTp3X/KDc6HBt8JAsc3QDZ32mOA f9bQeOayvqbz9DTDW0/q/AI6BEeSGtdHyL885qRorhroWvqbZIJAUHAE5wyYoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649186285; 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=69oCF78NKr1jl3sMedzA5+keaKCiGKe+Lwryd6u9+Y4=; b=LZzmf/FdVllf6Du1IsHVYJpfEemSP6ZKguYyqaxXSolfyK+cDtqCKw2kUX8I8hNVj1ej+r etWs0YDH0bGSnhAQ== To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Frederic Weisbecker Subject: [PATCH 1/2] timers: Initialize base::next_expiry_recalc during prepare cpu Date: Tue, 5 Apr 2022 21:17:31 +0200 Message-Id: <20220405191732.7438-2-anna-maria@linutronix.de> In-Reply-To: <20220405191732.7438-1-anna-maria@linutronix.de> References: <20220405191732.7438-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 base::next_expiry_recalc is not initialized to false during cpu bringup in HOTPLUG_CPU and is accidently true and no timer is queued in the meantime, the loop through the wheel to find __next_timer_interrupt() might be done for nothing. Therefore initialize base::next_expiry_recalc to false in timers_prepare_cpu(). Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 85f1021ad459..4af98e77cd78 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1950,6 +1950,7 @@ int timers_prepare_cpu(unsigned int cpu) base =3D per_cpu_ptr(&timer_bases[b], cpu); base->clk =3D jiffies; base->next_expiry =3D base->clk + NEXT_TIMER_MAX_DELTA; + base->next_expiry_recalc =3D false; base->timers_pending =3D false; base->is_idle =3D false; } --=20 2.20.1 From nobody Fri Jun 19 08:36:03 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 5165AC43219 for ; Tue, 5 Apr 2022 21:10:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350929AbiDEVJ4 (ORCPT ); Tue, 5 Apr 2022 17:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573545AbiDETUH (ORCPT ); Tue, 5 Apr 2022 15:20:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A72D7EBBBA for ; Tue, 5 Apr 2022 12:18:07 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649186285; 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=0nMItS7qCqiegQo1A0e1KdGXtjDBwpycBrPJsybEUo4=; b=sqKyNsLO5ZRoqbbiCvhK4JaM38b2Mh2U8EcEaUtUTi0Vr2lMQd75f4QVZgK3KRt315reLO SEkBpNt9baSqJ30dqbOi0YC5FMw2QI8Buj1hMfM9WbbYgX/C1+GozpZju6eWxVUgPpE1Ek RDUxuE41XelLEzZ4zFefIZVcvbO+f08HaqNxyA5lJ/SmAI2XG+uFUxFIfOBTBNipyTvUgd iEvKZGDwzpCQoHtsfBqe+L589sP7qqklNM+EdmGOy02fOZrEPfLqiinQ8sULVQNn5W3qJw Jgwzkofl4e6P/UfYZxBVUZy4Z42gt3Xd/25xfm2NmgkcYAAcGVmszRn4YN79lQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649186285; 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=0nMItS7qCqiegQo1A0e1KdGXtjDBwpycBrPJsybEUo4=; b=UUiXZZ4R04IUae1XNwVeR9Id8vQHmedvNK6eK3BV+Q9Ex4IVQRaq+wpNTSPFdKyA74yH4w B8Lj7QAuE1ljh7CQ== To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Frederic Weisbecker , Johannes Berg Subject: [PATCH 2/2] timers: Fix warning in __run_timers() Date: Tue, 5 Apr 2022 21:17:32 +0200 Message-Id: <20220405191732.7438-3-anna-maria@linutronix.de> In-Reply-To: <20220405191732.7438-1-anna-maria@linutronix.de> References: <20220405191732.7438-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 the timer base is empty, base::next_expiry is set to base::clk + NEXT_TIMER_MAX_DELTA and base::next_expiry_recalc is false. When no timer is queued until jiffies reaches base::next_expiry value, the warning for not finding any expired timer and base::next_expiry_recalc is false in __run_timers() triggers. To prevent triggering the warning in this valid scenario base::timers_pending needs to be added to the warning condition. Fixes: 31cd0e119d50 ("timers: Recalculate next timer interrupt only when ne= cessary") Reported-by: Johannes Berg Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 4af98e77cd78..204d6cd83d0e 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1722,11 +1722,14 @@ static inline void __run_timers(struct timer_base *= base) time_after_eq(jiffies, base->next_expiry)) { levels =3D collect_expired_timers(base, heads); /* - * The only possible reason for not finding any expired - * timer at this clk is that all matching timers have been - * dequeued. + * The two possible reasons for not finding any expired + * timer at this clk are that all matching timers have been + * dequeued or no timer has been queued since + * base::next_expiry was set to base::clk + + * NEXT_TIMER_MAX_DELTA. */ - WARN_ON_ONCE(!levels && !base->next_expiry_recalc); + WARN_ON_ONCE(!levels && !base->next_expiry_recalc + && base->timers_pending); base->clk++; base->next_expiry =3D __next_timer_interrupt(base); =20 --=20 2.20.1