From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E9812D0C95 for ; Thu, 29 Jan 2026 09:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769679763; cv=none; b=J85G4z3MKsfVChMsELGBPcyeO37JfIxFsUqmmL/12FExGdkp9zpIfYC0Xrxf9mXCzUx7cOK2B9HlfhmeyN2ShjNaGJv+UW+0KeFwXuLdr3cOO4fplFLxwNLK9e2v0jUzz0PJ/cJYu96NXlHEamyw1mIAzv7F6YzFwjMRpXFmzAc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769679763; c=relaxed/simple; bh=NCFxu4gdU6LMZiT7cr81QVnz8PQLWtZbqLWguRAXOc8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VBYg1uvpUtQSB7PvbyqT/VPPq3S4ZcPncQW3mFAgslpAmqGJ5qrRG2SgSNGwtGZCf4zQCOmde1uQVvBAPKy/VHyg/OhPVKscneI3ukYFlzL0bxE2kqqVXVRzUE/Mbfm42gGvbi4dnWQgahDxpw0kZZXwg5+ERqiXifgTeJtw9LQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=MAX82/le; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="MAX82/le" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-435a517be33so572740f8f.0 for ; Thu, 29 Jan 2026 01:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769679760; x=1770284560; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=HDqTuIHUerfJLYdistiUhGTZ/XX/JUR14D/Utf3PHsg=; b=MAX82/lemTdGsFEhsOejMEtG4uFA0RCUVOZUYPU/Kl8NXJ7A6HbnjVDWpQXzvyDexl FzPfq0xZbZkXusIHWYybUNVeisUSBA3dNLeh2zolCijBwpCuT4yxR0SZc7QV0CYuvoYX 6J/5fdFtISxVD6Ani5NmyUpillQOhfTZiR+gKSqSQ3vLBn48VrbAIUpUdZg7lmHagGKH sM9oK4dkNhgu+v5wQdV3UPK95Ewn6rMtbibdQRvjErd7+10TaA7fa89PBZ8ykSldMvxt 62CeSspDrThHepUc9RyDYO/WI4bvCrmMDN1ucrGIxAJ2tPrvWrCtkRQ5HZZpCvdw04O6 KXpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769679760; x=1770284560; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HDqTuIHUerfJLYdistiUhGTZ/XX/JUR14D/Utf3PHsg=; b=RQUT/I3IvOAWzs9F9pIZaIVktgWjffcEF0Upx1GLBAQE2X75oZIIzkUmRsfUUQ5f5y +6zae+XHoT+/DCohrxCQdytGyztc3kIChZsPpJbAkCuQH8eTUCAMp9s26/P+uwBtABBg 2W6xn7FdKsM70Ss2wIYtko3AuvlLVSwNFsBcpBeTRVN5Uahkv/c1de8nKqdmX0cuu40P SQFsIOZrafYt+e+8ihhxxtJjra3cl7Fua5aQzHdE05RE512N8Vtvr3IhulTJHcxTytMF mftO506JK/vXVB5JD9Ay/hKuHDPJW5p6W5leP63DPfPRq6W5TnB2vtdO/t6SOjTWUQV5 75tA== X-Forwarded-Encrypted: i=1; AJvYcCUMZSzoau9ZwfbyNUOpOujfzAGK/A89N6dbR3ffjTEIqISWxBfR6Oid8Ws47CINIzRFRawD2dOvXqew/hQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyYVJClp5MQpvq4DEIL5RDaCjEiF/FrP1jRv1doa+z8Tgk6RmpR BEg8fyoyMbD8TKlxPGq6mR+V9zJZraa7wB9pUOH6h4mt+0sH1V+ynsMMBnczx9aZKC0= X-Gm-Gg: AZuq6aJm1+LwssJ96R/lRPG2JSXLIS23KDTEkZcEsRS+Gz80WEvcQ/OhYaNSs2MlLFs i9+1RNGFXpPMUJoRZMdWNlfiBr8L3516JQjolEpFxwFNOJ6cR5YjvcKCMU2edCGQc5QjmbAYo4G ZdfBRJg+ks2MO6jcw2fwsYG9y9FndAmkxLn2QU25XW7zzGkAhUhJj/1tl0tmCnvxPmLc+iyZXNK Nbf3BGsNaG/YEoxr0BUHkFQSr3XTME6wonXyy1ybNYdylRfPnKC+dTlk6thJ2R3+39qraK8zJaC YKrmcoRDBeaXaKlnaNa3u43imv537zTbhrB65IvibAjwJTp0F9ztu2AeHZubpnfnki19GlY2n6/ rWQ1BehYQJP3TNg//x8ypMvrsBBb6IRBnXPomhiZSc373HBsPz7odOFwcAI6vua9G0OaWV3pWeK N/J591oFbVgz5Bog== X-Received: by 2002:a5d:5886:0:b0:42f:9e75:8605 with SMTP id ffacd0b85a97d-435dcf665e1mr10191483f8f.0.1769679759768; Thu, 29 Jan 2026 01:42:39 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e10ee040sm13180464f8f.11.2026.01.29.01.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 01:42:39 -0800 (PST) Date: Thu, 29 Jan 2026 10:42:37 +0100 From: Petr Mladek To: Andrew Morton Cc: shengminghu512 , tglx , mingo , broonie , linux-kernel , "hu.shengming" , "zhang.run" Subject: Re: [PATCH] watchdog/softlockup: Fix sample ring index wrap in need_counting_irqs() Message-ID: References: <20260128101339.658d522c69bb4466218ee437@linux-foundation.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260128101339.658d522c69bb4466218ee437@linux-foundation.org> On Wed 2026-01-28 10:13:39, Andrew Morton wrote: > On Wed, 28 Jan 2026 18:52:11 +0100 Petr Mladek wrote: > > > On Mon 2026-01-19 21:59:05, shengminghu512 wrote: > > > From: Shengming Hu > > > > > > cpustat_tail indexes cpustat_util[], which is a NUM_SAMPLE_PERIODS-sized > > > ring buffer. need_counting_irqs() currently wraps the index using > > > NUM_HARDIRQ_REPORT, which only happens to match NUM_SAMPLE_PERIODS. > > > > > > Use NUM_SAMPLE_PERIODS for the wrap to keep the ring math correct even if > > > the NUM_HARDIRQ_REPORT or NUM_SAMPLE_PERIODS changes. > > > > > > --- > > > kernel/watchdog.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/kernel/watchdog.c b/kernel/watchdog.c > > > index b4d5fbdb9..7d675781b 100644 > > > --- a/kernel/watchdog.c > > > +++ b/kernel/watchdog.c > > > @@ -550,7 +550,7 @@ static bool need_counting_irqs(void) > > > u8 util; > > > int tail = __this_cpu_read(cpustat_tail); > > > > > > - tail = (tail + NUM_HARDIRQ_REPORT - 1) % NUM_HARDIRQ_REPORT; > > > + tail = (tail + NUM_SAMPLE_PERIODS - 1) % NUM_SAMPLE_PERIODS; > > > util = __this_cpu_read(cpustat_util[tail][STATS_HARDIRQ]); > > > return util > HARDIRQ_PERCENT_THRESH; > > > > Great catch! It makes perfect sense. > > > > The NUM_HARDIRQ_REPORT is used for another array (irq_counts_sorted[]) > > with the most frequent IRQs. This code was added with the same commit > > which added the other array. It would explain the mistake. > > > > Reviewed-by: Petr Mladek > > Fixes: e9a9292e2368 ("watchdog/softlockup: Report the most frequent > interrupts"), yes? Yes. > What are the runtime effects of this? "most frequent interrupts" data > is messed up? It does not have any affect at the moment because both NUM_HARDIRQ_REPORT and NUM_SAMPLE_PERIODS are defined as '5'. It is rather a proactive fix. I might cause an invalid access when anyone increases NUM_HARDIRQ_REPORT count in the future. The purpose of this value is different. > I'm assuming we want to fix earlier kernels, so cc:stable? Good point. It is a good to have in stable. > > Andrew, I assume that you would take it... > > Sure, I can queue it. e9a9292e2368 was merged by tglx so he might want > to take it - if so I'll drop the mm.git copy if/when this appears in > linux-next. Thanks for taking it. Best Regards, Petr