linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] PATCH: KGDB/KDB Fix no KDB config problem.
@ 2013-10-03 16:38 Mike Travis
  2013-10-03 16:38 ` [PATCH 1/1] " Mike Travis
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Travis @ 2013-10-03 16:38 UTC (permalink / raw)
  To: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton
  Cc: Dimitri Sivanich, Hedi Berriche, x86, linux-kernel


* Fix build problem when KDB is not defined.

-- 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 16:38 [PATCH 0/1] PATCH: KGDB/KDB Fix no KDB config problem Mike Travis
@ 2013-10-03 16:38 ` Mike Travis
  2013-10-03 16:51   ` Ingo Molnar
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Travis @ 2013-10-03 16:38 UTC (permalink / raw)
  To: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton
  Cc: Dimitri Sivanich, Hedi Berriche, x86, linux-kernel

[-- Attachment #1: fix-non-kdb-config.patch --]
[-- Type: text/plain, Size: 1950 bytes --]

Some code added to the debug_core module had KDB dependencies
that it shouldn't have.

Signed-off-by: Mike Travis <travis@sgi.com>
---
 kernel/debug/debug_core.c |    8 ++++----
 kernel/debug/debug_core.h |    2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

--- linux.orig/kernel/debug/debug_core.c
+++ linux/kernel/debug/debug_core.c
@@ -575,8 +575,8 @@ return_normal:
 		raw_spin_lock(&dbg_slave_lock);
 
 #ifdef CONFIG_SMP
-	/* If SYSTEM_NMI, slaves are already waiting */
-	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
+	/* If send_ready set, slaves are already waiting */
+	if (ks->send_ready)
 		atomic_set(ks->send_ready, 1);
 
 	/* Signal the other CPUs to enter kgdb_wait() */
@@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
 	if (arch_kgdb_ops.enable_nmi)
 		arch_kgdb_ops.enable_nmi(0);
 
+	memset(ks, 0, sizeof(struct kgdb_state));
 	ks->cpu			= raw_smp_processor_id();
 	ks->ex_vector		= evector;
 	ks->signo		= signo;
 	ks->err_code		= ecode;
-	ks->kgdb_usethreadid	= 0;
 	ks->linux_regs		= regs;
 
 	if (kgdb_reenter_check(ks))
@@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
 		ks->cpu			= cpu;
 		ks->ex_vector		= trapnr;
 		ks->signo		= SIGTRAP;
-		ks->err_code		= KDB_REASON_SYSTEM_NMI;
+		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
 		ks->linux_regs		= regs;
 		ks->send_ready		= send_ready;
 		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
--- linux.orig/kernel/debug/debug_core.h
+++ linux/kernel/debug/debug_core.h
@@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
 extern int kdb_parse(const char *cmdstr);
 extern int kdb_common_init_state(struct kgdb_state *ks);
 extern int kdb_common_deinit_state(void);
+#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
 #else /* ! CONFIG_KGDB_KDB */
 static inline int kdb_stub(struct kgdb_state *ks)
 {
 	return DBG_PASS_EVENT;
 }
+#define KGDB_KDB_REASON_SYSTEM_NMI 0
 #endif /* CONFIG_KGDB_KDB */
 
 #endif /* _DEBUG_CORE_H_ */

-- 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 16:38 ` [PATCH 1/1] " Mike Travis
@ 2013-10-03 16:51   ` Ingo Molnar
  2013-10-03 17:04     ` Mike Travis
  0 siblings, 1 reply; 8+ messages in thread
From: Ingo Molnar @ 2013-10-03 16:51 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton, Dimitri Sivanich, Hedi Berriche, x86, linux-kernel


* Mike Travis <travis@sgi.com> wrote:

> Some code added to the debug_core module had KDB dependencies
> that it shouldn't have.
> 
> Signed-off-by: Mike Travis <travis@sgi.com>
> ---
>  kernel/debug/debug_core.c |    8 ++++----
>  kernel/debug/debug_core.h |    2 ++
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> --- linux.orig/kernel/debug/debug_core.c
> +++ linux/kernel/debug/debug_core.c
> @@ -575,8 +575,8 @@ return_normal:
>  		raw_spin_lock(&dbg_slave_lock);
>  
>  #ifdef CONFIG_SMP
> -	/* If SYSTEM_NMI, slaves are already waiting */
> -	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
> +	/* If send_ready set, slaves are already waiting */
> +	if (ks->send_ready)
>  		atomic_set(ks->send_ready, 1);
>  
>  	/* Signal the other CPUs to enter kgdb_wait() */
> @@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
>  	if (arch_kgdb_ops.enable_nmi)
>  		arch_kgdb_ops.enable_nmi(0);
>  
> +	memset(ks, 0, sizeof(struct kgdb_state));
>  	ks->cpu			= raw_smp_processor_id();
>  	ks->ex_vector		= evector;
>  	ks->signo		= signo;
>  	ks->err_code		= ecode;
> -	ks->kgdb_usethreadid	= 0;
>  	ks->linux_regs		= regs;
>  
>  	if (kgdb_reenter_check(ks))
> @@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
>  		ks->cpu			= cpu;
>  		ks->ex_vector		= trapnr;
>  		ks->signo		= SIGTRAP;
> -		ks->err_code		= KDB_REASON_SYSTEM_NMI;
> +		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
>  		ks->linux_regs		= regs;
>  		ks->send_ready		= send_ready;
>  		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
> --- linux.orig/kernel/debug/debug_core.h
> +++ linux/kernel/debug/debug_core.h
> @@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
>  extern int kdb_parse(const char *cmdstr);
>  extern int kdb_common_init_state(struct kgdb_state *ks);
>  extern int kdb_common_deinit_state(void);
> +#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
>  #else /* ! CONFIG_KGDB_KDB */
>  static inline int kdb_stub(struct kgdb_state *ks)
>  {
>  	return DBG_PASS_EVENT;
>  }
> +#define KGDB_KDB_REASON_SYSTEM_NMI 0
>  #endif /* CONFIG_KGDB_KDB */
>  
>  #endif /* _DEBUG_CORE_H_ */

Hm, the KGDB_KDB_REASON_SYSTEM_NMI definition is a bit ugly. I still think 
there are layering violations here and just kludging it around doesn't 
solve it - a helper function that keeps kgdb details to the kgdb code 
would.

Anyway, if Jason is fine with this solution and upholds his Acked-by then 
I'll merge this into the first patch and apply the two patches.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 16:51   ` Ingo Molnar
@ 2013-10-03 17:04     ` Mike Travis
  2013-10-03 17:15       ` Ingo Molnar
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Travis @ 2013-10-03 17:04 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton, Dimitri Sivanich, Hedi Berriche, x86, linux-kernel



On 10/3/2013 9:51 AM, Ingo Molnar wrote:
> 
> * Mike Travis <travis@sgi.com> wrote:
> 
>> Some code added to the debug_core module had KDB dependencies
>> that it shouldn't have.
>>
>> Signed-off-by: Mike Travis <travis@sgi.com>
>> ---
>>  kernel/debug/debug_core.c |    8 ++++----
>>  kernel/debug/debug_core.h |    2 ++
>>  2 files changed, 6 insertions(+), 4 deletions(-)
>>
>> --- linux.orig/kernel/debug/debug_core.c
>> +++ linux/kernel/debug/debug_core.c
>> @@ -575,8 +575,8 @@ return_normal:
>>  		raw_spin_lock(&dbg_slave_lock);
>>  
>>  #ifdef CONFIG_SMP
>> -	/* If SYSTEM_NMI, slaves are already waiting */
>> -	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
>> +	/* If send_ready set, slaves are already waiting */
>> +	if (ks->send_ready)
>>  		atomic_set(ks->send_ready, 1);
>>  
>>  	/* Signal the other CPUs to enter kgdb_wait() */
>> @@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
>>  	if (arch_kgdb_ops.enable_nmi)
>>  		arch_kgdb_ops.enable_nmi(0);
>>  
>> +	memset(ks, 0, sizeof(struct kgdb_state));
>>  	ks->cpu			= raw_smp_processor_id();
>>  	ks->ex_vector		= evector;
>>  	ks->signo		= signo;
>>  	ks->err_code		= ecode;
>> -	ks->kgdb_usethreadid	= 0;
>>  	ks->linux_regs		= regs;
>>  
>>  	if (kgdb_reenter_check(ks))
>> @@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
>>  		ks->cpu			= cpu;
>>  		ks->ex_vector		= trapnr;
>>  		ks->signo		= SIGTRAP;
>> -		ks->err_code		= KDB_REASON_SYSTEM_NMI;
>> +		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
>>  		ks->linux_regs		= regs;
>>  		ks->send_ready		= send_ready;
>>  		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
>> --- linux.orig/kernel/debug/debug_core.h
>> +++ linux/kernel/debug/debug_core.h
>> @@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
>>  extern int kdb_parse(const char *cmdstr);
>>  extern int kdb_common_init_state(struct kgdb_state *ks);
>>  extern int kdb_common_deinit_state(void);
>> +#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
>>  #else /* ! CONFIG_KGDB_KDB */
>>  static inline int kdb_stub(struct kgdb_state *ks)
>>  {
>>  	return DBG_PASS_EVENT;
>>  }
>> +#define KGDB_KDB_REASON_SYSTEM_NMI 0
>>  #endif /* CONFIG_KGDB_KDB */
>>  
>>  #endif /* _DEBUG_CORE_H_ */
> 
> Hm, the KGDB_KDB_REASON_SYSTEM_NMI definition is a bit ugly. I still think 
> there are layering violations here and just kludging it around doesn't 
> solve it - a helper function that keeps kgdb details to the kgdb code 
> would.
> 
> Anyway, if Jason is fine with this solution and upholds his Acked-by then 
> I'll merge this into the first patch and apply the two patches.
> 
> Thanks,
> 
> 	Ingo
> 

Would you prefer a simple #ifdef CONFIG_KGDB_KDB around the assignment?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 17:04     ` Mike Travis
@ 2013-10-03 17:15       ` Ingo Molnar
  2013-10-03 17:53         ` Mike Travis
  0 siblings, 1 reply; 8+ messages in thread
From: Ingo Molnar @ 2013-10-03 17:15 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton, Dimitri Sivanich, Hedi Berriche, x86, linux-kernel


* Mike Travis <travis@sgi.com> wrote:

> 
> 
> On 10/3/2013 9:51 AM, Ingo Molnar wrote:
> > 
> > * Mike Travis <travis@sgi.com> wrote:
> > 
> >> Some code added to the debug_core module had KDB dependencies
> >> that it shouldn't have.
> >>
> >> Signed-off-by: Mike Travis <travis@sgi.com>
> >> ---
> >>  kernel/debug/debug_core.c |    8 ++++----
> >>  kernel/debug/debug_core.h |    2 ++
> >>  2 files changed, 6 insertions(+), 4 deletions(-)
> >>
> >> --- linux.orig/kernel/debug/debug_core.c
> >> +++ linux/kernel/debug/debug_core.c
> >> @@ -575,8 +575,8 @@ return_normal:
> >>  		raw_spin_lock(&dbg_slave_lock);
> >>  
> >>  #ifdef CONFIG_SMP
> >> -	/* If SYSTEM_NMI, slaves are already waiting */
> >> -	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
> >> +	/* If send_ready set, slaves are already waiting */
> >> +	if (ks->send_ready)
> >>  		atomic_set(ks->send_ready, 1);
> >>  
> >>  	/* Signal the other CPUs to enter kgdb_wait() */
> >> @@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
> >>  	if (arch_kgdb_ops.enable_nmi)
> >>  		arch_kgdb_ops.enable_nmi(0);
> >>  
> >> +	memset(ks, 0, sizeof(struct kgdb_state));
> >>  	ks->cpu			= raw_smp_processor_id();
> >>  	ks->ex_vector		= evector;
> >>  	ks->signo		= signo;
> >>  	ks->err_code		= ecode;
> >> -	ks->kgdb_usethreadid	= 0;
> >>  	ks->linux_regs		= regs;
> >>  
> >>  	if (kgdb_reenter_check(ks))
> >> @@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
> >>  		ks->cpu			= cpu;
> >>  		ks->ex_vector		= trapnr;
> >>  		ks->signo		= SIGTRAP;
> >> -		ks->err_code		= KDB_REASON_SYSTEM_NMI;
> >> +		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
> >>  		ks->linux_regs		= regs;
> >>  		ks->send_ready		= send_ready;
> >>  		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
> >> --- linux.orig/kernel/debug/debug_core.h
> >> +++ linux/kernel/debug/debug_core.h
> >> @@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
> >>  extern int kdb_parse(const char *cmdstr);
> >>  extern int kdb_common_init_state(struct kgdb_state *ks);
> >>  extern int kdb_common_deinit_state(void);
> >> +#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
> >>  #else /* ! CONFIG_KGDB_KDB */
> >>  static inline int kdb_stub(struct kgdb_state *ks)
> >>  {
> >>  	return DBG_PASS_EVENT;
> >>  }
> >> +#define KGDB_KDB_REASON_SYSTEM_NMI 0
> >>  #endif /* CONFIG_KGDB_KDB */
> >>  
> >>  #endif /* _DEBUG_CORE_H_ */
> > 
> > Hm, the KGDB_KDB_REASON_SYSTEM_NMI definition is a bit ugly. I still think 
> > there are layering violations here and just kludging it around doesn't 
> > solve it - a helper function that keeps kgdb details to the kgdb code 
> > would.
> > 
> > Anyway, if Jason is fine with this solution and upholds his Acked-by then 
> > I'll merge this into the first patch and apply the two patches.
> > 
> > Thanks,
> > 
> > 	Ingo
> > 
> 
> Would you prefer a simple #ifdef CONFIG_KGDB_KDB around the assignment?

An #ifdef doesn't solve the layering violation!

kernel/debug/debug_core.c didn't have any serious use of #ifdef 
CONFIG_KGDB_KDB before (it used it to flavor a few printks) and I'm not 
convinced it needs one for this feature either.

So if that whole chunk is kdb dependent, why not shuffle that into a 
nicely named function and host it somewhere appropriate in 
kernel/debug/kdb/? That function would turn into an empty inline function 
in the !CONFIG_KGDB_KDB case.

But ... it's up to Jason really whether he wants to abstract that piece of 
code out, I'm just kibitzing here really.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 17:15       ` Ingo Molnar
@ 2013-10-03 17:53         ` Mike Travis
  2013-10-03 17:58           ` Mike Travis
  2013-10-04  6:30           ` Ingo Molnar
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Travis @ 2013-10-03 17:53 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton, Dimitri Sivanich, Hedi Berriche, x86, linux-kernel



On 10/3/2013 10:15 AM, Ingo Molnar wrote:
> 
> * Mike Travis <travis@sgi.com> wrote:
> 
>>
>>
>> On 10/3/2013 9:51 AM, Ingo Molnar wrote:
>>>
>>> * Mike Travis <travis@sgi.com> wrote:
>>>
>>>> Some code added to the debug_core module had KDB dependencies
>>>> that it shouldn't have.
>>>>
>>>> Signed-off-by: Mike Travis <travis@sgi.com>
>>>> ---
>>>>  kernel/debug/debug_core.c |    8 ++++----
>>>>  kernel/debug/debug_core.h |    2 ++
>>>>  2 files changed, 6 insertions(+), 4 deletions(-)
>>>>
>>>> --- linux.orig/kernel/debug/debug_core.c
>>>> +++ linux/kernel/debug/debug_core.c
>>>> @@ -575,8 +575,8 @@ return_normal:
>>>>  		raw_spin_lock(&dbg_slave_lock);
>>>>  
>>>>  #ifdef CONFIG_SMP
>>>> -	/* If SYSTEM_NMI, slaves are already waiting */
>>>> -	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
>>>> +	/* If send_ready set, slaves are already waiting */
>>>> +	if (ks->send_ready)
>>>>  		atomic_set(ks->send_ready, 1);
>>>>  
>>>>  	/* Signal the other CPUs to enter kgdb_wait() */
>>>> @@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
>>>>  	if (arch_kgdb_ops.enable_nmi)
>>>>  		arch_kgdb_ops.enable_nmi(0);
>>>>  
>>>> +	memset(ks, 0, sizeof(struct kgdb_state));
>>>>  	ks->cpu			= raw_smp_processor_id();
>>>>  	ks->ex_vector		= evector;
>>>>  	ks->signo		= signo;
>>>>  	ks->err_code		= ecode;
>>>> -	ks->kgdb_usethreadid	= 0;
>>>>  	ks->linux_regs		= regs;
>>>>  
>>>>  	if (kgdb_reenter_check(ks))
>>>> @@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
>>>>  		ks->cpu			= cpu;
>>>>  		ks->ex_vector		= trapnr;
>>>>  		ks->signo		= SIGTRAP;
>>>> -		ks->err_code		= KDB_REASON_SYSTEM_NMI;
>>>> +		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
>>>>  		ks->linux_regs		= regs;
>>>>  		ks->send_ready		= send_ready;
>>>>  		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
>>>> --- linux.orig/kernel/debug/debug_core.h
>>>> +++ linux/kernel/debug/debug_core.h
>>>> @@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
>>>>  extern int kdb_parse(const char *cmdstr);
>>>>  extern int kdb_common_init_state(struct kgdb_state *ks);
>>>>  extern int kdb_common_deinit_state(void);
>>>> +#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
>>>>  #else /* ! CONFIG_KGDB_KDB */
>>>>  static inline int kdb_stub(struct kgdb_state *ks)
>>>>  {
>>>>  	return DBG_PASS_EVENT;
>>>>  }
>>>> +#define KGDB_KDB_REASON_SYSTEM_NMI 0
>>>>  #endif /* CONFIG_KGDB_KDB */
>>>>  
>>>>  #endif /* _DEBUG_CORE_H_ */
>>>
>>> Hm, the KGDB_KDB_REASON_SYSTEM_NMI definition is a bit ugly. I still think 
>>> there are layering violations here and just kludging it around doesn't 
>>> solve it - a helper function that keeps kgdb details to the kgdb code 
>>> would.
>>>
>>> Anyway, if Jason is fine with this solution and upholds his Acked-by then 
>>> I'll merge this into the first patch and apply the two patches.
>>>
>>> Thanks,
>>>
>>> 	Ingo
>>>
>>
>> Would you prefer a simple #ifdef CONFIG_KGDB_KDB around the assignment?
> 
> An #ifdef doesn't solve the layering violation!
> 
> kernel/debug/debug_core.c didn't have any serious use of #ifdef 
> CONFIG_KGDB_KDB before (it used it to flavor a few printks) and I'm not 
> convinced it needs one for this feature either.
> 
> So if that whole chunk is kdb dependent, why not shuffle that into a 
> nicely named function and host it somewhere appropriate in 
> kernel/debug/kdb/? That function would turn into an empty inline function 
> in the !CONFIG_KGDB_KDB case.
> 
> But ... it's up to Jason really whether he wants to abstract that piece of 
> code out, I'm just kibitzing here really.
> 
> Thanks,
> 
> 	Ingo
> 

If I moved it to KDB then we would lose the capability to enter KGDB
mode and the gdb_stub functionality.  The #ifdef could have a comment
to this effect?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 17:53         ` Mike Travis
@ 2013-10-03 17:58           ` Mike Travis
  2013-10-04  6:30           ` Ingo Molnar
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Travis @ 2013-10-03 17:58 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton, Dimitri Sivanich, Hedi Berriche, x86, linux-kernel



On 10/3/2013 10:53 AM, Mike Travis wrote:
> 
> 
> On 10/3/2013 10:15 AM, Ingo Molnar wrote:
>>
>> * Mike Travis <travis@sgi.com> wrote:
>>
>>>
>>>
>>> On 10/3/2013 9:51 AM, Ingo Molnar wrote:
>>>>
>>>> * Mike Travis <travis@sgi.com> wrote:
>>>>
>>>>> Some code added to the debug_core module had KDB dependencies
>>>>> that it shouldn't have.
>>>>>
>>>>> Signed-off-by: Mike Travis <travis@sgi.com>
>>>>> ---
>>>>>  kernel/debug/debug_core.c |    8 ++++----
>>>>>  kernel/debug/debug_core.h |    2 ++
>>>>>  2 files changed, 6 insertions(+), 4 deletions(-)
>>>>>
>>>>> --- linux.orig/kernel/debug/debug_core.c
>>>>> +++ linux/kernel/debug/debug_core.c
>>>>> @@ -575,8 +575,8 @@ return_normal:
>>>>>  		raw_spin_lock(&dbg_slave_lock);
>>>>>  
>>>>>  #ifdef CONFIG_SMP
>>>>> -	/* If SYSTEM_NMI, slaves are already waiting */
>>>>> -	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
>>>>> +	/* If send_ready set, slaves are already waiting */
>>>>> +	if (ks->send_ready)
>>>>>  		atomic_set(ks->send_ready, 1);
>>>>>  
>>>>>  	/* Signal the other CPUs to enter kgdb_wait() */
>>>>> @@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
>>>>>  	if (arch_kgdb_ops.enable_nmi)
>>>>>  		arch_kgdb_ops.enable_nmi(0);
>>>>>  
>>>>> +	memset(ks, 0, sizeof(struct kgdb_state));
>>>>>  	ks->cpu			= raw_smp_processor_id();
>>>>>  	ks->ex_vector		= evector;
>>>>>  	ks->signo		= signo;
>>>>>  	ks->err_code		= ecode;
>>>>> -	ks->kgdb_usethreadid	= 0;
>>>>>  	ks->linux_regs		= regs;
>>>>>  
>>>>>  	if (kgdb_reenter_check(ks))
>>>>> @@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
>>>>>  		ks->cpu			= cpu;
>>>>>  		ks->ex_vector		= trapnr;
>>>>>  		ks->signo		= SIGTRAP;
>>>>> -		ks->err_code		= KDB_REASON_SYSTEM_NMI;
>>>>> +		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
>>>>>  		ks->linux_regs		= regs;
>>>>>  		ks->send_ready		= send_ready;
>>>>>  		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
>>>>> --- linux.orig/kernel/debug/debug_core.h
>>>>> +++ linux/kernel/debug/debug_core.h
>>>>> @@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
>>>>>  extern int kdb_parse(const char *cmdstr);
>>>>>  extern int kdb_common_init_state(struct kgdb_state *ks);
>>>>>  extern int kdb_common_deinit_state(void);
>>>>> +#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
>>>>>  #else /* ! CONFIG_KGDB_KDB */
>>>>>  static inline int kdb_stub(struct kgdb_state *ks)
>>>>>  {
>>>>>  	return DBG_PASS_EVENT;
>>>>>  }
>>>>> +#define KGDB_KDB_REASON_SYSTEM_NMI 0
>>>>>  #endif /* CONFIG_KGDB_KDB */
>>>>>  
>>>>>  #endif /* _DEBUG_CORE_H_ */
>>>>
>>>> Hm, the KGDB_KDB_REASON_SYSTEM_NMI definition is a bit ugly. I still think 
>>>> there are layering violations here and just kludging it around doesn't 
>>>> solve it - a helper function that keeps kgdb details to the kgdb code 
>>>> would.
>>>>
>>>> Anyway, if Jason is fine with this solution and upholds his Acked-by then 
>>>> I'll merge this into the first patch and apply the two patches.
>>>>
>>>> Thanks,
>>>>
>>>> 	Ingo
>>>>
>>>
>>> Would you prefer a simple #ifdef CONFIG_KGDB_KDB around the assignment?
>>
>> An #ifdef doesn't solve the layering violation!
>>
>> kernel/debug/debug_core.c didn't have any serious use of #ifdef 
>> CONFIG_KGDB_KDB before (it used it to flavor a few printks) and I'm not 
>> convinced it needs one for this feature either.
>>
>> So if that whole chunk is kdb dependent, why not shuffle that into a 
>> nicely named function and host it somewhere appropriate in 
>> kernel/debug/kdb/? That function would turn into an empty inline function 
>> in the !CONFIG_KGDB_KDB case.
>>
>> But ... it's up to Jason really whether he wants to abstract that piece of 
>> code out, I'm just kibitzing here really.
>>
>> Thanks,
>>
>> 	Ingo
>>
> 
> If I moved it to KDB then we would lose the capability to enter KGDB
> mode and the gdb_stub functionality.  The #ifdef could have a comment
> to this effect?
> 

Another option would be to pass the code in as the caller knows if KDB
is defined or not?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] PATCH: KGDB/KDB Fix no KDB config problem.
  2013-10-03 17:53         ` Mike Travis
  2013-10-03 17:58           ` Mike Travis
@ 2013-10-04  6:30           ` Ingo Molnar
  1 sibling, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2013-10-04  6:30 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Jason Wessel, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Thomas Gleixner,
	Andrew Morton, Dimitri Sivanich, Hedi Berriche, x86, linux-kernel


* Mike Travis <travis@sgi.com> wrote:

> 
> 
> On 10/3/2013 10:15 AM, Ingo Molnar wrote:
> > 
> > * Mike Travis <travis@sgi.com> wrote:
> > 
> >>
> >>
> >> On 10/3/2013 9:51 AM, Ingo Molnar wrote:
> >>>
> >>> * Mike Travis <travis@sgi.com> wrote:
> >>>
> >>>> Some code added to the debug_core module had KDB dependencies
> >>>> that it shouldn't have.
> >>>>
> >>>> Signed-off-by: Mike Travis <travis@sgi.com>
> >>>> ---
> >>>>  kernel/debug/debug_core.c |    8 ++++----
> >>>>  kernel/debug/debug_core.h |    2 ++
> >>>>  2 files changed, 6 insertions(+), 4 deletions(-)
> >>>>
> >>>> --- linux.orig/kernel/debug/debug_core.c
> >>>> +++ linux/kernel/debug/debug_core.c
> >>>> @@ -575,8 +575,8 @@ return_normal:
> >>>>  		raw_spin_lock(&dbg_slave_lock);
> >>>>  
> >>>>  #ifdef CONFIG_SMP
> >>>> -	/* If SYSTEM_NMI, slaves are already waiting */
> >>>> -	if (ks->err_code == KDB_REASON_SYSTEM_NMI)
> >>>> +	/* If send_ready set, slaves are already waiting */
> >>>> +	if (ks->send_ready)
> >>>>  		atomic_set(ks->send_ready, 1);
> >>>>  
> >>>>  	/* Signal the other CPUs to enter kgdb_wait() */
> >>>> @@ -682,11 +682,11 @@ kgdb_handle_exception(int evector, int s
> >>>>  	if (arch_kgdb_ops.enable_nmi)
> >>>>  		arch_kgdb_ops.enable_nmi(0);
> >>>>  
> >>>> +	memset(ks, 0, sizeof(struct kgdb_state));
> >>>>  	ks->cpu			= raw_smp_processor_id();
> >>>>  	ks->ex_vector		= evector;
> >>>>  	ks->signo		= signo;
> >>>>  	ks->err_code		= ecode;
> >>>> -	ks->kgdb_usethreadid	= 0;
> >>>>  	ks->linux_regs		= regs;
> >>>>  
> >>>>  	if (kgdb_reenter_check(ks))
> >>>> @@ -750,7 +750,7 @@ int kgdb_nmicallin(int cpu, int trapnr,
> >>>>  		ks->cpu			= cpu;
> >>>>  		ks->ex_vector		= trapnr;
> >>>>  		ks->signo		= SIGTRAP;
> >>>> -		ks->err_code		= KDB_REASON_SYSTEM_NMI;
> >>>> +		ks->err_code		= KGDB_KDB_REASON_SYSTEM_NMI;
> >>>>  		ks->linux_regs		= regs;
> >>>>  		ks->send_ready		= send_ready;
> >>>>  		kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
> >>>> --- linux.orig/kernel/debug/debug_core.h
> >>>> +++ linux/kernel/debug/debug_core.h
> >>>> @@ -75,11 +75,13 @@ extern int kdb_stub(struct kgdb_state *k
> >>>>  extern int kdb_parse(const char *cmdstr);
> >>>>  extern int kdb_common_init_state(struct kgdb_state *ks);
> >>>>  extern int kdb_common_deinit_state(void);
> >>>> +#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
> >>>>  #else /* ! CONFIG_KGDB_KDB */
> >>>>  static inline int kdb_stub(struct kgdb_state *ks)
> >>>>  {
> >>>>  	return DBG_PASS_EVENT;
> >>>>  }
> >>>> +#define KGDB_KDB_REASON_SYSTEM_NMI 0
> >>>>  #endif /* CONFIG_KGDB_KDB */
> >>>>  
> >>>>  #endif /* _DEBUG_CORE_H_ */
> >>>
> >>> Hm, the KGDB_KDB_REASON_SYSTEM_NMI definition is a bit ugly. I still think 
> >>> there are layering violations here and just kludging it around doesn't 
> >>> solve it - a helper function that keeps kgdb details to the kgdb code 
> >>> would.
> >>>
> >>> Anyway, if Jason is fine with this solution and upholds his Acked-by then 
> >>> I'll merge this into the first patch and apply the two patches.
> >>>
> >>> Thanks,
> >>>
> >>> 	Ingo
> >>>
> >>
> >> Would you prefer a simple #ifdef CONFIG_KGDB_KDB around the assignment?
> > 
> > An #ifdef doesn't solve the layering violation!
> > 
> > kernel/debug/debug_core.c didn't have any serious use of #ifdef 
> > CONFIG_KGDB_KDB before (it used it to flavor a few printks) and I'm not 
> > convinced it needs one for this feature either.
> > 
> > So if that whole chunk is kdb dependent, why not shuffle that into a 
> > nicely named function and host it somewhere appropriate in 
> > kernel/debug/kdb/? That function would turn into an empty inline function 
> > in the !CONFIG_KGDB_KDB case.
> > 
> > But ... it's up to Jason really whether he wants to abstract that piece of 
> > code out, I'm just kibitzing here really.
> > 
> > Thanks,
> > 
> > 	Ingo
> > 
> 
> If I moved it to KDB then we would lose the capability to enter KGDB 
> mode and the gdb_stub functionality.  The #ifdef could have a comment to 
> this effect?

No, this really suggests that there's something else broken around there.

Removing #ifdefs around non-trivial code and architecting it properly 
really makes things more reviewable, easier to understand, better 
specified and generally less bug prone. So adding an #ifdef around a pair 
of printk()s is probably OK - anything that is longer than a line probably 
deserves abstracted out.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-04  6:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 16:38 [PATCH 0/1] PATCH: KGDB/KDB Fix no KDB config problem Mike Travis
2013-10-03 16:38 ` [PATCH 1/1] " Mike Travis
2013-10-03 16:51   ` Ingo Molnar
2013-10-03 17:04     ` Mike Travis
2013-10-03 17:15       ` Ingo Molnar
2013-10-03 17:53         ` Mike Travis
2013-10-03 17:58           ` Mike Travis
2013-10-04  6:30           ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).