tracing/events: convert block trace points to TRACE_EVENT()
Subsystems (6)
v2 cover tracing/events: convert block trace points to TRACE_EVENT()
Here's the v2 patchset to convert block trace points to TRACE_EVENT().
The biggest change is to use __string() instead of __array() to store hex dump of rq->cmd, so we minimize the memory occupied by rq->cmd from 48 bytes to 3 bytes for fs events. Also some fixes and cleanups.
I haven't had time to benchmark the ioctl blktrace versus the splice based TRACE_EVENT tracing, but will do in these 2 days.
This patchset should be applied on top of:
"[PATCH] tracing/events: change the type of __str_loc_item to unsigned short"
(http://lkml.org/lkml/2009/5/21/17)
which hasn't been applied to tip tree.
[PATCH v2 1/2] tracing/events: make __string() more general [PATCH v2 2/2] tracing/events: convert block trace points to TRACE_EVENT()
--- block/blk-core.c | 16 +- block/elevator.c | 8 +- drivers/md/dm.c | 5 +- fs/bio.c | 3 +- include/linux/blktrace_api.h | 13 + include/trace/block.h | 76 ------- include/trace/events/block.h | 483 ++++++++++++++++++++++++++++++++++++++++ include/trace/events/irq.h | 12 +- include/trace/events/lockdep.h | 8 +- include/trace/ftrace.h | 21 +- kernel/trace/Makefile | 5 +- kernel/trace/blktrace.c | 78 +++++++- mm/bounce.c | 5 +- 13 files changed, 611 insertions(+), 122 deletions(-)
A sample output:
konsole-2057 [001] 870.751689: block_unplug_io: [konsole] 2
<idle>-0 [001] 870.759674: block_rq_complete: 8,0 R () 115104312 + 24 [0]
<idle>-0 [001] 870.760744: block_rq_complete: 8,0 R () 115104344 + 120 [0]
konsole-2057 [001] 870.761233: block_remap: 8,0 R 115132584 + 256 <- (8,8) 12428976
konsole-2057 [001] 870.761234: block_bio_queue: 8,0 R 115132584 + 256 [konsole]
konsole-2057 [001] 870.761239: block_getrq: 8,0 R 115132584 + 256 [konsole]
konsole-2057 [001] 870.761243: block_plug: [konsole]
konsole-2057 [001] 870.761244: block_rq_insert: 8,0 R 0 () 115132584 + 256 [konsole]
konsole-2057 [001] 870.761248: block_rq_issue: 8,0 R 0 () 115132584 + 256 [konsole]
konsole-2057 [001] 870.761311: block_unplug_io: [konsole] 1
<idle>-0 [001] 870.770299: block_rq_complete: 8,0 R () 115132584 + 256 [0]
konsole-2057 [001] 870.770603: block_remap: 8,0 R 115143352 + 8 <- (8,8) 12439744
konsole-2057 [001] 870.770604: block_bio_queue: 8,0 R 115143352 + 8 [konsole]
konsole-2057 [001] 870.770609: block_getrq: 8,0 R 115143352 + 8 [konsole]
konsole-2057 [001] 870.770612: block_plug: [konsole]
konsole-2057 [001] 870.770614: block_rq_insert: 8,0 R 0 () 115143352 + 8 [konsole]
konsole-2057 [001] 870.770666: block_remap: 8,0 R 115143376 + 104 <- (8,8) 12439768
konsole-2057 [001] 870.770667: block_bio_queue: 8,0 R 115143376 + 104 [konsole]
konsole-2057 [001] 870.770672: block_getrq: 8,0 R 115143376 + 104 [konsole]
konsole-2057 [001] 870.770674: block_rq_insert: 8,0 R 0 () 115143376 + 104 [konsole]
konsole-2057 [001] 870.770678: block_rq_issue: 8,0 R 0 () 115143352 + 8 [konsole]
konsole-2057 [001] 870.770736: block_rq_issue: 8,0 R 0 () 115143376 + 104 [konsole]
konsole-2057 [001] 870.770744: block_unplug_io: [konsole] 2
<idle>-0 [001] 870.780006: block_rq_complete: 8,0 R () 115143352 + 8 [0]
konsole-2057 [001] 870.780423: block_remap: 8,0 R 115184728 + 168 <- (8,8) 12481120
konsole-2057 [001] 870.780424: block_bio_queue: 8,0 R 115184728 + 168 [konsole]
konsole-2057 [001] 870.780429: block_getrq: 8,0 R 115184728 + 168 [konsole]
konsole-2057 [001] 870.780432: block_plug: [konsole]
konsole-2057 [001] 870.780433: block_rq_insert: 8,0 R 0 () 115184728 + 168 [konsole]
konsole-2057 [001] 870.780437: block_rq_issue: 8,0 R 0 () 115184728 + 168 [konsole]
konsole-2057 [001] 870.780483: block_remap: 8,0 R 115187448 + 88 <- (8,8) 12483840
konsole-2057 [001] 870.780484: block_bio_queue: 8,0 R 115187448 + 88 [konsole]
konsole-2057 [001] 870.780488: block_getrq: 8,0 R 115187448 + 88 [konsole]
konsole-2057 [001] 870.780490: block_rq_insert: 8,0 R 0 () 115187448 + 88 [konsole]
konsole-2057 [001] 870.780496: block_unplug_io: [konsole] 3
<idle>-0 [001] 870.781010: block_rq_complete: 8,0 R () 115143376 + 104 [0]
<idle>-0 [001] 870.781076: block_rq_issue: 8,0 R 0 () 115187448 + 88 [swapper]
<idle>-0 [001] 870.792032: block_rq_complete: 8,0 R () 115184728 + 168 [0]
X-1702 [001] 870.801456: block_rq_complete: 8,0 R () 115187448 + 88 [0]PATCH v2 1/2 tracing/events: make __string() more general
This changes __string(..., src) to __string(..., len), thus makes it more general, and then block TRACE_EVENT() can use it.
Also introduce __fetch_str(), which is used in TP_assign() and returns the address of the string, while __get_str() is used in TP_print().
[ Impact: TRACE_EVENT api change ]
--- include/trace/events/irq.h | 12 ++++++------ include/trace/events/lockdep.h | 8 ++++---- include/trace/ftrace.h | 21 +++++++++++++-------- 3 files changed, 23 insertions(+), 18 deletions(-)
include/trace/events/irq.h +6 -6
@@ -25,8 +25,8 @@ TRACE_EVENT(irq_handler_entry,TP_ARGS (irq, action),TP_STRUCT__entry ( - __field( int, irq ) -__string ( name, action->name ) + __field( int, irq ) +__string ( name,strlen (action->name) ) ), TP_fast_assign(
@@ -86,8 +86,8 @@ TRACE_EVENT(softirq_entry,TP_ARGS (h, vec),TP_STRUCT__entry ( - __field( int, vec ) -__string ( name, softirq_to_name[h-vec] ) + __field( int, vec ) +__string ( name,strlen (softirq_to_name[h-vec]) ) ), TP_fast_assign(
@@ -116,8 +116,8 @@ TRACE_EVENT(softirq_exit,TP_ARGS (h, vec),TP_STRUCT__entry ( - __field( int, vec ) -__string ( name, softirq_to_name[h-vec] ) + __field( int, vec ) +__string ( name,strlen (softirq_to_name[h-vec]) ) ), TP_fast_assign(
include/trace/events/lockdep.h +4 -4
@@ -19,7 +19,7 @@ TRACE_EVENT(lock_acquire,TP_STRUCT__entry (__field (unsigned int ,flags ) - __string(name, lock->name) + __string(name, strlen(lock->name)) ), TP_fast_assign(
@@ -39,7 +39,7 @@ TRACE_EVENT(lock_release,TP_ARGS (lock, nested, ip),TP_STRUCT__entry ( -__string (name, lock->name) +__string (name,strlen (lock->name)) ), TP_fast_assign(
@@ -58,7 +58,7 @@ TRACE_EVENT(lock_contended,TP_ARGS (lock, ip),TP_STRUCT__entry ( -__string (name, lock->name) +__string (name,strlen (lock->name)) ), TP_fast_assign(
@@ -74,7 +74,7 @@ TRACE_EVENT(lock_acquired,TP_ARGS (lock, ip, waittime),TP_STRUCT__entry ( - __string(name, lock->name) + __string(name, strlen(lock->name)) __field(unsigned long, wait_usec) __field(unsigned long, wait_nsec_rem) ),
include/trace/ftrace.h +13 -8
@@ -25,7 +25,7 @@#define __field (type, item) type item;#undef __string -#define __string (item, src) unsigned short __str_loc_##item; +#define __string (item, len) unsigned short __str_loc_##item;#undef TP_STRUCT__entry #define TP_STRUCT__entry(args...) args
@@ -66,7 +66,7 @@#define __field (type, item);#undef __string -#define __string (item, src) int item; +#define __string (item, len) int item;#undef TRACE_EVENT#define TRACE_EVENT (call, proto, args, tstruct, assign, print) \
@@ -186,7 +186,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \return 0 ;#undef __string -#define __string (item, src) \ +#define __string (item, len) \ ret = trace_seq_printf(s, "\tfield: __str_loc " #item ";\t" \ "offset:%u;tsize:%u;\n", \ (unsigned int)offsetof(typeof(field), \
@@ -239,7 +239,7 @@ ftrace_format_##call(struct trace_seq *s) \return ret;#undef __string -#define __string (item, src) \ +#define __string (item, len) \ ret = trace_define_field(event_call, "__str_loc", #item, \ offsetof(typeof(field), __str_loc_##item), \ sizeof(field.__str_loc_##item), 0);
@@ -411,10 +411,15 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *call) \#define __array (type, item, len)#undef __string -#define __string (item, src) \ - __str_offsets.item = __str_size + \ - offsetof(typeof(*entry), __str_data); \ - __str_size += strlen(src) + 1; +#define __string (item, len) \ + __str_offsets.item = __str_size + \ + offsetof(typeof(*entry), __str_data); \ + __str_size += (len) + 1; + +#undef __fetch_str +#define __fetch_str (dst) \ + ({__entry->__str_loc_##dst = __str_offsets.dst; \ + __get_str(dst);})#undef __assign_str#define __assign_str (dst, src) \
Signature · 1 line
1.5.4.rc3
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 5 lines · Li Zefan
This changes
__string(..., src)to__string(..., len), thus makes it more general, and then blockTRACE_EVENT()can use it.Also introduce
__fetch_str(), which is used inTP_assign()and returns the address of the string, while__get_str()is used inTP_print().
If you want to make it really generaly dealing with NULL string pointers would be extremly helpful. I ran into that limitation (and the length one fixed here) when converting the XFS tracing over.
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Li Zefan
This changes
__string(..., src)to__string(..., len), thus makes it more general, and then blockTRACE_EVENT()can use it.Also introduce
__fetch_str(), which is used inTP_assign()and returns the address of the string, while__get_str()is used inTP_print().If you want to make it really generaly dealing with NULL string pointers would be extremly helpful. I ran into that limitation (and the length one fixed here) when converting the XFS tracing over.
I'm not suffering from NULL str, so I'm not quite sure how you want __string() deal with it.
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 2 lines · Li Zefan
I'm not suffering from NULL str, so I'm not quite sure how you want
__string()deal with it.
The internals of __string is still magic to me, need to finish my advance cpp abuse degree first ;-)
But the expected outcome would be that when we get a NULL pointer as input we get a NULL pointer as output again.
What I currently do is:
TRACE_EVENT(xfs_dir2,
TP_PROTO(struct xfs_da_args *args, int i, int j, int count),
TP_ARGS(args, i, j, count),
TP_STRUCT__entry(
__field(xfs_ino_t, ino)
__array(char, name, TRACE_MAXNAMELEN)
__field(int, namelen)
...
),
TP_fast_assign(
__entry->ino = args->dp->i_ino;
if (args->namelen)
memcpy(__entry->name, args->name,
min(args->namelen, TRACE_MAXNAMELEN));
__entry->namelen = args->namelen;
...
),
TP_printk("ino 0x%lld %pF name %.*s namelen %d hashval 0x%x "
"inumber 0x%llx op_flags %s i %d j %d count %d",
__entry->ino,
(void *)__entry->caller_ip,
min(__entry->namelen, TRACE_MAXNAMELEN),
__entry->namelen ? __entry->name : NULL,
__entry->namelen,
...));
Quoted 2 lines
---end quoted text---
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Li Zefan
I'm not suffering from NULL str, so I'm not quite sure how you want
__string()deal with it.The internals of
__stringis still magic to me, need to finish my advance cpp abuse degree first ;-)
It's no longer magic to me. ;)
Quoted 3 lines
But the expected outcome would be that when we get a NULL pointer as input we get a NULL pointer as output again.
The following trick should meet your needs (based on this 1/2 patch):
(Not even compiled!)
include/trace/ftrace.h +9 -3
@@ -117,7 +117,10 @@ #define TP_printk(fmt, args...) fmt "\n", args#undef __get_str -#define __get_str (field) ((char *)__entry + __entry->__str_loc_##field) +#define __get_str (field) \ + (__entry->__str_lock_##field != -1) ? \ + ((char *)__entry + __entry->__str_loc_##field) : \ + NULL#undef TRACE_EVENT#define TRACE_EVENT (call, proto, args, tstruct, assign, print) \
@@ -412,8 +415,11 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *call) \#undef __string#define __string (item, len) \ - __str_offsets.item = __str_size + \ - offsetof(typeof(*entry), __str_data); \ + if (len) \ + __str_offsets.item = __str_size + \ + offsetof(typeof(*entry), __str_data);\ + else \ + __str_offsets.item = -1; \ __str_size += (len) + 1;#undef __fetch_str
Quoted 18 lines
What I currently do is:
TRACE_EVENT(xfs_dir2,
TP_PROTO(struct xfs_da_args *args, int i, int j, int count), TP_ARGS(args, i, j, count), TP_STRUCT__entry( __field(xfs_ino_t, ino) __array(char, name, TRACE_MAXNAMELEN) __field(int, namelen) ... ), TP_fast_assign( __entry->ino = args->dp->i_ino; if (args->namelen) memcpy(__entry->name, args->name, min(args->namelen, TRACE_MAXNAMELEN));
This string is not NULL-terminated?
Quoted 12 lines
__entry->namelen = args->namelen;
...
),
TP_printk("ino 0x%lld %pF name %.*s namelen %d hashval 0x%x "
"inumber 0x%llx op_flags %s i %d j %d count %d",
__entry->ino,
(void *)__entry->caller_ip,
min(__entry->namelen, TRACE_MAXNAMELEN),
__entry->namelen ? __entry->name : NULL,
__entry->namelen,
...)Quoted 2 lines
);
Then the above code can be rewrote:
TRACE_EVENT(xfs_dir2,
TP_PROTO(struct xfs_da_args *args, int i, int j, int count),
TP_ARGS(args, i, j, count),
TP_STRUCT__entry(
__field(xfs_ino_t, ino)
__string(name, args->namelen)
__field(int, namelen)
...
),
TP_fast_assign(
__entry->ino = args->dp->i_ino;
memcpy(__fetch_str(name), args->name, args->namelen);
__entry->namelen = args->namelen;
...
),
TP_printk("ino 0x%lld %pF name %.*s namelen %d hashval 0x%x "
"inumber 0x%llx op_flags %s i %d j %d count %d",
__entry->ino,
(void *)__entry->caller_ip,
__entry->namelen,
__get_str(name),
__entry->namelen,
...));
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 7 lines · Li Zefan
Quoted 5 lines
TP_fast_assign( __entry->ino = args->dp->i_ino; if (args->namelen) memcpy(__entry->name, args->name, min(args->namelen, TRACE_MAXNAMELEN));This string is not NULL-terminated?
As written a little above it's indeed not NULL-terminated.
Quoted 20 lines
Then the above code can be rewrote:
TRACE_EVENT(xfs_dir2,
TP_PROTO(struct xfs_da_args *args, int i, int j, int count), TP_ARGS(args, i, j, count), TP_STRUCT__entry( __field(xfs_ino_t, ino) __string(name, args->namelen) __field(int, namelen) ... ), TP_fast_assign( __entry->ino = args->dp->i_ino; memcpy(__fetch_str(name), args->name, args->namelen); __entry->namelen = args->namelen; ... ),
Quoted 7 lines
TP_printk("ino 0x%lld %pF name %.*s namelen %d hashval 0x%x "
"inumber 0x%llx op_flags %s i %d j %d count %d",
__entry->ino,
(void *)__entry->caller_ip,
__entry->namelen,
__get_str(name),
__entry->namelen,That's indeed wht I would love to see.
Steven Rostedt
maintainerRe: [PATCH v2 1/2] tracing/events: make __string() more general
In reply to Li ZefanQuoted 7 lines · Li Zefan
This changes
__string(..., src)to__string(..., len), thus makes it more general, and then blockTRACE_EVENT()can use it.Also introduce
__fetch_str(), which is used inTP_assign()and returns the address of the string, while__get_str()is used inTP_print().[ Impact:
TRACE_EVENTapi change ]
What's the reason for the change?
Is it to handle NULL pointers? If so, lets change the ftrace.h to handle it instead.
This is why I like the Impact line really be a "rational" line.
"TRACE_EVENT api change" is meaningless to me.
-- Steve
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 9 lines · Steven Rostedt
Quoted 6 lines · Li Zefan
This changes
__string(..., src)to__string(..., len), thus makes it more general, and then blockTRACE_EVENT()can use it.Also introduce
__fetch_str(), which is used inTP_assign()and returns the address of the string, while__get_str()is used inTP_print().
Quoted 7 lines
Quoted 1 line
[ Impact:
TRACE_EVENTapi change ]What's the reason for the change?
Is it to handle NULL pointers? If so, lets change the
ftrace.hto handle it instead.
No, not for this purpose.
With __string(..., src), we need to have a source string, but sometimes no source string is available, and what we know is how big the string will be.
Take block trace events for example, I want to convert an unsigned char array into a string, after this patch, this can be done this way:
TP_STRUCT_entry(
__string( cmd, rq->cmd_len * 3 )
)
TP_fast_assign(
construct_str( cmd )
)
TP_prink("%s\n", get_str(cmd))
Seems Christoph also runs into this problem while doing his XFS tracing. (and NULL str ptr that I'm not suffering)
Quoted 3 lines
This is why I like the Impact line really be a "rational" line.
"TRACE_EVENTapi change" is meaningless to me.
So what should this impact be. :(
Steven Rostedt
maintainerRe: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 26 lines · Li Zefan
Quoted 9 lines · Steven Rostedt
Quoted 6 lines · Li Zefan
This changes
__string(..., src)to__string(..., len), thus makes it more general, and then blockTRACE_EVENT()can use it.Also introduce
__fetch_str(), which is used inTP_assign()and returns the address of the string, while__get_str()is used inTP_print().Quoted 7 lines
Quoted 1 line
[ Impact:
TRACE_EVENTapi change ]What's the reason for the change?
Is it to handle NULL pointers? If so, lets change the
ftrace.hto handle it instead.No, not for this purpose.
With
__string(..., src), we need to have a source string, but sometimes no source string is available, and what we know is how big the string will be.Take block trace events for example, I want to convert an unsigned char array into a string, after this patch, this can be done this way:
Quoted 6 lines
TP_STRUCT_entry(
__string( cmd, rq->cmd_len * 3 ))
TP_fast_assign(
construct_str( cmd )
What does the construct_str do?
Quoted 4 lines
)
TP_prink("%s\n", get_str(cmd))
Quoted 8 lines
Seems Christoph also runs into this problem while doing his XFS tracing. (and NULL str ptr that I'm not suffering)
Quoted 3 lines
This is why I like the Impact line really be a "rational" line.
"TRACE_EVENTapi change" is meaningless to me.So what should this impact be. :(
That's the point. I don't know the purpose of the patch except that it changes the API. But changing the API is the means to the end. I'm still confused by what the end is.
-- Steve
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 25 lines · Steven Rostedt
Quoted 23 lines · Li Zefan
Quoted 5 lines · Steven Rostedt
Quoted 3 lines · Li Zefan
This changes
__string(..., src)to__string(..., len), thus makes it more general, and then blockTRACE_EVENT()can use it.Quoted 9 lines
Quoted 4 lines
Also introduce
__fetch_str(), which is used inTP_assign()and returns the address of the string, while__get_str()is used inTP_print().[ Impact:
TRACE_EVENTapi change ]What's the reason for the change?
Is it to handle NULL pointers? If so, lets change the
ftrace.hto handle it instead.No, not for this purpose.
With
__string(..., src), we need to have a source string, but sometimes no source string is available, and what we know is how big the string will be.Take block trace events for example, I want to convert an unsigned char array into a string, after this patch, this can be done this way:
Quoted 9 lines
Quoted 6 lines
TP_STRUCT_entry(
__string( cmd, rq->cmd_len * 3 ))
TP_fast_assign(
construct_str( cmd )What does the
construct_strdo?
Ah, it's pseudo code.. Should be construct_str(__entry->cmd, rq), this helper function convert rq->cmd (unsigned char[]) to a string of hex dump.
No source string is available, so I'm not calling assign_str() in TP_fast_assign.
Quoted 17 lines
Quoted 5 lines
)
TP_prink("%s\n", get_str(cmd))Quoted 7 lines
Seems Christoph also runs into this problem while doing his XFS tracing. (and NULL str ptr that I'm not suffering)
Quoted 3 lines
This is why I like the Impact line really be a "rational" line.
"TRACE_EVENTapi change" is meaningless to me.So what should this impact be. :(
That's the point. I don't know the purpose of the patch except that it changes the API. But changing the API is the means to the end. I'm still confused by what the end is.
Steven Rostedt
maintainerRe: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 17 lines · Li Zefan
Quoted 7 lines
Quoted 7 lines
With
__string(..., src), we need to have a source string, but sometimes no source string is available, and what we know is how big the string will be.Take block trace events for example, I want to convert an unsigned char array into a string, after this patch, this can be done this way:
Quoted 9 lines
Quoted 6 lines
TP_STRUCT_entry(
__string( cmd, rq->cmd_len * 3 ))
TP_fast_assign(
construct_str( cmd )What does the
construct_strdo?
Quoted 6 lines
Ah, it's pseudo code.. Should be
construct_str(__entry->cmd, rq), this helper function convertrq->cmd(unsigned char[]) to a string of hex dump.No source string is available, so I'm not calling
assign_str()inTP_fast_assign.
OK, I think I have a better understanding of what you are doing.
But, I don't like changing the interface for string by adding that "strlen" to all users. I find that very ugly.
Could we instead perhaps add a __dynamic_array? That would take a length, and append itself to after the strings?
stage 1:
#define __dynamic_array(item, len) int __dyn_loc_##item;
stage 2:
#define __dynamic_array(item, len) int item;
stage 3:
#define __get_dynamic_array(item) \ ((void *)__entry + __entry->__str_loc_##field
stage 4:
#define __dynamic_array(item, len) \ __str_offsets.item = __str_size + \ offsetof(typeof(*entry), __str_data); \ __str_size += len;
And so on. You should be able to do something like this, and make it more generic.
-- Steve
Re: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 4 lines
Quoted 4 lines
Ah, it's pseudo code.. Should be
construct_str(__entry->cmd, rq), this helper function convertrq->cmd(unsigned char[]) to a string of hex dump.
Quoted 8 lines
Quoted 2 lines
No source string is available, so I'm not calling
assign_str()inTP_fast_assign.OK, I think I have a better understanding of what you are doing.
But, I don't like changing the interface for string by adding that "strlen" to all users. I find that very ugly.
Yeah, it does look somewhat ugly..
Quoted 3 lines
Could we instead perhaps add a
__dynamic_array? That would take a length, and append itself to after the strings?
I thought about this actually. ;)
What troubled me is to give this new macro a better name.
We have __array() which is fixed-size, but __dynamic_array() is not a dynamic-size version of __array(). How about __dyn_string() or __dynamic_string()?
Quoted 13 lines
stage 1:
#define
__dynamic_array(item, len)int __dyn_loc_##item;stage 2:
#define
__dynamic_array(item, len)int item;stage 3:
#define __get_dynamic_array(item) \ ((void *)__entry + __entry->__str_loc_##field
Quoted 7 lines
stage 4:
#define __dynamic_array(item, len) \ __str_offsets.item = __str_size + \ offsetof(typeof(*entry), __str_data); \ __str_size += len;
Then we can make __string() reuse __dynamic_array().
Quoted 4 lines
And so on. You should be able to do something like this, and make it more generic.
Steven Rostedt
maintainerRe: [PATCH v2 1/2] tracing/events: make __string() more general
Quoted 6 lines · Li Zefan
Yeah, it does look somewhat ugly..
Quoted 3 lines
Could we instead perhaps add a
__dynamic_array? That would take a length, and append itself to after the strings?
Quoted 7 lines
I thought about this actually. ;)
What troubled me is to give this new macro a better name.
We have
__array()which is fixed-size, but__dynamic_array()is not a dynamic-size version of__array(). How about__dyn_string()or__dynamic_string()?
String in many languages are non fixed size. But why not call it a dynamic array. We can make it into a varible length array. But the assignment may need to be careful.
Quoted 16 lines
Quoted 16 lines
stage 1:
#define
__dynamic_array(item, len)int __dyn_loc_##item;stage 2:
#define
__dynamic_array(item, len)int item;stage 3:
#define __get_dynamic_array(item) \ ((void *)__entry + __entry->__str_loc_##fieldstage 4:
Quoted 7 lines
Quoted 5 lines
#define __dynamic_array(item, len) \ __str_offsets.item = __str_size + \ offsetof(typeof(*entry), __str_data); \ __str_size += len;Then we can make
__string()reuse__dynamic_array().
Yeah, the __string() can end up being a wrapper around a __dynamic_array macro that just adds the strlen().
-- Steve
Re: [PATCH v2 1/2] tracing/events: make __string() more general
In reply to Li ZefanQuoted 2 lines · Li Zefan
Seems Christoph also runs into this problem while doing his XFS tracing. (and NULL str ptr that I'm not suffering)
Yeah. What I'm doing is tracing the XFS directory code. For some reason unknown to mankind people decided not to store the 0 termination on disk because we have the string length in the dirent anyway. So beeing able to specify the length is important to me, aswell as dealing with NULL strings because there are some directory operations that are internal and don't deal with any entry and thus don't have a name associated with them.
Quoted 5 lines
Quoted 3 lines
This is why I like the Impact line really be a "rational" line.
"TRACE_EVENTapi change" is meaningless to me.So what should this impact be. :(
Another reason for just dropping the impact Lines. I had hope people would just stop adding it after the last flamewar^H^H^H^H^H^H^Hdiscussion.
PATCH v2 2/2 tracing/events: convert block trace points to TRACE_EVENT()
In reply to Li ZefanTRACE_EVENT is a more generic way to define tracepoints. Doing so adds these new capabilities to this tracepoint:
- zero-copy and per-cpu splice() tracing
- binary tracing without printf overhead
- structured logging records exposed under /debug/tracing/events
- trace events embedded in function tracer output and other plugins
- user-defined, per tracepoint filter expressions
...
Cons:
- no dev_t info for the output of plug, unplug_timer and unplug_io events. no dev_t info for getrq and sleeprq events if bio == NULL. no dev_t info for rq_abort,...,rq_requeue events if rq->rq_disk == NULL.
This is mainly because we can't get the deivce from a request queue. But this may change in the future.
- A packet command is converted to a string in TP_assign, not TP_print. While blktrace do the convertion just before output.
Since pc requests should be rather rare, this seems not a big issue.
- In blktrace, an event can have 2 different print formats, but a TRACE_EVENT has a unique format, which means we have some unused data in a trace entry.
This is minimized by using __string() instead of __array().
Following are some comparisons between TRACE_EVENT and blktrace:
plug:
kjournald-480 [000] 303.084981: block_plug: [kjournald] kjournald-480 [000] 303.084981: 8,0 P N [kjournald]
unplug_io:
kblockd/0-118 [000] 300.052973: block_unplug_io: [kblockd/0] 1 kblockd/0-118 [000] 300.052974: 8,0 U N [kblockd/0] 1
remap:
kjournald-480 [000] 303.085042: block_remap: 8,0 W 102736992 + 8 <- (8,8) 33384 kjournald-480 [000] 303.085043: 8,0 A W 102736992 + 8 <- (8,8) 33384
bio_backmerge:
kjournald-480 [000] 303.085086: block_bio_backmerge: 8,0 W 102737032 + 8 [kjournald] kjournald-480 [000] 303.085086: 8,0 M W 102737032 + 8 [kjournald]
getrq:
kjournald-480 [000] 303.084974: block_getrq: 8,0 W 102736984 + 8 [kjournald] kjournald-480 [000] 303.084975: 8,0 G W 102736984 + 8 [kjournald]
bash-2066 [001] 1072.953770: 8,0 G N [bash] bash-2066 [001] 1072.953773: block_getrq: 0,0 N 0 + 0 [bash]
rq_complete:
konsole-2065 [001] 300.053184: block_rq_complete: 8,0 W () 103669040 + 16 [0] konsole-2065 [001] 300.053191: 8,0 C W 103669040 + 16 [0]
ksoftirqd/1-7 [001] 1072.953811: 8,0 C N (5a 00 08 00 00 00 00 00 24 00) [0] ksoftirqd/1-7 [001] 1072.953813: block_rq_complete: 0,0 N (5a 00 08 00 00 00 00 00 24 00) 0 + 0 [0]
rq_insert:
kjournald-480 [000] 303.084985: block_rq_insert: 8,0 W 0 () 102736984 + 8 [kjournald] kjournald-480 [000] 303.084986: 8,0 I W 102736984 + 8 [kjournald]
Changelog from v1:
- use __string() instead of __array() to minimize the memory required to store hex dump of rq->cmd().
- support large pc requests.
- add missing blk_fill_rwbs_rq() in block_rq_requeue TRACE_EVENT.
- some cleanups.
--- block/blk-core.c | 16 +- block/elevator.c | 8 +- drivers/md/dm.c | 5 +- fs/bio.c | 3 +- include/linux/blktrace_api.h | 13 ++ include/trace/block.h | 76 ------- include/trace/events/block.h | 483 ++++++++++++++++++++++++++++++++++++++++++ kernel/trace/Makefile | 5 +- kernel/trace/blktrace.c | 78 +++++++- mm/bounce.c | 5 +- 10 files changed, 588 insertions(+), 104 deletions(-) delete mode 100644 include/trace/block.h create mode 100644 include/trace/events/block.h
block/blk-core.c +4 -12
@@ -28,22 +28,14 @@#include <linux/task_io_accounting_ops.h> #include <linux/blktrace_api.h> #include <linux/fault-inject.h> -#include <trace/block.h> + +#define CREATE_TRACE_POINTS +#include <trace/events/block.h> #include "blk.h" -DEFINE_TRACE (block_plug); -DEFINE_TRACE (block_unplug_io); -DEFINE_TRACE (block_unplug_timer); -DEFINE_TRACE (block_getrq); -DEFINE_TRACE (block_sleeprq); -DEFINE_TRACE (block_rq_requeue); -DEFINE_TRACE (block_bio_backmerge); -DEFINE_TRACE (block_bio_frontmerge); -DEFINE_TRACE (block_bio_queue); -DEFINE_TRACE (block_rq_complete); -DEFINE_TRACE (block_remap);/* Also used in drivers/md/dm.c */ EXPORT_TRACEPOINT_SYMBOL_GPL (block_remap); +EXPORT_TRACEPOINT_SYMBOL_GPL (block_bio_complete);static int __make_request (struct request_queue *q,struct bio *bio);
block/elevator.c +2 -6
@@ -33,17 +33,16 @@#include <linux/compiler.h> #include <linux/delay.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <linux/hash.h> #include <linux/uaccess.h> +#include <trace/events/block.h> +#include "blk.h" static DEFINE_SPINLOCK (elv_list_lock);static LIST_HEAD (elv_list); -DEFINE_TRACE (block_rq_abort); -/* * Merge hash stuff. */
@@ -55,9 +54,6 @@ static const int elv_hash_shift = 6;#define rq_hash_key (rq) ((rq)->sector + (rq)->nr_sectors)#define ELV_ON_HASH (rq) (!hlist_unhashed(&(rq)->hash)) -DEFINE_TRACE (block_rq_insert); -DEFINE_TRACE (block_rq_issue); -/* * Query io scheduler to see if the current process issuing bio may be * merged with rq.
drivers/md/dm.c +2 -3
@@ -20,7 +20,8 @@#include <linux/idr.h> #include <linux/hdreg.h> #include <linux/blktrace_api.h> -#include <trace/block.h> + +#include <trace/events/block.h> #define DM_MSG_PREFIX "core"
@@ -53,8 +54,6 @@ struct dm_target_io {union map_info info; }; -DEFINE_TRACE (block_bio_complete); -/* * For request-based dm. * One of these is allocated per request.
fs/bio.c +1 -2
@@ -26,10 +26,9 @@#include <linux/mempool.h> #include <linux/workqueue.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <scsi/sg.h> /* for struct sg_iovec */ -DEFINE_TRACE (block_split); +#include <trace/events/block.h> /* * Test patch to inline a certain number of bi_io_vec's inside the bio
include/linux/blktrace_api.h +13 -0
@@ -218,5 +218,18 @@ static inline int blk_trace_init_sysfs(struct device *dev)#endif /* CONFIG_BLK_DEV_IO_TRACE */ +#ifdef CONFIG_EVENT_TRACING + +static inline int blk_cmd_buf_len (struct request *rq) +{ +return blk_pc_request (rq) ? rq->cmd_len :1 ; +} + +extern void blk_dump_cmd (char *buf,struct request *rq); +extern void blk_fill_rwbs (char *rwbs,u32 rw,int bytes); +extern void blk_fill_rwbs_rq (char *rwbs,struct request *rq); + +#endif /* CONFIG_EVENT_TRACING */ +#endif /* __KERNEL__ */ #endif
include/trace/block.h deleted +0 -76
76 lines not on this page · raw message
include/trace/events/block.h new file +483 -0
483 lines not on this page · raw message
kernel/trace/Makefile +4 -1
@@ -45,7 +45,10 @@ obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o obj-$(CONFIG_POWER_TRACER) += trace_power.o obj-$(CONFIG_KMEMTRACE) += kmemtrace.o obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o -obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o +obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o +ifeq ($(CONFIG_BLOCK),y) +obj-$(CONFIG_EVENT_TRACING) += blktrace.o +endif obj-$(CONFIG_EVENT_TRACING) += trace_events.o obj-$(CONFIG_EVENT_TRACING) += trace_export.o obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
kernel/trace/blktrace.c +77 -1
90 lines not on this page · raw message
mm/bounce.c +2 -3
@@ -14,16 +14,15 @@#include <linux/hash.h> #include <linux/highmem.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <asm/tlbflush.h> +#include <trace/events/block.h> +#define POOL_SIZE 64#define ISA_POOL_SIZE 16static mempool_t *page_pool, *isa_page_pool; -DEFINE_TRACE (block_bio_bounce); -#ifdef CONFIG_HIGHMEM static __init int init_emergency_pool (void ) {
Signature · 1 line
1.5.4.rc3
PATCH v3 1/1 tracing/events: convert block trace points to TRACE_EVENT()
In reply to Li ZefanTRACE_EVENT is a more generic way to define tracepoints. Doing so adds these new capabilities to this tracepoint:
- zero-copy and per-cpu splice() tracing
- binary tracing without printf overhead
- structured logging records exposed under /debug/tracing/events
- trace events embedded in function tracer output and other plugins
- user-defined, per tracepoint filter expressions
...
Cons:
- no dev_t info for the output of plug, unplug_timer and unplug_io events. no dev_t info for getrq and sleeprq events if bio == NULL. no dev_t info for rq_abort,...,rq_requeue events if rq->rq_disk == NULL.
This is mainly because we can't get the deivce from a request queue. But this may change in the future.
- A packet command is converted to a string in TP_assign, not TP_print. While blktrace do the convertion just before output.
Since pc requests should be rather rare, this is not a big issue.
- In blktrace, an event can have 2 different print formats, but a TRACE_EVENT has a unique format, which means we have some unused data in a trace entry.
The overhead is minimized by using __dynamic_array() instead of __array().
I've benchmarked the ioctl blktrace vs the splice based TRACE_EVENT tracing:
dd dd + ioctl blktrace dd + TRACE_EVENT (splice) 1 7.36s, 42.7 MB/s 7.50s, 42.0 MB/s 7.41s, 42.5 MB/s 2 7.43s, 42.3 MB/s 7.48s, 42.1 MB/s 7.43s, 42.4 MB/s 3 7.38s, 42.6 MB/s 7.45s, 42.2 MB/s 7.41s, 42.5 MB/s
So the overhead of tracing is very small, and no regression when using those trace events vs blktrace.
And the binary output of TRACE_EVENT is much smaller than blktrace:
# ls -l -h -rw-r--r-- 1 root root 8.8M 06-09 13:24 sda.blktrace.0 -rw-r--r-- 1 root root 195K 06-09 13:24 sda.blktrace.1 -rw-r--r-- 1 root root 2.7M 06-09 13:25 trace_splice.out
Following are some comparisons between TRACE_EVENT and blktrace:
plug:
kjournald-480 [000] 303.084981: block_plug: [kjournald] kjournald-480 [000] 303.084981: 8,0 P N [kjournald]
unplug_io:
kblockd/0-118 [000] 300.052973: block_unplug_io: [kblockd/0] 1 kblockd/0-118 [000] 300.052974: 8,0 U N [kblockd/0] 1
remap:
kjournald-480 [000] 303.085042: block_remap: 8,0 W 102736992 + 8 <- (8,8) 33384 kjournald-480 [000] 303.085043: 8,0 A W 102736992 + 8 <- (8,8) 33384
bio_backmerge:
kjournald-480 [000] 303.085086: block_bio_backmerge: 8,0 W 102737032 + 8 [kjournald] kjournald-480 [000] 303.085086: 8,0 M W 102737032 + 8 [kjournald]
getrq:
kjournald-480 [000] 303.084974: block_getrq: 8,0 W 102736984 + 8 [kjournald] kjournald-480 [000] 303.084975: 8,0 G W 102736984 + 8 [kjournald]
bash-2066 [001] 1072.953770: 8,0 G N [bash] bash-2066 [001] 1072.953773: block_getrq: 0,0 N 0 + 0 [bash]
rq_complete:
konsole-2065 [001] 300.053184: block_rq_complete: 8,0 W () 103669040 + 16 [0] konsole-2065 [001] 300.053191: 8,0 C W 103669040 + 16 [0]
ksoftirqd/1-7 [001] 1072.953811: 8,0 C N (5a 00 08 00 00 00 00 00 24 00) [0] ksoftirqd/1-7 [001] 1072.953813: block_rq_complete: 0,0 N (5a 00 08 00 00 00 00 00 24 00) 0 + 0 [0]
rq_insert:
kjournald-480 [000] 303.084985: block_rq_insert: 8,0 W 0 () 102736984 + 8 [kjournald] kjournald-480 [000] 303.084986: 8,0 I W 102736984 + 8 [kjournald]
Changelog from v2 -> v3:
- use the newly introduced __dynamic_array().
Changelog from v1 -> v2:
- use __string() instead of __array() to minimize the memory required to store hex dump of rq->cmd().
- support large pc requests.
- add missing blk_fill_rwbs_rq() in block_rq_requeue TRACE_EVENT.
- some cleanups.
--- block/blk-core.c | 16 +- block/elevator.c | 8 +- drivers/md/dm.c | 5 +- fs/bio.c | 3 +- include/linux/blktrace_api.h | 13 ++ include/trace/block.h | 76 ------- include/trace/events/block.h | 483 ++++++++++++++++++++++++++++++++++++++++++ kernel/trace/Makefile | 5 +- kernel/trace/blktrace.c | 78 +++++++- mm/bounce.c | 5 +- 10 files changed, 588 insertions(+), 104 deletions(-) delete mode 100644 include/trace/block.h create mode 100644 include/trace/events/block.h
block/blk-core.c +4 -12
@@ -28,22 +28,14 @@#include <linux/task_io_accounting_ops.h> #include <linux/blktrace_api.h> #include <linux/fault-inject.h> -#include <trace/block.h> + +#define CREATE_TRACE_POINTS +#include <trace/events/block.h> #include "blk.h" -DEFINE_TRACE (block_plug); -DEFINE_TRACE (block_unplug_io); -DEFINE_TRACE (block_unplug_timer); -DEFINE_TRACE (block_getrq); -DEFINE_TRACE (block_sleeprq); -DEFINE_TRACE (block_rq_requeue); -DEFINE_TRACE (block_bio_backmerge); -DEFINE_TRACE (block_bio_frontmerge); -DEFINE_TRACE (block_bio_queue); -DEFINE_TRACE (block_rq_complete); -DEFINE_TRACE (block_remap);/* Also used in drivers/md/dm.c */ EXPORT_TRACEPOINT_SYMBOL_GPL (block_remap); +EXPORT_TRACEPOINT_SYMBOL_GPL (block_bio_complete);static int __make_request (struct request_queue *q,struct bio *bio);
block/elevator.c +2 -6
@@ -33,17 +33,16 @@#include <linux/compiler.h> #include <linux/delay.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <linux/hash.h> #include <linux/uaccess.h> +#include <trace/events/block.h> +#include "blk.h" static DEFINE_SPINLOCK (elv_list_lock);static LIST_HEAD (elv_list); -DEFINE_TRACE (block_rq_abort); -/* * Merge hash stuff. */
@@ -55,9 +54,6 @@ static const int elv_hash_shift = 6;#define rq_hash_key (rq) ((rq)->sector + (rq)->nr_sectors)#define ELV_ON_HASH (rq) (!hlist_unhashed(&(rq)->hash)) -DEFINE_TRACE (block_rq_insert); -DEFINE_TRACE (block_rq_issue); -/* * Query io scheduler to see if the current process issuing bio may be * merged with rq.
drivers/md/dm.c +2 -3
@@ -20,7 +20,8 @@#include <linux/idr.h> #include <linux/hdreg.h> #include <linux/blktrace_api.h> -#include <trace/block.h> + +#include <trace/events/block.h> #define DM_MSG_PREFIX "core"
@@ -53,8 +54,6 @@ struct dm_target_io {union map_info info; }; -DEFINE_TRACE (block_bio_complete); -/* * For request-based dm. * One of these is allocated per request.
fs/bio.c +1 -2
@@ -26,10 +26,9 @@#include <linux/mempool.h> #include <linux/workqueue.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <scsi/sg.h> /* for struct sg_iovec */ -DEFINE_TRACE (block_split); +#include <trace/events/block.h> /* * Test patch to inline a certain number of bi_io_vec's inside the bio
include/linux/blktrace_api.h +13 -0
@@ -218,5 +218,18 @@ static inline int blk_trace_init_sysfs(struct device *dev)#endif /* CONFIG_BLK_DEV_IO_TRACE */ +#ifdef CONFIG_EVENT_TRACING + +static inline int blk_cmd_buf_len (struct request *rq) +{ +return blk_pc_request (rq) ? rq->cmd_len *3 :1 ; +} + +extern void blk_dump_cmd (char *buf,struct request *rq); +extern void blk_fill_rwbs (char *rwbs,u32 rw,int bytes); +extern void blk_fill_rwbs_rq (char *rwbs,struct request *rq); + +#endif /* CONFIG_EVENT_TRACING */ +#endif /* __KERNEL__ */ #endif
include/trace/block.h deleted +0 -76
76 lines not on this page · raw message
include/trace/events/block.h new file +483 -0
483 lines not on this page · raw message
kernel/trace/Makefile +4 -1
@@ -45,7 +45,10 @@ obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o obj-$(CONFIG_POWER_TRACER) += trace_power.o obj-$(CONFIG_KMEMTRACE) += kmemtrace.o obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o -obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o +obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o +ifeq ($(CONFIG_BLOCK),y) +obj-$(CONFIG_EVENT_TRACING) += blktrace.o +endif obj-$(CONFIG_EVENT_TRACING) += trace_events.o obj-$(CONFIG_EVENT_TRACING) += trace_export.o obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
kernel/trace/blktrace.c +77 -1
90 lines not on this page · raw message
mm/bounce.c +2 -3
@@ -14,16 +14,15 @@#include <linux/hash.h> #include <linux/highmem.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <asm/tlbflush.h> +#include <trace/events/block.h> +#define POOL_SIZE 64#define ISA_POOL_SIZE 16static mempool_t *page_pool, *isa_page_pool; -DEFINE_TRACE (block_bio_bounce); -#ifdef CONFIG_HIGHMEM static __init int init_emergency_pool (void ) {
Signature · 1 line
1.5.4.rc3
Commit-ID: 55782138e47d9baf2f7d3a7af9e7cf42adf72c56 Gitweb: http://git.kernel.org/tip/55782138e47d9baf2f7d3a7af9e7cf42adf72c56 Author: Li Zefan <[email protected]> AuthorDate: Tue, 9 Jun 2009 13:43:05 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Tue, 9 Jun 2009 12:34:23 -0400
tracing/events: convert block trace points to TRACE_EVENT()
TRACE_EVENT is a more generic way to define tracepoints. Doing so adds these new capabilities to this tracepoint:
- zero-copy and per-cpu splice() tracing
- binary tracing without printf overhead
- structured logging records exposed under /debug/tracing/events
- trace events embedded in function tracer output and other plugins
- user-defined, per tracepoint filter expressions
...
Cons:
- no dev_t info for the output of plug, unplug_timer and unplug_io events. no dev_t info for getrq and sleeprq events if bio == NULL. no dev_t info for rq_abort,...,rq_requeue events if rq->rq_disk == NULL.
This is mainly because we can't get the deivce from a request queue. But this may change in the future.
- A packet command is converted to a string in TP_assign, not TP_print. While blktrace do the convertion just before output.
Since pc requests should be rather rare, this is not a big issue.
- In blktrace, an event can have 2 different print formats, but a TRACE_EVENT has a unique format, which means we have some unused data in a trace entry.
The overhead is minimized by using __dynamic_array() instead of __array().
I've benchmarked the ioctl blktrace vs the splice based TRACE_EVENT tracing:
dd dd + ioctl blktrace dd + TRACE_EVENT (splice) 1 7.36s, 42.7 MB/s 7.50s, 42.0 MB/s 7.41s, 42.5 MB/s 2 7.43s, 42.3 MB/s 7.48s, 42.1 MB/s 7.43s, 42.4 MB/s 3 7.38s, 42.6 MB/s 7.45s, 42.2 MB/s 7.41s, 42.5 MB/s
So the overhead of tracing is very small, and no regression when using those trace events vs blktrace.
And the binary output of TRACE_EVENT is much smaller than blktrace:
# ls -l -h -rw-r--r-- 1 root root 8.8M 06-09 13:24 sda.blktrace.0 -rw-r--r-- 1 root root 195K 06-09 13:24 sda.blktrace.1 -rw-r--r-- 1 root root 2.7M 06-09 13:25 trace_splice.out
Following are some comparisons between TRACE_EVENT and blktrace:
plug:
kjournald-480 [000] 303.084981: block_plug: [kjournald] kjournald-480 [000] 303.084981: 8,0 P N [kjournald]
unplug_io:
kblockd/0-118 [000] 300.052973: block_unplug_io: [kblockd/0] 1 kblockd/0-118 [000] 300.052974: 8,0 U N [kblockd/0] 1
remap:
kjournald-480 [000] 303.085042: block_remap: 8,0 W 102736992 + 8 <- (8,8) 33384 kjournald-480 [000] 303.085043: 8,0 A W 102736992 + 8 <- (8,8) 33384
bio_backmerge:
kjournald-480 [000] 303.085086: block_bio_backmerge: 8,0 W 102737032 + 8 [kjournald] kjournald-480 [000] 303.085086: 8,0 M W 102737032 + 8 [kjournald]
getrq:
kjournald-480 [000] 303.084974: block_getrq: 8,0 W 102736984 + 8 [kjournald] kjournald-480 [000] 303.084975: 8,0 G W 102736984 + 8 [kjournald]
bash-2066 [001] 1072.953770: 8,0 G N [bash] bash-2066 [001] 1072.953773: block_getrq: 0,0 N 0 + 0 [bash]
rq_complete:
konsole-2065 [001] 300.053184: block_rq_complete: 8,0 W () 103669040 + 16 [0] konsole-2065 [001] 300.053191: 8,0 C W 103669040 + 16 [0]
ksoftirqd/1-7 [001] 1072.953811: 8,0 C N (5a 00 08 00 00 00 00 00 24 00) [0] ksoftirqd/1-7 [001] 1072.953813: block_rq_complete: 0,0 N (5a 00 08 00 00 00 00 00 24 00) 0 + 0 [0]
rq_insert:
kjournald-480 [000] 303.084985: block_rq_insert: 8,0 W 0 () 102736984 + 8 [kjournald] kjournald-480 [000] 303.084986: 8,0 I W 102736984 + 8 [kjournald]
Changelog from v2 -> v3:
- use the newly introduced __dynamic_array().
Changelog from v1 -> v2:
- use __string() instead of __array() to minimize the memory required to store hex dump of rq->cmd().
- support large pc requests.
- add missing blk_fill_rwbs_rq() in block_rq_requeue TRACE_EVENT.
- some cleanups.
LKML-Reference: <[email protected]>
--- block/blk-core.c | 16 +- block/elevator.c | 8 +- drivers/md/dm.c | 5 +- fs/bio.c | 3 +- include/linux/blktrace_api.h | 13 ++ include/trace/block.h | 76 ------- include/trace/events/block.h | 483 ++++++++++++++++++++++++++++++++++++++++++ kernel/trace/Makefile | 5 +- kernel/trace/blktrace.c | 78 +++++++- mm/bounce.c | 5 +- 10 files changed, 588 insertions(+), 104 deletions(-)
block/blk-core.c +4 -12
@@ -28,22 +28,14 @@#include <linux/task_io_accounting_ops.h> #include <linux/blktrace_api.h> #include <linux/fault-inject.h> -#include <trace/block.h> + +#define CREATE_TRACE_POINTS +#include <trace/events/block.h> #include "blk.h" -DEFINE_TRACE (block_plug); -DEFINE_TRACE (block_unplug_io); -DEFINE_TRACE (block_unplug_timer); -DEFINE_TRACE (block_getrq); -DEFINE_TRACE (block_sleeprq); -DEFINE_TRACE (block_rq_requeue); -DEFINE_TRACE (block_bio_backmerge); -DEFINE_TRACE (block_bio_frontmerge); -DEFINE_TRACE (block_bio_queue); -DEFINE_TRACE (block_rq_complete); -DEFINE_TRACE (block_remap);/* Also used in drivers/md/dm.c */ EXPORT_TRACEPOINT_SYMBOL_GPL (block_remap); +EXPORT_TRACEPOINT_SYMBOL_GPL (block_bio_complete);static int __make_request (struct request_queue *q,struct bio *bio);
block/elevator.c +2 -6
@@ -33,17 +33,16 @@#include <linux/compiler.h> #include <linux/delay.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <linux/hash.h> #include <linux/uaccess.h> +#include <trace/events/block.h> +#include "blk.h" static DEFINE_SPINLOCK (elv_list_lock);static LIST_HEAD (elv_list); -DEFINE_TRACE (block_rq_abort); -/* * Merge hash stuff. */
@@ -55,9 +54,6 @@ static const int elv_hash_shift = 6;#define rq_hash_key (rq) ((rq)->sector + (rq)->nr_sectors)#define ELV_ON_HASH (rq) (!hlist_unhashed(&(rq)->hash)) -DEFINE_TRACE (block_rq_insert); -DEFINE_TRACE (block_rq_issue); -/* * Query io scheduler to see if the current process issuing bio may be * merged with rq.
drivers/md/dm.c +2 -3
@@ -20,7 +20,8 @@#include <linux/idr.h> #include <linux/hdreg.h> #include <linux/blktrace_api.h> -#include <trace/block.h> + +#include <trace/events/block.h> #define DM_MSG_PREFIX "core"
@@ -53,8 +54,6 @@ struct dm_target_io {union map_info info; }; -DEFINE_TRACE (block_bio_complete); -/* * For request-based dm. * One of these is allocated per request.
fs/bio.c +1 -2
@@ -26,10 +26,9 @@#include <linux/mempool.h> #include <linux/workqueue.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <scsi/sg.h> /* for struct sg_iovec */ -DEFINE_TRACE (block_split); +#include <trace/events/block.h> /* * Test patch to inline a certain number of bi_io_vec's inside the bio
include/linux/blktrace_api.h +13 -0
@@ -218,5 +218,18 @@ static inline int blk_trace_init_sysfs(struct device *dev)#endif /* CONFIG_BLK_DEV_IO_TRACE */ +#ifdef CONFIG_EVENT_TRACING + +static inline int blk_cmd_buf_len (struct request *rq) +{ +return blk_pc_request (rq) ? rq->cmd_len *3 :1 ; +} + +extern void blk_dump_cmd (char *buf,struct request *rq); +extern void blk_fill_rwbs (char *rwbs,u32 rw,int bytes); +extern void blk_fill_rwbs_rq (char *rwbs,struct request *rq); + +#endif /* CONFIG_EVENT_TRACING */ +#endif /* __KERNEL__ */ #endif
include/trace/block.h deleted +0 -76
76 lines not on this page · raw message
include/trace/events/block.h new file +483 -0
483 lines not on this page · raw message
kernel/trace/Makefile +4 -1
@@ -45,7 +45,10 @@ obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o obj-$(CONFIG_POWER_TRACER) += trace_power.o obj-$(CONFIG_KMEMTRACE) += kmemtrace.o obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o -obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o +obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o +ifeq ($(CONFIG_BLOCK),y) +obj-$(CONFIG_EVENT_TRACING) += blktrace.o +endif obj-$(CONFIG_EVENT_TRACING) += trace_events.o obj-$(CONFIG_EVENT_TRACING) += trace_export.o obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
kernel/trace/blktrace.c +77 -1
90 lines not on this page · raw message
mm/bounce.c +2 -3
@@ -14,16 +14,15 @@#include <linux/hash.h> #include <linux/highmem.h> #include <linux/blktrace_api.h> -#include <trace/block.h> #include <asm/tlbflush.h> +#include <trace/events/block.h> +#define POOL_SIZE 64#define ISA_POOL_SIZE 16static mempool_t *page_pool, *isa_page_pool; -DEFINE_TRACE (block_bio_bounce); -#ifdef CONFIG_HIGHMEM static __init int init_emergency_pool (void ) {