From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4074C22424C for ; Fri, 22 May 2026 03:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779422008; cv=none; b=r+A7g3HggIlOKeenyoHh3GUODqNtXUxos5UCJN930HtamA6H06/V3/HTl1TINdcUaJ4QO9dMr9ncLKl1fHdpPwPgS0d8T/2ZoFfuvkcd6qk71LbSH0sN8TtIl5PJ4fi/f+qEjJkg44GCxxtO8NWf05/l7NjQ1xILMoqtpH8huz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779422008; c=relaxed/simple; bh=ZeHIxM/F5NQmG12pYv80bylQZXLAFrtwYvp5dKTNasU=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=PauO+dkslhHD+srgXrggrRmhwDtmANCLZWfG2fDsLIA34SE4J6i2HofbAuq9eTo673rA91v4v/ODDFyaGttNbcK7SrxbdwNiR7l6ub9KqVKXi9tkr/J/EoYRhLpURN+L29JkMHAJ+lsCpi9/an2NAKZ68OEZej5PKAWjdk2WpLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=cP5UB4OU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="cP5UB4OU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABEA91F000E9; Fri, 22 May 2026 03:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1779422006; bh=Yt0C2v+ARY5pW3zb+E2+lhTn0IaBZmsPuGn7dqCAjew=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=cP5UB4OUfnLu8c1lsRyte6CWU4xOyL5VDhuXc9g7yIMwVMR+txNTxPPfmlD8YU33r 1GnEGH2cQViO5TL9tpLa324Uhd3qjPQOSDIfz7tt6myJp8/1OnWr3I6K1wKMaww1XZ xm+GWRYHOnPfr45qEv2vz0QykVEeLZnV+YT9SL4k= Date: Thu, 21 May 2026 20:53:26 -0700 From: Andrew Morton To: Feng Tang Cc: paulmck@kernel.org, Petr Mladek , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/nmi_backtrace: print out the CPUs which fail to respond to NMI Message-Id: <20260521205326.06557d667beab85a21fd0a6f@linux-foundation.org> In-Reply-To: References: <20260521030336.92172-1-feng.tang@linux.alibaba.com> <20260521153716.0e6da8366d3e2004e9e7cf97@linux-foundation.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 22 May 2026 09:46:26 +0800 Feng Tang wrote: > > It's a nitpick, but > > > > : /* Wait for up to 10 seconds for all CPUs to do the backtrace */ > > : for (i = 0; i < 10 * 1000; i++) { > > : if (cpumask_empty(to_cpumask(backtrace_mask))) > > : break; > > : mdelay(1); > > : touch_softlockup_watchdog(); > > : } > > : > > : if (!cpumask_empty(to_cpumask(backtrace_mask))) { > > : pr_warn("After 10 seconds, these CPUS still haven't responded to the NMI: %*pbl\n", > > > > Here we're hard-coding "10" in two places and in a comment. It would > > be nicer to do > > > > #define FOO_TIMEOUT 10 > > > > then use that throughout. > > > > (bonus points for figuring out how to paste that "10" into the > > pr_warn() control string rather than using %d!) > > How about this followon patch? Looks great. But you missed the fun part! --- a/lib/nmi_backtrace.c~lib-nmi_backtrace-print-out-the-cpus-which-fail-to-respond-to-nmi-fix-fix +++ a/lib/nmi_backtrace.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -79,8 +80,8 @@ void nmi_trigger_cpumask_backtrace(const } if (!cpumask_empty(to_cpumask(backtrace_mask))) { - pr_warn("After %d seconds, these CPUS still haven't responded to the NMI: %*pbl\n", - NMI_BT_TIMEOUT_SEC, cpumask_pr_args(to_cpumask(backtrace_mask))); + pr_warn("After " __stringify(NMI_BT_TIMEOUT_SEC) " seconds, these CPUS still haven't responded to the NMI: %*pbl\n", + cpumask_pr_args(to_cpumask(backtrace_mask))); nmi_backtrace_stall_check(to_cpumask(backtrace_mask)); } _ It saved five bytes!