All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Anderson <dianders@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Petr Mladek <pmladek@suse.com>, Michal Hocko <mhocko@suse.com>,
	Douglas Anderson <dianders@chromium.org>,
	kernel test robot <lkp@intel.com>,
	Lecopzer Chen <lecopzer.chen@mediatek.com>,
	Pingfan Liu <kernelfans@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/2] watchdog/hardlockup: Avoid large stack frames in watchdog_hardlockup_check()
Date: Thu,  3 Aug 2023 16:07:58 -0700	[thread overview]
Message-ID: <20230803160649.v3.2.I501ab68cb926ee33a7c87e063d207abf09b9943c@changeid> (raw)
In-Reply-To: <20230803160649.v3.1.Ia35521b91fc781368945161d7b28538f9996c182@changeid>

After commit 77c12fc95980 ("watchdog/hardlockup: add a "cpu" param to
watchdog_hardlockup_check()") we started storing a `struct cpumask` on
the stack in watchdog_hardlockup_check(). On systems with
CONFIG_NR_CPUS set to 8192 this takes up 1K on the stack. That
triggers warnings with `CONFIG_FRAME_WARN` set to 1024.

We'll use the new trigger_allbutcpu_cpu_backtrace() to avoid needing
to use a CPU mask at all.

Fixes: 77c12fc95980 ("watchdog/hardlockup: add a "cpu" param to watchdog_hardlockup_check()")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202307310955.pLZDhpnl-lkp@intel.com
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

Changes in v3:
- Rebase on change introducing trigger_allbutcpu_cpu_backtrace().

Changes in v2:
- Allocate space when userspace requests all cpus be backtraced.

 kernel/watchdog.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 085d7a78f62f..d145305d95fe 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -151,9 +151,6 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
 	 */
 	if (is_hardlockup(cpu)) {
 		unsigned int this_cpu = smp_processor_id();
-		struct cpumask backtrace_mask;
-
-		cpumask_copy(&backtrace_mask, cpu_online_mask);
 
 		/* Only print hardlockups once. */
 		if (per_cpu(watchdog_hardlockup_warned, cpu))
@@ -167,10 +164,8 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
 				show_regs(regs);
 			else
 				dump_stack();
-			cpumask_clear_cpu(cpu, &backtrace_mask);
 		} else {
-			if (trigger_single_cpu_backtrace(cpu))
-				cpumask_clear_cpu(cpu, &backtrace_mask);
+			trigger_single_cpu_backtrace(cpu);
 		}
 
 		/*
@@ -179,7 +174,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
 		 */
 		if (sysctl_hardlockup_all_cpu_backtrace &&
 		    !test_and_set_bit(0, &watchdog_hardlockup_all_cpu_dumped))
-			trigger_cpumask_backtrace(&backtrace_mask);
+			trigger_allbutcpu_cpu_backtrace(cpu);
 
 		if (hardlockup_panic)
 			nmi_panic(regs, "Hard LOCKUP");
-- 
2.41.0.585.gd2178a4bd4-goog


  reply	other threads:[~2023-08-03 23:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 23:07 [PATCH v3 1/2] nmi_backtrace: Allow excluding an arbitrary CPU Douglas Anderson
2023-08-03 23:07 ` Douglas Anderson
2023-08-03 23:07 ` Douglas Anderson
2023-08-03 23:07 ` Douglas Anderson [this message]
2023-08-04  7:50   ` [PATCH v3 2/2] watchdog/hardlockup: Avoid large stack frames in watchdog_hardlockup_check() Michal Hocko
2023-08-04  7:50 ` [PATCH v3 1/2] nmi_backtrace: Allow excluding an arbitrary CPU Michal Hocko
2023-08-04  7:50   ` Michal Hocko
2023-08-04  7:50   ` Michal Hocko
2023-08-04 13:56   ` Doug Anderson
2023-08-04 13:56     ` Doug Anderson
2023-08-04 13:56     ` Doug Anderson
2023-08-04 15:02     ` Michal Hocko
2023-08-04 15:02       ` Michal Hocko
2023-08-04 15:02       ` Michal Hocko
2023-08-04 16:06       ` Doug Anderson
2023-08-04 16:06         ` Doug Anderson
2023-08-04 16:06         ` Doug Anderson
2023-08-07  7:03         ` Michal Hocko
2023-08-07  7:03           ` Michal Hocko
2023-08-07  7:03           ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230803160649.v3.2.I501ab68cb926ee33a7c87e063d207abf09b9943c@changeid \
    --to=dianders@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=kernelfans@gmail.com \
    --cc=lecopzer.chen@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mhocko@suse.com \
    --cc=pmladek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.