linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var
@ 2012-11-19  5:21 Shan Wei
  2012-11-19 21:34 ` Christoph Lameter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shan Wei @ 2012-11-19  5:21 UTC (permalink / raw)
  To: rostedt, fweisbec, mingo, Kernel-Maillist, Christoph Lameter

From: Shan Wei <davidshan@tencent.com>

__this_cpu_inc_return() or __this_cpu_dec generates a single instruction,
which is faster than __get_cpu_var operation.

Signed-off-by: Shan Wei <davidshan@tencent.com>
---
 kernel/trace/trace.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 18c0aa8..3795694 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1313,7 +1313,7 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,
 	 */
 	preempt_disable_notrace();
 
-	use_stack = ++__get_cpu_var(ftrace_stack_reserve);
+	use_stack = __this_cpu_inc_return(ftrace_stack_reserve);
 	/*
 	 * We don't need any atomic variables, just a barrier.
 	 * If an interrupt comes in, we don't care, because it would
@@ -1367,7 +1367,7 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,
  out:
 	/* Again, don't let gcc optimize things here */
 	barrier();
-	__get_cpu_var(ftrace_stack_reserve)--;
+	__this_cpu_dec(ftrace_stack_reserve);
 	preempt_enable_notrace();
 
 }
-- 
1.7.1


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

* Re: [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var
  2012-11-19  5:21 [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var Shan Wei
@ 2012-11-19 21:34 ` Christoph Lameter
  2012-11-30  6:37 ` Shan Wei
  2013-02-03 19:18 ` [tip:perf/core] tracing: Use __this_cpu_inc/ dec " tip-bot for Shan Wei
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Lameter @ 2012-11-19 21:34 UTC (permalink / raw)
  To: Shan Wei; +Cc: rostedt, fweisbec, mingo, Kernel-Maillist

On Mon, 19 Nov 2012, Shan Wei wrote:

> __this_cpu_inc_return() or __this_cpu_dec generates a single instruction,
> which is faster than __get_cpu_var operation.

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

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

* Re: [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var
  2012-11-19  5:21 [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var Shan Wei
  2012-11-19 21:34 ` Christoph Lameter
@ 2012-11-30  6:37 ` Shan Wei
  2013-02-03 19:18 ` [tip:perf/core] tracing: Use __this_cpu_inc/ dec " tip-bot for Shan Wei
  2 siblings, 0 replies; 4+ messages in thread
From: Shan Wei @ 2012-11-30  6:37 UTC (permalink / raw)
  To: rostedt, fweisbec, mingo, Kernel-Maillist, Christoph Lameter

ping ......


Shan Wei said, at 2012/11/19 13:21:
> From: Shan Wei <davidshan@tencent.com>
> 
> __this_cpu_inc_return() or __this_cpu_dec generates a single instruction,
> which is faster than __get_cpu_var operation.
> 
> Signed-off-by: Shan Wei <davidshan@tencent.com>
> ---
>  kernel/trace/trace.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 18c0aa8..3795694 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1313,7 +1313,7 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,
>  	 */
>  	preempt_disable_notrace();
>  
> -	use_stack = ++__get_cpu_var(ftrace_stack_reserve);
> +	use_stack = __this_cpu_inc_return(ftrace_stack_reserve);
>  	/*
>  	 * We don't need any atomic variables, just a barrier.
>  	 * If an interrupt comes in, we don't care, because it would
> @@ -1367,7 +1367,7 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,
>   out:
>  	/* Again, don't let gcc optimize things here */
>  	barrier();
> -	__get_cpu_var(ftrace_stack_reserve)--;
> +	__this_cpu_dec(ftrace_stack_reserve);
>  	preempt_enable_notrace();
>  
>  }
> 


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

* [tip:perf/core] tracing: Use __this_cpu_inc/ dec operation instead of __get_cpu_var
  2012-11-19  5:21 [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var Shan Wei
  2012-11-19 21:34 ` Christoph Lameter
  2012-11-30  6:37 ` Shan Wei
@ 2013-02-03 19:18 ` tip-bot for Shan Wei
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Shan Wei @ 2013-02-03 19:18 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, davidshan, rostedt, cl, tglx

Commit-ID:  821465295b36136998ef294fe176fba4e09c1cd9
Gitweb:     http://git.kernel.org/tip/821465295b36136998ef294fe176fba4e09c1cd9
Author:     Shan Wei <davidshan@tencent.com>
AuthorDate: Mon, 19 Nov 2012 13:21:01 +0800
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Fri, 25 Jan 2013 20:36:54 -0500

tracing: Use __this_cpu_inc/dec operation instead of __get_cpu_var

__this_cpu_inc_return() or __this_cpu_dec generates a single instruction,
which is faster than __get_cpu_var operation.

Link: http://lkml.kernel.org/r/50A9C1BD.1060308@gmail.com

Reviewed-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Shan Wei <davidshan@tencent.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ca9b7df..07888e1 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1344,7 +1344,7 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,
 	 */
 	preempt_disable_notrace();
 
-	use_stack = ++__get_cpu_var(ftrace_stack_reserve);
+	use_stack = __this_cpu_inc_return(ftrace_stack_reserve);
 	/*
 	 * We don't need any atomic variables, just a barrier.
 	 * If an interrupt comes in, we don't care, because it would
@@ -1398,7 +1398,7 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,
  out:
 	/* Again, don't let gcc optimize things here */
 	barrier();
-	__get_cpu_var(ftrace_stack_reserve)--;
+	__this_cpu_dec(ftrace_stack_reserve);
 	preempt_enable_notrace();
 
 }

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

end of thread, other threads:[~2013-02-03 19:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19  5:21 [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var Shan Wei
2012-11-19 21:34 ` Christoph Lameter
2012-11-30  6:37 ` Shan Wei
2013-02-03 19:18 ` [tip:perf/core] tracing: Use __this_cpu_inc/ dec " tip-bot for Shan Wei

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).