2012-11-19 05:21:13

by Shan Wei

[permalink] [raw]
Subject: [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var

From: Shan Wei <[email protected]>

__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 <[email protected]>
---
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


Subject: Re: [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var

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 <[email protected]>

2012-11-30 06:37:44

by Shan Wei

[permalink] [raw]
Subject: Re: [PATCH] trace: use __this_cpu_inc/dec operation instead of __get_cpu_var

ping ......


Shan Wei said, at 2012/11/19 13:21:
> From: Shan Wei <[email protected]>
>
> __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 <[email protected]>
> ---
> 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();
>
> }
>