From nobody Tue Dec 2 02:20:28 2025 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (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 2B4A82DF148 for ; Wed, 19 Nov 2025 17:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763574360; cv=none; b=kV/WplT4A753MGqF6Q106cgPDEKBa3yUZagMgDTrdNzL3w48KnM9WOZUAKcKgm3Ti7XTINKIQlzjGfzkRS1U5PzolFzUCSEwYJJahJAijtWoLj6X8oCDju5J9FLIn9JX1iejwSbgqhkZVlCfGS10skYakIVLoN0Lqien3E/+1Xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763574360; c=relaxed/simple; bh=h+lYHIhsWNnA8y3WkiORQ7yMszT5A0b+52owjdCDZXo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=QtfD3KJLNrqCx1au8GPx3j2gQspNN+VJctejBqLrOtph3xlEe2gAGZQLm3hzj0d1q993+qgZ4T/GhsqgcdrIGshJZkiJHFxQVlkM++R9YdwLii20W23rcPNiX4RwKOEeg/6xYWfTccxIC9Ct6odgGUCOFcfGJdzgMqjasponJ1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Zjdh/YAX; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Zjdh/YAX" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763574350; 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; bh=muwiF57bLoGIHTqx8FROteg39SxxKIHdD+fmYMRRXsw=; b=Zjdh/YAXiHv2OqrFkbaDrxmWCJH9Vl0CqczK/jFRDIUyOvxpyl0jv4fxZ1BrPAyMlMf16S E7cGbDhss/ys7ldCUEg6PmS4i7pXmwnJEsr7rLDtoa6/Buh75QyrgRfjOExOapTdBJckYZ ZNsn/jIk94EDTSwwbRtmq9cFcSRb8ro= From: wen.yang@linux.dev To: Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , Thomas Gleixner Cc: Wen Yang , Paul Gortmaker , linux-kernel@vger.kernel.org Subject: [PATCH] tick/rcu: fix report_idle_softirq Date: Thu, 20 Nov 2025 01:45:25 +0800 Message-Id: <20251119174525.29470-1-wen.yang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Wen Yang In commit 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle") the new function report_idle_softirq() was created by breaking code out of the existing can_stop_idle_tick() for kernels v5.18 and newer. In doing so, the code essentially went from this form: if (A) { static int ratelimit; if (ratelimit < 10 && !C && A&D) { pr_warn("NOHZ tick-stop error: ..."); ratelimit++; } return false; } to a new function: static bool report_idle_softirq(void) { static int ratelimit; if (likely(!A)) return false; if (ratelimit < 10) return false; ... pr_warn("NOHZ tick-stop error: local softirq work is pending, handle= r #%02x!!!\n", pending); ratelimit++; return true; } commit a7e282c77785 ("tick/rcu: Fix bogus ratelimit condition") realized the ratelimit was essentially set to zero instead of ten, and hence *no* softirq pending messages would ever be issued, but fix it as: - if (ratelimit < 10) + if (ratelimit >=3D 10) return false; However, this fix introduces another issue: When ratelimit is greater than 10, even if A is true, it will directly return false. While ratelimit in the original code is only used to control printing and will not affect the return value. This patch fixes the above issues. Fixes: 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle") Fixes: a7e282c77785 ("tick/rcu: Fix bogus ratelimit condition") Signed-off-by: Wen Yang Cc: Paul Gortmaker Cc: Thomas Gleixner Cc: Frederic Weisbecker Cc: Anna-Maria Behnsen Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- kernel/time/tick-sched.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 3ff3eb1f90d0..8ddf74e705d3 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1174,16 +1174,15 @@ static bool report_idle_softirq(void) return false; } =20 - if (ratelimit >=3D 10) - return false; - /* On RT, softirq handling may be waiting on some lock */ if (local_bh_blocked()) return false; =20 - pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%0= 2x!!!\n", - pending); - ratelimit++; + if (ratelimit < 10) { + pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%= 02x!!!\n", + pending); + ratelimit++; + } =20 return true; } --=20 2.25.1