On Thu, Oct 29, 2020 at 08:26:26PM +0530, Sumit Garg wrote: > Add a new API kgdb_arch_roundup_cpus() for a particular archichecture to > override default kgdb roundup and if it detects at runtime to not support > NMI roundup then it can fallback to default implementation using async > SMP cross-calls. > > Currently such an architecture example is arm64 supporting pseudo NMIs > feature which is only available on platforms which have support for GICv3 > or later version. > > Signed-off-by: Sumit Garg <sumit.g...@linaro.org> > --- > arch/powerpc/kernel/kgdb.c | 3 ++- > arch/sparc/kernel/smp_64.c | 3 ++- > arch/x86/kernel/kgdb.c | 6 ++++-- > include/linux/kgdb.h | 5 +++-- > kernel/debug/debug_core.c | 10 +++++++++- > 5 files changed, 20 insertions(+), 7 deletions(-) > > diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c > index 4090802..126575d 100644 > --- a/arch/powerpc/kernel/kgdb.c > +++ b/arch/powerpc/kernel/kgdb.c > @@ -125,9 +125,10 @@ static int kgdb_debugger_ipi(struct pt_regs *regs) > } > > #ifdef CONFIG_SMP > -void kgdb_roundup_cpus(void) > +bool kgdb_arch_roundup_cpus(void) > { > smp_send_debugger_break(); > + return true; > } > #endif > > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > index e38d8bf..c459c83 100644 > --- a/arch/sparc/kernel/smp_64.c > +++ b/arch/sparc/kernel/smp_64.c > @@ -1014,9 +1014,10 @@ void flush_dcache_page_all(struct mm_struct *mm, > struct page *page) > } > > #ifdef CONFIG_KGDB > -void kgdb_roundup_cpus(void) > +bool kgdb_arch_roundup_cpus(void) > { > smp_cross_call(&xcall_kgdb_capture, 0, 0, 0); > + return true; > } > #endif > > diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c > index ff7878d..1b756d9 100644 > --- a/arch/x86/kernel/kgdb.c > +++ b/arch/x86/kernel/kgdb.c > @@ -404,7 +404,8 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) > > #ifdef CONFIG_SMP > /** > - * kgdb_roundup_cpus - Get other CPUs into a holding pattern > + * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern > + * in an architectural specific manner > * > * 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 > @@ -414,9 +415,10 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) > * > * On non-SMP systems, this is not called. > */ > -void kgdb_roundup_cpus(void) > +bool kgdb_arch_roundup_cpus(void) > { > apic_send_IPI_allbutself(NMI_VECTOR); > + return true; > } > #endif > > diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h > index 0d6cf64..f9db5b8 100644 > --- a/include/linux/kgdb.h > +++ b/include/linux/kgdb.h > @@ -200,7 +200,8 @@ kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer, > extern void kgdb_call_nmi_hook(void *ignored); > > /** > - * kgdb_roundup_cpus - Get other CPUs into a holding pattern > + * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern > + * in an architectural specific manner > * > * 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 > @@ -210,7 +211,7 @@ extern void kgdb_call_nmi_hook(void *ignored); > * > * On non-SMP systems, this is not called. > */ > -extern void kgdb_roundup_cpus(void); > +extern bool kgdb_arch_roundup_cpus(void); > > /** > * kgdb_arch_set_pc - Generic call back to the program counter > diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c > index 1e75a89..27e401c 100644 > --- a/kernel/debug/debug_core.c > +++ b/kernel/debug/debug_core.c > @@ -241,13 +241,21 @@ void __weak kgdb_call_nmi_hook(void *ignored) > } > NOKPROBE_SYMBOL(kgdb_call_nmi_hook); > > -void __weak kgdb_roundup_cpus(void) > +bool __weak kgdb_arch_roundup_cpus(void) > +{ > + return false;
Do we really need to introduce all these boolean return values just to call a bit of library code when one of the architectures wants to fallback to a generic implementation? Why not something more like: void kgdb_smp_call_nmi_hook(void) { /* original weak version of kgdb_roundup_cpus goes here */ } void __weak kgdb_roundup_cpus(void) { kgdb_smp_call_nmi_hook(); } arm64 can now simply call the new library function if a fallback is needed. Note that same question applies to the backtrace changes... Daniel. > +} > + > +static void kgdb_roundup_cpus(void) > { > call_single_data_t *csd; > int this_cpu = raw_smp_processor_id(); > int cpu; > int ret; > > + if (kgdb_arch_roundup_cpus()) > + return; > + > for_each_online_cpu(cpu) { > /* No need to roundup ourselves */ > if (cpu == this_cpu) > -- > 2.7.4 > _______________________________________________ Kgdb-bugreport mailing list Kgdb-bugreport@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport