[PATCH] kgdb: update outdated references to kgdb_wait()

Kexin Sun posted 1 patch 1 week, 6 days ago
There is a newer version of this series
arch/x86/kernel/kgdb.c    | 5 +++--
include/linux/kgdb.h      | 3 ++-
kernel/debug/debug_core.c | 2 +-
kernel/debug/gdbstub.c    | 2 +-
4 files changed, 7 insertions(+), 5 deletions(-)
[PATCH] kgdb: update outdated references to kgdb_wait()
Posted by Kexin Sun 1 week, 6 days ago
The function kgdb_wait() was replaced by kgdb_cpu_enter()
in commit 62fae312197a ("kgdb: eliminate kgdb_wait(), all cpus
enter the same way").  Update the four stale references:
 - include/linux/kgdb.h: kgdb_roundup_cpus() kdoc
 - arch/x86/kernel/kgdb.c: kgdb_roundup_cpus() kdoc; also fix
   pre-existing grammar error ("get them be" -> "get them into")
 - kernel/debug/debug_core.c: inline comment
 - kernel/debug/gdbstub.c: inline comment

Assisted-by: unnamed:deepseek-v3.2 coccinelle
Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
---
 arch/x86/kernel/kgdb.c    | 5 +++--
 include/linux/kgdb.h      | 3 ++-
 kernel/debug/debug_core.c | 2 +-
 kernel/debug/gdbstub.c    | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 8b1a9733d13e..f50a39818223 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -407,8 +407,9 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
  *	kgdb_roundup_cpus - Get other CPUs into a holding pattern
  *
  *	On SMP systems, we need to get the attention of the other CPUs
- *	and get them be in a known state.  This should do what is needed
- *	to get the other CPUs to call kgdb_wait(). Note that on some arches,
+ *	and get them into a known state.  This should do what is needed
+ *	to get the other CPUs to call kgdb_cpu_enter(). Note that on
+ *	some arches,
  *	the NMI approach is not used for rounding up all the CPUs. For example,
  *	in case of MIPS, smp_call_function() is used to roundup CPUs.
  *
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index 22b3f3839f30..bbe9b54a57c9 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -202,7 +202,8 @@ extern void kgdb_call_nmi_hook(void *ignored);
  *
  *	On SMP systems, we need to get the attention of the other CPUs
  *	and get them into a known state.  This should do what is needed
- *	to get the other CPUs to call kgdb_wait(). Note that on some arches,
+ *	to get the other CPUs to call kgdb_cpu_enter(). Note that on
+ *	some arches,
  *	the NMI approach is not used for rounding up all the CPUs.  Normally
  *	those architectures can just not implement this and get the default.
  *
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 0b9495187fba..1a2f0297a80c 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -704,7 +704,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
 	if (ks->send_ready)
 		atomic_set(ks->send_ready, 1);
 
-	/* Signal the other CPUs to enter kgdb_wait() */
+	/* Signal the other CPUs to enter kgdb_cpu_enter() */
 	else if ((!kgdb_single_step) && kgdb_do_roundup)
 		kgdb_roundup_cpus();
 #endif
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index f586afd76c80..aafd8da5d7fc 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -517,7 +517,7 @@ static void gdb_get_regs_helper(struct kgdb_state *ks)
 	/*
 	 * All threads that don't have debuggerinfo should be
 	 * in schedule() sleeping, since all other CPUs
-	 * are in kgdb_wait, and thus have debuggerinfo.
+	 * are in kgdb_cpu_enter, and thus have debuggerinfo.
 	 */
 	if (local_debuggerinfo) {
 		pt_regs_to_gdb_regs(gdb_regs, local_debuggerinfo);
-- 
2.25.1
Re: [PATCH] kgdb: update outdated references to kgdb_wait()
Posted by Daniel Thompson 1 week, 4 days ago
On Sat, Mar 21, 2026 at 06:58:08PM +0800, Kexin Sun wrote:
> The function kgdb_wait() was replaced by kgdb_cpu_enter()
> in commit 62fae312197a ("kgdb: eliminate kgdb_wait(), all cpus
> enter the same way").  Update the four stale references:
>  - include/linux/kgdb.h: kgdb_roundup_cpus() kdoc
>  - arch/x86/kernel/kgdb.c: kgdb_roundup_cpus() kdoc; also fix
>    pre-existing grammar error ("get them be" -> "get them into")
>  - kernel/debug/debug_core.c: inline comment
>  - kernel/debug/gdbstub.c: inline comment
>
> Assisted-by: unnamed:deepseek-v3.2 coccinelle
> Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>

Thanks for the patch. However I don't think the changes in commit
62fae312197a have been incorrectly interpreted in your update. See
below.


> ---
>  arch/x86/kernel/kgdb.c    | 5 +++--
>  include/linux/kgdb.h      | 3 ++-
>  kernel/debug/debug_core.c | 2 +-
>  kernel/debug/gdbstub.c    | 2 +-
>  4 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
> index 8b1a9733d13e..f50a39818223 100644
> --- a/arch/x86/kernel/kgdb.c
> +++ b/arch/x86/kernel/kgdb.c
> @@ -407,8 +407,9 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
>   *	kgdb_roundup_cpus - Get other CPUs into a holding pattern
>   *
>   *	On SMP systems, we need to get the attention of the other CPUs
> - *	and get them be in a known state.  This should do what is needed
> - *	to get the other CPUs to call kgdb_wait(). Note that on some arches,
> + *	and get them into a known state.  This should do what is needed
> + *	to get the other CPUs to call kgdb_cpu_enter(). Note that on

kgdb_cpu_enter() is a static function. There is no way this is the right
function to get the other CPUs to call.

Are you sure you don't mean kgdb_handle_exception() here?


> + *	some arches,

Please reflow the text for the whole comment.


>   *	the NMI approach is not used for rounding up all the CPUs. For example,
>   *	in case of MIPS, smp_call_function() is used to roundup CPUs.
>   *
> diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
> index 22b3f3839f30..bbe9b54a57c9 100644
> --- a/include/linux/kgdb.h
> +++ b/include/linux/kgdb.h
> @@ -202,7 +202,8 @@ extern void kgdb_call_nmi_hook(void *ignored);
>   *
>   *	On SMP systems, we need to get the attention of the other CPUs
>   *	and get them into a known state.  This should do what is needed
> - *	to get the other CPUs to call kgdb_wait(). Note that on some arches,
> + *	to get the other CPUs to call kgdb_cpu_enter(). Note that on
> + *	some arches,

+2


>   *	the NMI approach is not used for rounding up all the CPUs.  Normally
>   *	those architectures can just not implement this and get the default.
>   *
> diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
> index 0b9495187fba..1a2f0297a80c 100644
> --- a/kernel/debug/debug_core.c
> +++ b/kernel/debug/debug_core.c
> @@ -704,7 +704,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
>  	if (ks->send_ready)
>  		atomic_set(ks->send_ready, 1);
>
> -	/* Signal the other CPUs to enter kgdb_wait() */
> +	/* Signal the other CPUs to enter kgdb_cpu_enter() */
>  	else if ((!kgdb_single_step) && kgdb_do_roundup)
>  		kgdb_roundup_cpus();

This isn't wrong but still suggests that code outside of kgdb can call
into kgdb (and it can't). I think just "to enter the debug trap handler"
would be better here.


>  #endif
> diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
> index f586afd76c80..aafd8da5d7fc 100644
> --- a/kernel/debug/gdbstub.c
> +++ b/kernel/debug/gdbstub.c
> @@ -517,7 +517,7 @@ static void gdb_get_regs_helper(struct kgdb_state *ks)
>  	/*
>  	 * All threads that don't have debuggerinfo should be
>  	 * in schedule() sleeping, since all other CPUs
> -	 * are in kgdb_wait, and thus have debuggerinfo.
> +	 * are in kgdb_cpu_enter, and thus have debuggerinfo.

This usage is correct... but could you add the () after the function name
to match the reset of the comment.


Daniel.
[PATCH v2] kgdb: update outdated references to kgdb_wait()
Posted by Kexin Sun 1 week, 3 days ago
The function kgdb_wait() was folded into the static function
kgdb_cpu_enter() by commit 62fae312197a ("kgdb: eliminate
kgdb_wait(), all cpus enter the same way").  Update the four stale
references accordingly:

 - include/linux/kgdb.h and arch/x86/kernel/kgdb.c: the
   kgdb_roundup_cpus() kdoc describes what other CPUs are rounded up
   to call.  Because kgdb_cpu_enter() is static, the correct public
   entry point is kgdb_handle_exception(); also fix a pre-existing
   grammar error ("get them be" -> "get them into") and reflow the
   text.

 - kernel/debug/debug_core.c: replace with the generic description
   "the debug trap handler", since the actual entry path is
   architecture-specific.

 - kernel/debug/gdbstub.c: kgdb_cpu_enter() is correct here (it
   describes internal state, not a call target); add the missing
   parentheses.

Suggested-by: Daniel Thompson <daniel@riscstar.com>
Assisted-by: unnamed:deepseek-v3.2 coccinelle
Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
---
v2:
 - Use kgdb_handle_exception() instead of static kgdb_cpu_enter() for
   the two kdoc comments describing what other CPUs call (Daniel Thompson)
 - Use "the debug trap handler" for the debug_core.c inline comment
 - Add missing parentheses in gdbstub.c
 - Reflow both reflowed comment blocks

 arch/x86/kernel/kgdb.c    | 9 +++++----
 include/linux/kgdb.h      | 7 ++++---
 kernel/debug/debug_core.c | 2 +-
 kernel/debug/gdbstub.c    | 2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 8b1a9733d13e..96af1242454e 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -407,10 +407,11 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
  *	kgdb_roundup_cpus - Get other CPUs into a holding pattern
  *
  *	On SMP systems, we need to get the attention of the other CPUs
- *	and get them be in a known state.  This should do what is needed
- *	to get the other CPUs to call kgdb_wait(). Note that on some arches,
- *	the NMI approach is not used for rounding up all the CPUs. For example,
- *	in case of MIPS, smp_call_function() is used to roundup CPUs.
+ *	and get them into a known state.  This should do what is needed
+ *	to get the other CPUs to call kgdb_handle_exception().  Note that
+ *	on some arches, the NMI approach is not used for rounding up all
+ *	the CPUs.  For example, in case of MIPS, smp_call_function() is
+ *	used to roundup CPUs.
  *
  *	On non-SMP systems, this is not called.
  */
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index 22b3f3839f30..6c46591a2eac 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -202,9 +202,10 @@ extern void kgdb_call_nmi_hook(void *ignored);
  *
  *	On SMP systems, we need to get the attention of the other CPUs
  *	and get them into a known state.  This should do what is needed
- *	to get the other CPUs to call kgdb_wait(). Note that on some arches,
- *	the NMI approach is not used for rounding up all the CPUs.  Normally
- *	those architectures can just not implement this and get the default.
+ *	to get the other CPUs to call kgdb_handle_exception().  Note that
+ *	on some arches, the NMI approach is not used for rounding up all
+ *	the CPUs.  Normally those architectures can just not implement
+ *	this and get the default.
  *
  *	On non-SMP systems, this is not called.
  */
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 0b9495187fba..b276504c1c6b 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -704,7 +704,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
 	if (ks->send_ready)
 		atomic_set(ks->send_ready, 1);
 
-	/* Signal the other CPUs to enter kgdb_wait() */
+	/* Signal the other CPUs to enter the debug trap handler */
 	else if ((!kgdb_single_step) && kgdb_do_roundup)
 		kgdb_roundup_cpus();
 #endif
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index f586afd76c80..e271a436d60e 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -517,7 +517,7 @@ static void gdb_get_regs_helper(struct kgdb_state *ks)
 	/*
 	 * All threads that don't have debuggerinfo should be
 	 * in schedule() sleeping, since all other CPUs
-	 * are in kgdb_wait, and thus have debuggerinfo.
+	 * are in kgdb_cpu_enter(), and thus have debuggerinfo.
 	 */
 	if (local_debuggerinfo) {
 		pt_regs_to_gdb_regs(gdb_regs, local_debuggerinfo);
-- 
2.25.1