From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.82 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796317460; b=dZEzMXlF3qSojFZ0mgTJCdSfJG4Q0Zb1zgYaKrDb9fALKXRaQx+an0OdUdGkRS2+Og0L 7IqsMOwG/illjCQbAD3KyfwWioyWxfwa+piq2mH+5+V3j0CDxwvvjHFQqSfsyVLGaBJzg nYSfXVhncwFIoXkZnas1BCdfsyTtno9wMYE3ZC38plLDpflL+mrZeeA8B0E7IajZ0UOwr CuYv8X6ezz1XRJTr/Y6rZl3Wg1t0Y56UimXGxCdzyYKw2RyJDMbPH2z5IPR+Mc/d+Zj4Q ebsBLTCGBwyoma61mrw1RX8YynxjVNUdUh5R2qiTtjP01obfWXGfXqrbAzWBHrm9TrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796317460; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:CC:Subject:In-Reply-To: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Jp1R9AMCrr42S4DNLDEqVdrYHsf3RDztezkdgxFAZs4=; b=aAkQ1xDW03RpeKdCcPNVTT1QqBYTQ4HoMcj403ju6VhSiIdczZu6AHEx8O59Tijtf3Y+ nbnkJLh/GVCJbWr0xKaxT13n1k6Em92x+Z2jZcb6lv1G7yVU7S8VTCRSGHxTiaplhErjl l6wvtyePFu2aAwf2NjDbssA0IhGrqFmx3rRB11wcNGbRcy+3p+vDq0+XrjFwASWQdZXtJ 1jbjhv1aOt9Xck3Kp1XMV0gBYcTOQ1HR87w+cP4ZdXpeXAkksW80/B6roT+AAUKVIwIw+ qpxcuO7QGMWDHIul5jemrvgclWrPvEnCae6Yn5VkSoXb3jfjkWwm7WkJaQBGD5nW/6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=iGZbZTDp; arc=none smtp.remote-ip=95.215.58.82 Received: from mta1.migadu.com (out-82.mta1.migadu.com [95.215.58.82]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12E7D606A322 for ; Thu, 3 Dec 2026 17:04:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12E7D606A322 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, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=iGZbZTDp X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=OKza3MJQBFHQ6bw9+2/vWwhTmKCtxRI66Yb2+LJU8rk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796317457; v=1; x=1796922257; b=iGZbZTDpTJK+dF+n35t//dc7wxXpkCzAyF68FWHGMFmFWmiit7Rec3eZoV/QqOUUZg3NM6G2 pRT77QCJ/b/ea/cxHfJByHFKmTMQW96y4v3rvseElS8OuJugkdmWVh51IIZbBt7aOzecmbTu0wg pZleiZTVsMDFZVegZEeYWyJQ= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id c50dc99d1fdee58d; Thu, 03 Dec 2026 17:04:17 +0000 X-Mizu-Trace-ID: c50dc99d1fdee58d X-Migadu-Flow: FLOW_OUT Date: Thu, 03 Dec 2026 17:04:17 +0000 From: Bradley Morgan To: thnkslprpt@gmail.com CC: akpm@linux-foundation.org, dianders@chromium.org, linux-kernel@vger.kernel.org, liusong@linux.alibaba.com, mrungta@google.com, pmladek@suse.com, tglx@kernel.org, yaoma@linux.alibaba.com, yaozhenguo1@gmail.com Subject: =?US-ASCII?Q?Re=3A_=5BPATCH=5D_watchdog/softlockup=3A_Fix_CP?= =?US-ASCII?Q?U_utilization_across_counter_wraparound?= In-Reply-To: <20261203065113.686608-1-thnkslprpt@gmail.com> Message-ID: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 3 December 2026 06:51:13 GMT, Avi Weiss wrote: >update_cpustat() keeps the low 16 bits of each quantized CPU time >counter. Subtracting two u16 values promotes them to int, so a counter >that wraps gives a negative delta. > >Store the difference in a u16 to recover the modular delta before >scaling it. Keep the percentage in an unsigned int until after applying >the 100% cap. ehh? The negative result goes into a u8, so the softlockup report prints a crap percentage. With the default 4s sample, old=65500 and new=100 should report 58%, but the current code turns the negative quotient into 171 and then caps it to 100%. The cap only sometimes catches the conversion, so the wrong value can look "ok". please add to changelog For one sample after the counter wraps, the report prints a bogus utilization, e.g. 100% instead of 58%. btw, if you want stable. Cc: stable@vger.kernel.org # v6.18+ > >Fixes: d7037381d002 ("watchdog/softlockup: Low-overhead detection of interrupt storm") >Signed-off-by: Avi Weiss >--- > kernel/watchdog.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > >diff --git a/kernel/watchdog.c b/kernel/watchdog.c >index 64da2e500144..b75564260562 100644 >--- a/kernel/watchdog.c >+++ b/kernel/watchdog.c >@@ -489,8 +489,8 @@ static u16 get_16bit_precision(u64 data_ns) > static void update_cpustat(void) > { > int i; >- u8 util; >- u16 old_stat, new_stat; >+ unsigned int util; >+ u16 old_stat, new_stat, delta; > struct kernel_cpustat kcpustat; > u64 *cpustat = kcpustat.cpustat; > u8 tail = __this_cpu_read(cpustat_tail); >@@ -501,7 +501,9 @@ static void update_cpustat(void) > for (i = 0; i < NUM_STATS_PER_GROUP; i++) { > old_stat = __this_cpu_read(cpustat_old[i]); > new_stat = get_16bit_precision(cpustat[tracked_stats[i]]); >- util = DIV_ROUND_UP(100 * (new_stat - old_stat), sample_period_16); >+ /* Take the delta modulo 2^16 before scaling it. */ >+ delta = new_stat - old_stat; >+ util = DIV_ROUND_UP(100U * delta, sample_period_16); > /* > * Since we use 16-bit precision, the raw data will undergo > * integer division, which may sometimes result in data loss, > >base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 > --- Thanks!