trace: use this_cpu_ptr per-cpu helper
Subsystems (2)
PATCH v4 7/9 trace: use this_cpu_ptr per-cpu helper
From: Shan Wei <[email protected]>
typeof(&buffer) is a pointer to array of 1024 char, or char (*)[1024].
But, typeof(&buffer[0]) is a pointer to char which match the return type of get_trace_buf(). As well-known, the value of &buffer is equal to &buffer[0].
so return this_cpu_ptr(&percpu_buffer->buffer[0]) can avoid type cast.
---
v4: avoid type cast using &percpu_buffer->buffer[0].
--- kernel/trace/blktrace.c | 2 +- kernel/trace/trace.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-)
kernel/trace/blktrace.c +1 -1
@@ -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);
kernel/trace/trace.c +1 -4
@@ -1495,7 +1495,6 @@ static struct trace_buffer_struct *trace_percpu_nmi_buffer;static char *get_trace_buf (void ) {struct trace_buffer_struct *percpu_buffer; -struct trace_buffer_struct *buffer;/* * If we have allocated per cpu buffers, then we do not
@@ -1513,9 +1512,7 @@ static char *get_trace_buf(void)if (!percpu_buffer)return NULL ; - buffer =per_cpu_ptr (percpu_buffer,smp_processor_id ()); - -return buffer->buffer; +return this_cpu_ptr (&percpu_buffer->buffer[0 ]); }static int alloc_percpu_trace_buffer (void )
Signature · 1 line
1.7.1
Shan Wei said, at 2012/11/13 9:53:
Quoted 8 lines
From: Shan Wei <[email protected]>
typeof(&buffer)is a pointer to array of 1024 char, or char (*)[1024].
But,typeof(&buffer[0])is a pointer to char which match the return type ofget_trace_buf(). As well-known, the value of &buffer is equal to &buffer[0].
so returnthis_cpu_ptr(&percpu_buffer->buffer[0])can avoid type cast.Signed-off-by Shan Wei <[email protected]>
Steven Rostedt, would you like to pick it up to your tree?
Quoted 44 lines
---
v4: avoid type cast using &percpu_buffer->buffer[0].--- kernel/trace/blktrace.c | 2 +- kernel/trace/trace.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-)kernel/trace/blktrace.c +1
-1@@ -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);kernel/trace/trace.c +1
-4@@ -1495,7 +1495,6 @@ static struct trace_buffer_struct *trace_percpu_nmi_buffer;static char *get_trace_buf (void ) {struct trace_buffer_struct *percpu_buffer; -struct trace_buffer_struct *buffer;/* * If we have allocated per cpu buffers, then we do not @@ -1513,9 +1512,7 @@ static char *get_trace_buf(void)if (!percpu_buffer)return NULL ; - buffer =per_cpu_ptr (percpu_buffer,smp_processor_id ()); - -return buffer->buffer; +return this_cpu_ptr (&percpu_buffer->buffer[0 ]); }static int alloc_percpu_trace_buffer (void )
Shan Wei said, at 2012/11/16 16:34:
Quoted 11 lines
Shan Wei said, at 2012/11/13 9:53:
Quoted 8 lines
From: Shan Wei <[email protected]>
typeof(&buffer)is a pointer to array of 1024 char, or char (*)[1024].
But,typeof(&buffer[0])is a pointer to char which match the return type ofget_trace_buf(). As well-known, the value of &buffer is equal to &buffer[0].
so returnthis_cpu_ptr(&percpu_buffer->buffer[0])can avoid type cast.Signed-off-by Shan Wei <[email protected]>Steven Rostedt, would you like to pick it up to your tree?
ping......................
Steven Rostedt
maintainerQuoted 9 lines · Shan Wei
Shan Wei said, at 2012/11/16 16:34:
Quoted 8 lines
Shan Wei said, at 2012/11/13 9:53:
Quoted 7 lines
From: Shan Wei <[email protected]>
typeof(&buffer)is a pointer to array of 1024 char, or char (*)[1024].
But,typeof(&buffer[0])is a pointer to char which match the return type ofget_trace_buf(). As well-known, the value of &buffer is equal to &buffer[0].
so returnthis_cpu_ptr(&percpu_buffer->buffer[0])can avoid type cast.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Shan Wei <[email protected]>Steven Rostedt, would you like to pick it up to your tree?
ping......................
Sorry for the late reply. I've been hacking on other things and my queue of stuff for tip still hasn't been pulled yet. I'll pull this into my tree, and see if I can get it in by the merge window. If the merge window opens this weekend, I'll add this to my 3.9 queue.
-- Steve
[tip:perf/core] tracing: Use this_cpu_ptr per-cpu helper
In reply to Shan WeiCommit-ID: d8a0349c0cea477322c66ea9362f10c62fad5f62 Gitweb: http://git.kernel.org/tip/d8a0349c0cea477322c66ea9362f10c62fad5f62 Author: Shan Wei <[email protected]> AuthorDate: Tue, 13 Nov 2012 09:53:04 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 21 Jan 2013 13:22:30 -0500
tracing: Use this_cpu_ptr per-cpu helper
typeof(&buffer) is a pointer to array of 1024 char, or char (*)[1024].
But, typeof(&buffer[0]) is a pointer to char which match the return type of get_trace_buf(). As well-known, the value of &buffer is equal to &buffer[0].
so return this_cpu_ptr(&percpu_buffer->buffer[0]) can avoid type cast.
--- kernel/trace/blktrace.c | 2 +- kernel/trace/trace.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-)
kernel/trace/blktrace.c +1 -1
@@ -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);
kernel/trace/trace.c +1 -4
@@ -1517,7 +1517,6 @@ static struct trace_buffer_struct *trace_percpu_nmi_buffer;static char *get_trace_buf (void ) {struct trace_buffer_struct *percpu_buffer; -struct trace_buffer_struct *buffer;/* * If we have allocated per cpu buffers, then we do not
@@ -1535,9 +1534,7 @@ static char *get_trace_buf(void)if (!percpu_buffer)return NULL ; - buffer =per_cpu_ptr (percpu_buffer,smp_processor_id ()); - -return buffer->buffer; +return this_cpu_ptr (&percpu_buffer->buffer[0 ]); }static int alloc_percpu_trace_buffer (void )