All of lore.kernel.org
 help / color / mirror / Atom feed
* x86: use this_cpu for debug_stack_usage
@ 2013-08-06 17:01 Christoph Lameter
  2013-08-06 17:50 ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Lameter @ 2013-08-06 17:01 UTC (permalink / raw)
  To: rostedt; +Cc: linux-kernel

Reduces overhead a bit and frees up a couple of registers.

Signed-off-by: Christoph Lameter <cl@linux.com>

Index: linux/arch/x86/include/asm/debugreg.h
===================================================================
--- linux.orig/arch/x86/include/asm/debugreg.h	2013-07-30 14:00:30.000000000 -0500
+++ linux/arch/x86/include/asm/debugreg.h	2013-07-30 14:00:57.503076270 -0500
@@ -97,11 +97,11 @@ extern void hw_breakpoint_restore(void);
 DECLARE_PER_CPU(int, debug_stack_usage);
 static inline void debug_stack_usage_inc(void)
 {
-	__get_cpu_var(debug_stack_usage)++;
+	__this_cpu_inc(debug_stack_usage);
 }
 static inline void debug_stack_usage_dec(void)
 {
-	__get_cpu_var(debug_stack_usage)--;
+	__this_cpu_dec(debug_stack_usage);
 }
 int is_debug_stack(unsigned long addr);
 void debug_stack_set_zero(void);

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

* Re: x86: use this_cpu for debug_stack_usage
  2013-08-06 17:01 x86: use this_cpu for debug_stack_usage Christoph Lameter
@ 2013-08-06 17:50 ` Steven Rostedt
  2013-08-06 18:50   ` Christoph Lameter
  2013-08-06 18:56   ` Christoph Lameter
  0 siblings, 2 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-08-06 17:50 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

On Tue, 2013-08-06 at 17:01 +0000, Christoph Lameter wrote:
> Reduces overhead a bit and frees up a couple of registers.
> 
> Signed-off-by: Christoph Lameter <cl@linux.com>
> 
> Index: linux/arch/x86/include/asm/debugreg.h
> ===================================================================
> --- linux.orig/arch/x86/include/asm/debugreg.h	2013-07-30 14:00:30.000000000 -0500
> +++ linux/arch/x86/include/asm/debugreg.h	2013-07-30 14:00:57.503076270 -0500
> @@ -97,11 +97,11 @@ extern void hw_breakpoint_restore(void);
>  DECLARE_PER_CPU(int, debug_stack_usage);
>  static inline void debug_stack_usage_inc(void)
>  {
> -	__get_cpu_var(debug_stack_usage)++;
> +	__this_cpu_inc(debug_stack_usage);

I don't remember why I didn't use this in the first place. Perhaps I was
still in the "get_cpu" mind set.

Also, what's the difference between "__this_cpu_inc()" and
"this_cpu_inc()"?

>  }
>  static inline void debug_stack_usage_dec(void)
>  {
> -	__get_cpu_var(debug_stack_usage)--;
> +	__this_cpu_dec(debug_stack_usage);
>  }
>  int is_debug_stack(unsigned long addr);
>  void debug_stack_set_zero(void);

Might as well change is_debug_stack() to use __this_cpu_read() instead
of __get_cpu_var().

-- Steve



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

* Re: x86: use this_cpu for debug_stack_usage
  2013-08-06 17:50 ` Steven Rostedt
@ 2013-08-06 18:50   ` Christoph Lameter
  2013-08-06 18:56   ` Christoph Lameter
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Lameter @ 2013-08-06 18:50 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel

On Tue, 6 Aug 2013, Steven Rostedt wrote:

> I don't remember why I didn't use this in the first place. Perhaps I was
> still in the "get_cpu" mind set.
>
> Also, what's the difference between "__this_cpu_inc()" and
> "this_cpu_inc()"?

The fallback logic for arches not supporting segment prefixes is differnt.
this_cpu_inc() disables interrupts.

__this_cpu_inc() is used when you know that the scheduler cannot move the
process.

The code generated by both is the same on x86.

> >  int is_debug_stack(unsigned long addr);
> >  void debug_stack_set_zero(void);
>
> Might as well change is_debug_stack() to use __this_cpu_read() instead
> of __get_cpu_var().

True and that will also shave off some instructions.


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

* Re: x86: use this_cpu for debug_stack_usage
  2013-08-06 17:50 ` Steven Rostedt
  2013-08-06 18:50   ` Christoph Lameter
@ 2013-08-06 18:56   ` Christoph Lameter
  2013-08-06 19:02     ` Steven Rostedt
  1 sibling, 1 reply; 7+ messages in thread
From: Christoph Lameter @ 2013-08-06 18:56 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel

> Might as well change is_debug_stack() to use __this_cpu_read() instead
> of __get_cpu_var().





Subject: x86: use this_cpu for debug_stack_usage

Reduces overhead a bit and frees up a couple of registers.

Signed-off-by: Christoph Lameter <cl@linux.com>

Index: linux/arch/x86/include/asm/debugreg.h
===================================================================
--- linux.orig/arch/x86/include/asm/debugreg.h	2013-08-06 13:52:23.740092873 -0500
+++ linux/arch/x86/include/asm/debugreg.h	2013-08-06 13:52:23.740092873 -0500
@@ -97,11 +97,11 @@ extern void hw_breakpoint_restore(void);
 DECLARE_PER_CPU(int, debug_stack_usage);
 static inline void debug_stack_usage_inc(void)
 {
-	__get_cpu_var(debug_stack_usage)++;
+	__this_cpu_inc(debug_stack_usage);
 }
 static inline void debug_stack_usage_dec(void)
 {
-	__get_cpu_var(debug_stack_usage)--;
+	__this_cpu_dec(debug_stack_usage);
 }
 int is_debug_stack(unsigned long addr);
 void debug_stack_set_zero(void);
Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c	2013-07-19 09:06:36.850047837 -0500
+++ linux/arch/x86/kernel/cpu/common.c	2013-08-06 13:54:36.426384889 -0500
@@ -1144,9 +1144,9 @@ DEFINE_PER_CPU(int, debug_stack_usage);

 int is_debug_stack(unsigned long addr)
 {
-	return __get_cpu_var(debug_stack_usage) ||
-		(addr <= __get_cpu_var(debug_stack_addr) &&
-		 addr > (__get_cpu_var(debug_stack_addr) - DEBUG_STKSZ));
+	return __this_cpu_read(debug_stack_usage) ||
+		(addr <= __this_cpu_read(debug_stack_addr) &&
+		 addr > (__this_cpu_read(debug_stack_addr) - DEBUG_STKSZ));
 }

 DEFINE_PER_CPU(u32, debug_idt_ctr);

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

* Re: x86: use this_cpu for debug_stack_usage
  2013-08-06 18:56   ` Christoph Lameter
@ 2013-08-06 19:02     ` Steven Rostedt
  2013-08-06 20:07       ` H. Peter Anvin
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2013-08-06 19:02 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin

On Tue, 2013-08-06 at 18:56 +0000, Christoph Lameter wrote:
> > Might as well change is_debug_stack() to use __this_cpu_read() instead
> > of __get_cpu_var().

I just noticed that you didn't include the x86 maintainers.

Reviewed-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> 
> 
> 
> 
> 
> Subject: x86: use this_cpu for debug_stack_usage
> 
> Reduces overhead a bit and frees up a couple of registers.
> 
> Signed-off-by: Christoph Lameter <cl@linux.com>
> 
> Index: linux/arch/x86/include/asm/debugreg.h
> ===================================================================
> --- linux.orig/arch/x86/include/asm/debugreg.h	2013-08-06 13:52:23.740092873 -0500
> +++ linux/arch/x86/include/asm/debugreg.h	2013-08-06 13:52:23.740092873 -0500
> @@ -97,11 +97,11 @@ extern void hw_breakpoint_restore(void);
>  DECLARE_PER_CPU(int, debug_stack_usage);
>  static inline void debug_stack_usage_inc(void)
>  {
> -	__get_cpu_var(debug_stack_usage)++;
> +	__this_cpu_inc(debug_stack_usage);
>  }
>  static inline void debug_stack_usage_dec(void)
>  {
> -	__get_cpu_var(debug_stack_usage)--;
> +	__this_cpu_dec(debug_stack_usage);
>  }
>  int is_debug_stack(unsigned long addr);
>  void debug_stack_set_zero(void);
> Index: linux/arch/x86/kernel/cpu/common.c
> ===================================================================
> --- linux.orig/arch/x86/kernel/cpu/common.c	2013-07-19 09:06:36.850047837 -0500
> +++ linux/arch/x86/kernel/cpu/common.c	2013-08-06 13:54:36.426384889 -0500
> @@ -1144,9 +1144,9 @@ DEFINE_PER_CPU(int, debug_stack_usage);
> 
>  int is_debug_stack(unsigned long addr)
>  {
> -	return __get_cpu_var(debug_stack_usage) ||
> -		(addr <= __get_cpu_var(debug_stack_addr) &&
> -		 addr > (__get_cpu_var(debug_stack_addr) - DEBUG_STKSZ));
> +	return __this_cpu_read(debug_stack_usage) ||
> +		(addr <= __this_cpu_read(debug_stack_addr) &&
> +		 addr > (__this_cpu_read(debug_stack_addr) - DEBUG_STKSZ));
>  }
> 
>  DEFINE_PER_CPU(u32, debug_idt_ctr);



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

* Re: x86: use this_cpu for debug_stack_usage
  2013-08-06 19:02     ` Steven Rostedt
@ 2013-08-06 20:07       ` H. Peter Anvin
  2013-08-06 20:11         ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2013-08-06 20:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Christoph Lameter, linux-kernel, Thomas Gleixner, Ingo Molnar

On 08/06/2013 12:02 PM, Steven Rostedt wrote:
> On Tue, 2013-08-06 at 18:56 +0000, Christoph Lameter wrote:
>>> Might as well change is_debug_stack() to use __this_cpu_read() instead
>>> of __get_cpu_var().
> 
> I just noticed that you didn't include the x86 maintainers.
> 
> Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
> 

Looks good to me.

Do you want an ACK from me or do you want me to pick it up?

	-hpa



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

* Re: x86: use this_cpu for debug_stack_usage
  2013-08-06 20:07       ` H. Peter Anvin
@ 2013-08-06 20:11         ` Steven Rostedt
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-08-06 20:11 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Christoph Lameter, linux-kernel, Thomas Gleixner, Ingo Molnar

On Tue, 2013-08-06 at 13:07 -0700, H. Peter Anvin wrote:
> On 08/06/2013 12:02 PM, Steven Rostedt wrote:
> > On Tue, 2013-08-06 at 18:56 +0000, Christoph Lameter wrote:
> >>> Might as well change is_debug_stack() to use __this_cpu_read() instead
> >>> of __get_cpu_var().
> > 
> > I just noticed that you didn't include the x86 maintainers.
> > 
> > Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
> > 
> 
> Looks good to me.
> 
> Do you want an ACK from me or do you want me to pick it up?
> 

You can take it.

Thanks,

-- Steve



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

end of thread, other threads:[~2013-08-06 20:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-06 17:01 x86: use this_cpu for debug_stack_usage Christoph Lameter
2013-08-06 17:50 ` Steven Rostedt
2013-08-06 18:50   ` Christoph Lameter
2013-08-06 18:56   ` Christoph Lameter
2013-08-06 19:02     ` Steven Rostedt
2013-08-06 20:07       ` H. Peter Anvin
2013-08-06 20:11         ` Steven Rostedt

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.