2006-03-24 03:00:26 +08:00
|
|
|
#ifndef BLKTRACE_H
|
|
|
|
#define BLKTRACE_H
|
|
|
|
|
2009-01-30 23:06:52 +08:00
|
|
|
#include <linux/types.h>
|
2008-09-26 16:58:02 +08:00
|
|
|
#ifdef __KERNEL__
|
2006-03-24 03:00:26 +08:00
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/relay.h>
|
2010-07-07 22:51:26 +08:00
|
|
|
#include <linux/compat.h>
|
2008-09-26 16:58:02 +08:00
|
|
|
#endif
|
2006-03-24 03:00:26 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Trace categories
|
|
|
|
*/
|
|
|
|
enum blktrace_cat {
|
|
|
|
BLK_TC_READ = 1 << 0, /* reads */
|
|
|
|
BLK_TC_WRITE = 1 << 1, /* writes */
|
|
|
|
BLK_TC_BARRIER = 1 << 2, /* barrier */
|
2006-07-06 15:56:30 +08:00
|
|
|
BLK_TC_SYNC = 1 << 3, /* sync IO */
|
2009-02-16 17:25:40 +08:00
|
|
|
BLK_TC_SYNCIO = BLK_TC_SYNC,
|
2006-03-24 03:00:26 +08:00
|
|
|
BLK_TC_QUEUE = 1 << 4, /* queueing/merging */
|
|
|
|
BLK_TC_REQUEUE = 1 << 5, /* requeueing */
|
|
|
|
BLK_TC_ISSUE = 1 << 6, /* issue */
|
|
|
|
BLK_TC_COMPLETE = 1 << 7, /* completions */
|
|
|
|
BLK_TC_FS = 1 << 8, /* fs requests */
|
|
|
|
BLK_TC_PC = 1 << 9, /* pc requests */
|
|
|
|
BLK_TC_NOTIFY = 1 << 10, /* special message */
|
2006-07-06 16:03:28 +08:00
|
|
|
BLK_TC_AHEAD = 1 << 11, /* readahead */
|
2006-07-23 08:12:01 +08:00
|
|
|
BLK_TC_META = 1 << 12, /* metadata */
|
2008-08-10 18:21:57 +08:00
|
|
|
BLK_TC_DISCARD = 1 << 13, /* discard requests */
|
2008-10-16 14:23:21 +08:00
|
|
|
BLK_TC_DRV_DATA = 1 << 14, /* binary per-driver data */
|
2006-03-24 03:00:26 +08:00
|
|
|
|
|
|
|
BLK_TC_END = 1 << 15, /* only 16-bits, reminder */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BLK_TC_SHIFT (16)
|
|
|
|
#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Basic trace actions
|
|
|
|
*/
|
|
|
|
enum blktrace_act {
|
|
|
|
__BLK_TA_QUEUE = 1, /* queued */
|
|
|
|
__BLK_TA_BACKMERGE, /* back merged to existing rq */
|
|
|
|
__BLK_TA_FRONTMERGE, /* front merge to existing rq */
|
|
|
|
__BLK_TA_GETRQ, /* allocated new request */
|
|
|
|
__BLK_TA_SLEEPRQ, /* sleeping on rq allocation */
|
|
|
|
__BLK_TA_REQUEUE, /* request requeued */
|
|
|
|
__BLK_TA_ISSUE, /* sent to driver */
|
|
|
|
__BLK_TA_COMPLETE, /* completed by driver */
|
|
|
|
__BLK_TA_PLUG, /* queue was plugged */
|
|
|
|
__BLK_TA_UNPLUG_IO, /* queue was unplugged by io */
|
|
|
|
__BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */
|
|
|
|
__BLK_TA_INSERT, /* insert request */
|
|
|
|
__BLK_TA_SPLIT, /* bio was split */
|
|
|
|
__BLK_TA_BOUNCE, /* bio was bounced */
|
|
|
|
__BLK_TA_REMAP, /* bio was remapped */
|
2008-09-14 02:31:27 +08:00
|
|
|
__BLK_TA_ABORT, /* request aborted */
|
2008-10-16 14:23:21 +08:00
|
|
|
__BLK_TA_DRV_DATA, /* driver-specific binary data */
|
2006-03-24 03:00:26 +08:00
|
|
|
};
|
|
|
|
|
2006-12-01 17:39:12 +08:00
|
|
|
/*
|
|
|
|
* Notify events.
|
|
|
|
*/
|
|
|
|
enum blktrace_notify {
|
|
|
|
__BLK_TN_PROCESS = 0, /* establish pid/name mapping */
|
|
|
|
__BLK_TN_TIMESTAMP, /* include system clock */
|
2008-05-27 20:54:41 +08:00
|
|
|
__BLK_TN_MESSAGE, /* Character string message */
|
2006-12-01 17:39:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-03-24 03:00:26 +08:00
|
|
|
/*
|
|
|
|
* Trace actions in full. Additionally, read or write is masked
|
|
|
|
*/
|
|
|
|
#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE))
|
|
|
|
#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE))
|
|
|
|
#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE))
|
|
|
|
#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE))
|
|
|
|
#define BLK_TA_SPLIT (__BLK_TA_SPLIT)
|
|
|
|
#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
|
|
|
|
#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
|
2008-09-14 02:31:27 +08:00
|
|
|
#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
|
2008-10-16 14:23:21 +08:00
|
|
|
#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
|
2006-03-24 03:00:26 +08:00
|
|
|
|
2006-12-01 17:39:12 +08:00
|
|
|
#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
|
|
|
|
#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
|
2008-05-27 20:54:41 +08:00
|
|
|
#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
|
2006-12-01 17:39:12 +08:00
|
|
|
|
2006-03-24 03:00:26 +08:00
|
|
|
#define BLK_IO_TRACE_MAGIC 0x65617400
|
|
|
|
#define BLK_IO_TRACE_VERSION 0x07
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The trace itself
|
|
|
|
*/
|
|
|
|
struct blk_io_trace {
|
2008-09-26 16:58:02 +08:00
|
|
|
__u32 magic; /* MAGIC << 8 | version */
|
|
|
|
__u32 sequence; /* event number */
|
|
|
|
__u64 time; /* in microseconds */
|
|
|
|
__u64 sector; /* disk offset */
|
|
|
|
__u32 bytes; /* transfer length */
|
|
|
|
__u32 action; /* what happened */
|
|
|
|
__u32 pid; /* who did it */
|
|
|
|
__u32 device; /* device number */
|
|
|
|
__u32 cpu; /* on what cpu did it happen */
|
|
|
|
__u16 error; /* completion error */
|
|
|
|
__u16 pdu_len; /* length of data after this trace */
|
2006-03-24 03:00:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The remap event
|
|
|
|
*/
|
|
|
|
struct blk_io_trace_remap {
|
2007-08-07 21:30:23 +08:00
|
|
|
__be32 device_from;
|
2009-05-05 04:27:26 +08:00
|
|
|
__be32 device_to;
|
|
|
|
__be64 sector_from;
|
2006-03-24 03:00:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Blktrace_setup = 1,
|
|
|
|
Blktrace_running,
|
|
|
|
Blktrace_stopped,
|
|
|
|
};
|
|
|
|
|
2008-10-01 22:16:25 +08:00
|
|
|
#define BLKTRACE_BDEV_SIZE 32
|
|
|
|
|
2008-09-26 16:58:02 +08:00
|
|
|
/*
|
|
|
|
* User setup structure passed with BLKTRACESTART
|
|
|
|
*/
|
|
|
|
struct blk_user_trace_setup {
|
2008-10-01 22:16:25 +08:00
|
|
|
char name[BLKTRACE_BDEV_SIZE]; /* output */
|
2008-09-26 16:58:02 +08:00
|
|
|
__u16 act_mask; /* input */
|
|
|
|
__u32 buf_size; /* input */
|
|
|
|
__u32 buf_nr; /* input */
|
|
|
|
__u64 start_lba;
|
|
|
|
__u64 end_lba;
|
|
|
|
__u32 pid;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#if defined(CONFIG_BLK_DEV_IO_TRACE)
|
2009-01-27 01:00:56 +08:00
|
|
|
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
|
2006-03-24 03:00:26 +08:00
|
|
|
struct blk_trace {
|
|
|
|
int trace_state;
|
|
|
|
struct rchan *rchan;
|
2010-02-02 13:38:57 +08:00
|
|
|
unsigned long __percpu *sequence;
|
|
|
|
unsigned char __percpu *msg_data;
|
2006-03-24 03:00:26 +08:00
|
|
|
u16 act_mask;
|
|
|
|
u64 start_lba;
|
|
|
|
u64 end_lba;
|
|
|
|
u32 pid;
|
|
|
|
u32 dev;
|
|
|
|
struct dentry *dir;
|
|
|
|
struct dentry *dropped_file;
|
2008-06-11 15:12:52 +08:00
|
|
|
struct dentry *msg_file;
|
2006-03-24 03:00:26 +08:00
|
|
|
atomic_t dropped;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
|
2007-07-24 15:28:11 +08:00
|
|
|
extern void blk_trace_shutdown(struct request_queue *);
|
2009-04-14 13:58:56 +08:00
|
|
|
extern int do_blk_trace_setup(struct request_queue *q, char *name,
|
|
|
|
dev_t dev, struct block_device *bdev,
|
|
|
|
struct blk_user_trace_setup *buts);
|
2008-05-27 20:54:41 +08:00
|
|
|
extern void __trace_note_message(struct blk_trace *, const char *fmt, ...);
|
2007-10-09 19:23:53 +08:00
|
|
|
|
2008-05-27 20:54:41 +08:00
|
|
|
/**
|
|
|
|
* blk_add_trace_msg - Add a (simple) message to the blktrace stream
|
|
|
|
* @q: queue the io is for
|
|
|
|
* @fmt: format to print message in
|
|
|
|
* args... Variable argument list for format
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Records a (simple) message onto the blktrace stream.
|
|
|
|
*
|
|
|
|
* NOTE: BLK_TN_MAX_MSG characters are output at most.
|
|
|
|
* NOTE: Can not use 'static inline' due to presence of var args...
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
#define blk_add_trace_msg(q, fmt, ...) \
|
|
|
|
do { \
|
|
|
|
struct blk_trace *bt = (q)->blk_trace; \
|
|
|
|
if (unlikely(bt)) \
|
|
|
|
__trace_note_message(bt, fmt, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|
2008-05-28 20:45:33 +08:00
|
|
|
#define BLK_TN_MAX_MSG 128
|
2006-03-24 03:00:26 +08:00
|
|
|
|
2008-10-30 15:34:33 +08:00
|
|
|
extern void blk_add_driver_data(struct request_queue *q, struct request *rq,
|
|
|
|
void *data, size_t len);
|
2008-01-30 02:12:06 +08:00
|
|
|
extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
|
2009-04-14 13:58:56 +08:00
|
|
|
struct block_device *bdev,
|
2008-01-11 17:09:43 +08:00
|
|
|
char __user *arg);
|
2008-01-30 02:12:06 +08:00
|
|
|
extern int blk_trace_startstop(struct request_queue *q, int start);
|
|
|
|
extern int blk_trace_remove(struct request_queue *q);
|
2009-09-25 12:19:26 +08:00
|
|
|
extern void blk_trace_remove_sysfs(struct device *dev);
|
2009-04-14 14:00:05 +08:00
|
|
|
extern int blk_trace_init_sysfs(struct device *dev);
|
2008-01-11 17:09:43 +08:00
|
|
|
|
2009-01-27 01:00:56 +08:00
|
|
|
extern struct attribute_group blk_trace_attr_group;
|
|
|
|
|
2006-03-24 03:00:26 +08:00
|
|
|
#else /* !CONFIG_BLK_DEV_IO_TRACE */
|
2009-04-14 13:58:56 +08:00
|
|
|
# define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY)
|
|
|
|
# define blk_trace_shutdown(q) do { } while (0)
|
|
|
|
# define do_blk_trace_setup(q, name, dev, bdev, buts) (-ENOTTY)
|
|
|
|
# define blk_add_driver_data(q, rq, data, len) do {} while (0)
|
|
|
|
# define blk_trace_setup(q, name, dev, bdev, arg) (-ENOTTY)
|
|
|
|
# define blk_trace_startstop(q, start) (-ENOTTY)
|
|
|
|
# define blk_trace_remove(q) (-ENOTTY)
|
|
|
|
# define blk_add_trace_msg(q, fmt, ...) do { } while (0)
|
2009-10-02 03:16:13 +08:00
|
|
|
# define blk_trace_remove_sysfs(dev) do { } while (0)
|
2009-04-14 14:00:05 +08:00
|
|
|
static inline int blk_trace_init_sysfs(struct device *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-24 03:00:26 +08:00
|
|
|
#endif /* CONFIG_BLK_DEV_IO_TRACE */
|
2009-04-14 13:58:56 +08:00
|
|
|
|
2010-07-09 12:24:38 +08:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
|
|
|
|
struct compat_blk_user_trace_setup {
|
|
|
|
char name[32];
|
|
|
|
u16 act_mask;
|
|
|
|
u32 buf_size;
|
|
|
|
u32 buf_nr;
|
|
|
|
compat_u64 start_lba;
|
|
|
|
compat_u64 end_lba;
|
|
|
|
u32 pid;
|
|
|
|
};
|
|
|
|
#define BLKTRACESETUP32 _IOWR(0x12, 115, struct compat_blk_user_trace_setup)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-06-10 10:06:24 +08:00
|
|
|
#if defined(CONFIG_EVENT_TRACING) && defined(CONFIG_BLOCK)
|
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.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A2DF669.5070905@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2009-06-09 13:43:05 +08:00
|
|
|
|
|
|
|
static inline int blk_cmd_buf_len(struct request *rq)
|
|
|
|
{
|
2010-08-08 00:17:56 +08:00
|
|
|
return (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? rq->cmd_len * 3 : 1;
|
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.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A2DF669.5070905@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2009-06-09 13:43:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2009-06-10 10:06:24 +08:00
|
|
|
#endif /* CONFIG_EVENT_TRACING && CONFIG_BLOCK */
|
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.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A2DF669.5070905@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2009-06-09 13:43:05 +08:00
|
|
|
|
2007-10-09 19:23:53 +08:00
|
|
|
#endif /* __KERNEL__ */
|
2006-03-24 03:00:26 +08:00
|
|
|
#endif
|