* [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper
@ 2012-10-31 11:23 Shan Wei
2012-10-31 17:50 ` Christoph Lameter
0 siblings, 1 reply; 6+ messages in thread
From: Shan Wei @ 2012-10-31 11:23 UTC (permalink / raw)
To: rostedt, fweisbec, Kernel-Maillist, mingo, cl
From: Shan Wei <davidshan@tencent.com>
Signed-off-by: Shan Wei <davidshan@tencent.com>
---
kernel/trace/blktrace.c | 2 +-
kernel/trace/trace.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index c0bd030..71259e2 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -147,7 +147,7 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
return;
local_irq_save(flags);
- buf = per_cpu_ptr(bt->msg_data, smp_processor_id());
+ buf = this_cpu_ptr(bt->msg_data);
va_start(args, fmt);
n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
va_end(args);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 31e4f55..81ae35b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1513,7 +1513,7 @@ static char *get_trace_buf(void)
if (!percpu_buffer)
return NULL;
- buffer = per_cpu_ptr(percpu_buffer, smp_processor_id());
+ buffer = this_cpu_ptr(percpu_buffer);
return buffer->buffer;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper
2012-10-31 11:23 [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper Shan Wei
@ 2012-10-31 17:50 ` Christoph Lameter
2012-11-02 15:25 ` Shan Wei
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Lameter @ 2012-10-31 17:50 UTC (permalink / raw)
To: Shan Wei; +Cc: rostedt, fweisbec, Kernel-Maillist, mingo
On Wed, 31 Oct 2012, Shan Wei wrote:
> From: Shan Wei <davidshan@tencent.com>
>
>
> Signed-off-by: Shan Wei <davidshan@tencent.com>
> ---
> kernel/trace/blktrace.c | 2 +-
> kernel/trace/trace.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index c0bd030..71259e2 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -147,7 +147,7 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
> return;
>
> local_irq_save(flags);
> - buf = per_cpu_ptr(bt->msg_data, smp_processor_id());
> + buf = this_cpu_ptr(bt->msg_data);
> va_start(args, fmt);
> n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
> va_end(args);
Ok
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 31e4f55..81ae35b 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1513,7 +1513,7 @@ static char *get_trace_buf(void)
> if (!percpu_buffer)
> return NULL;
>
> - buffer = per_cpu_ptr(percpu_buffer, smp_processor_id());
> + buffer = this_cpu_ptr(percpu_buffer);
>
> return buffer->buffer;
Just do a
return this_cpu_read(percpu_buffer->buffer);
and get rid of the this_cpu_ptr op
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper
2012-10-31 17:50 ` Christoph Lameter
@ 2012-11-02 15:25 ` Shan Wei
2012-11-02 17:53 ` Christoph Lameter
0 siblings, 1 reply; 6+ messages in thread
From: Shan Wei @ 2012-11-02 15:25 UTC (permalink / raw)
To: Christoph Lameter; +Cc: rostedt, fweisbec, Kernel-Maillist, mingo
Christoph Lameter said, at 2012/11/1 1:50:
>>
>> - buffer = per_cpu_ptr(percpu_buffer, smp_processor_id());
>> + buffer = this_cpu_ptr(percpu_buffer);
>>
>> return buffer->buffer;
>
>
> Just do a
>
> return this_cpu_read(percpu_buffer->buffer);
>
> and get rid of the this_cpu_ptr op
can not do that.
kernel/trace/trace.c:1515: error: incompatible types when assigning to type 'char[1024]' from type 'char *'
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper
2012-11-02 15:25 ` Shan Wei
@ 2012-11-02 17:53 ` Christoph Lameter
2012-11-03 4:51 ` Shan Wei
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Lameter @ 2012-11-02 17:53 UTC (permalink / raw)
To: Shan Wei; +Cc: rostedt, fweisbec, Kernel-Maillist, mingo
On Fri, 2 Nov 2012, Shan Wei wrote:
> Christoph Lameter said, at 2012/11/1 1:50:
> >>
> >> - buffer = per_cpu_ptr(percpu_buffer, smp_processor_id());
> >> + buffer = this_cpu_ptr(percpu_buffer);
> >>
> >> return buffer->buffer;
> >
> >
> > Just do a
> >
> > return this_cpu_read(percpu_buffer->buffer);
> >
> > and get rid of the this_cpu_ptr op
>
> can not do that.
> kernel/trace/trace.c:1515: error: incompatible types when assigning to type 'char[1024]' from type 'char *'
hmm.... what is actually returned is a pointer to char right? And buffer
is char[1024] so I guess then you need to pass a pointer to char to
this_cpu_read.
return this_cpu_read(&(percpu_buffer->buffer))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper
2012-11-02 17:53 ` Christoph Lameter
@ 2012-11-03 4:51 ` Shan Wei
2012-11-05 15:18 ` Christoph Lameter
0 siblings, 1 reply; 6+ messages in thread
From: Shan Wei @ 2012-11-03 4:51 UTC (permalink / raw)
To: Christoph Lameter; +Cc: rostedt, fweisbec, Kernel-Maillist, mingo
Christoph Lameter said, at 2012/11/3 1:53:
>
> hmm.... what is actually returned is a pointer to char right? And buffer
> is char[1024] so I guess then you need to pass a pointer to char to
> this_cpu_read.
>
> return this_cpu_read(&(percpu_buffer->buffer))
still error....
kernel/trace/trace.c: In function 'get_trace_buf':
kernel/trace/trace.c:1517: error: lvalue required as unary '&' operand
kernel/trace/trace.c:1517: warning: type defaults to 'int' in declaration of 'type name'
kernel/trace/trace.c:1517: warning: cast from pointer to integer of different size
kernel/trace/trace.c:1517: warning: return from incompatible pointer type
kernel/trace/trace.c:1498: warning: unused variable 'buffer'
kernel/trace/trace.c:1517: error: memory input 1 is not directly addressable
kernel/trace/trace.c:1517: error: memory input 1 is not directly addressable
this_cpu_read just read the actual value which a pointer point to.
some case, we just need the pointer.
It's better to use this_cpu_ptr.
return (char *)this_cpu_ptr(&percpu_buffer->buffer);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper
2012-11-03 4:51 ` Shan Wei
@ 2012-11-05 15:18 ` Christoph Lameter
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2012-11-05 15:18 UTC (permalink / raw)
To: Shan Wei; +Cc: rostedt, fweisbec, Kernel-Maillist, mingo
On Sat, 3 Nov 2012, Shan Wei wrote:
> return (char *)this_cpu_ptr(&percpu_buffer->buffer);
Makes sense since buffer is the actual start of the bytes and not a
pointer to a buffer like what I thought.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-11-05 15:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31 11:23 [PATCH 8/9] trace: use this_cpu_ptr per-cpu helper Shan Wei
2012-10-31 17:50 ` Christoph Lameter
2012-11-02 15:25 ` Shan Wei
2012-11-02 17:53 ` Christoph Lameter
2012-11-03 4:51 ` Shan Wei
2012-11-05 15:18 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox