From 01696d4df8bf2d0cdb06b67d819f91db2cd443be Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 7 Jun 2013 14:39:41 -0400 Subject: [PATCH] Backport block-related changes from "Update kernel probes to more detailed match to kernel versions" This commit: commit 7c68b363332170e4db100327ecc9e09b8a79cf29 Author: Andrew Gabbasov Date: Mon Dec 10 11:12:14 2012 -0500 Update kernel probes to more detailed match to kernel versions Some ifdef's are added to kernel probes instrumentation to make them more close to original tracepoints in different kernel versions. Supported kernel version are from 2.6.32 to 3.7. Signed-off-by: Andrew Gabbasov Signed-off-by: Mathieu Desnoyers Contains block-layer related changes needed to push compatibility fixes for newer kernels. Signed-off-by: Mathieu Desnoyers --- instrumentation/events/lttng-module/block.h | 110 +++++++++++++++++++- instrumentation/events/mainline/block.h | 20 ++-- probes/lttng-probe-block.c | 2 + 3 files changed, 120 insertions(+), 12 deletions(-) diff --git a/instrumentation/events/lttng-module/block.h b/instrumentation/events/lttng-module/block.h index 42184f3d..d42ebd4e 100644 --- a/instrumentation/events/lttng-module/block.h +++ b/instrumentation/events/lttng-module/block.h @@ -8,6 +8,9 @@ #include #include #include +#include + +#define RWBS_LEN 8 #ifndef _TRACE_BLOCK_DEF_ #define _TRACE_BLOCK_DEF_ @@ -19,23 +22,45 @@ enum { RWBS_FLAG_DISCARD = (1 << 1), RWBS_FLAG_READ = (1 << 2), RWBS_FLAG_RAHEAD = (1 << 3), - RWBS_FLAG_SYNC = (1 << 4), - RWBS_FLAG_META = (1 << 5), - RWBS_FLAG_SECURE = (1 << 6), + RWBS_FLAG_BARRIER = (1 << 4), + RWBS_FLAG_SYNC = (1 << 5), + RWBS_FLAG_META = (1 << 6), + RWBS_FLAG_SECURE = (1 << 7), + RWBS_FLAG_FLUSH = (1 << 8), + RWBS_FLAG_FUA = (1 << 9), }; #endif /* _TRACE_BLOCK_DEF_ */ #define __print_rwbs_flags(rwbs) \ __print_flags(rwbs, "", \ + { RWBS_FLAG_FLUSH, "F" }, \ { RWBS_FLAG_WRITE, "W" }, \ { RWBS_FLAG_DISCARD, "D" }, \ { RWBS_FLAG_READ, "R" }, \ + { RWBS_FLAG_FUA, "F" }, \ { RWBS_FLAG_RAHEAD, "A" }, \ + { RWBS_FLAG_BARRIER, "B" }, \ { RWBS_FLAG_SYNC, "S" }, \ { RWBS_FLAG_META, "M" }, \ { RWBS_FLAG_SECURE, "E" }) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) + +#define blk_fill_rwbs(rwbs, rw, bytes) \ + tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ + ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ + ( (bytes) ? RWBS_FLAG_READ : \ + ( 0 )))) \ + | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \ + | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \ + | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ + | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0) \ + | ((rw) & REQ_FLUSH ? RWBS_FLAG_FLUSH : 0) \ + | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0)) + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + #define blk_fill_rwbs(rwbs, rw, bytes) \ tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ @@ -46,6 +71,33 @@ enum { | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0)) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) + +#define blk_fill_rwbs(rwbs, rw, bytes) \ + tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ + ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ + ( (bytes) ? RWBS_FLAG_READ : \ + ( 0 )))) \ + | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \ + | ((rw) & REQ_HARDBARRIER ? RWBS_FLAG_BARRIER : 0) \ + | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \ + | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ + | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0)) + +#else + +#define blk_fill_rwbs(rwbs, rw, bytes) \ + tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ + ( (rw) & (1 << BIO_RW_DISCARD) ? RWBS_FLAG_DISCARD : \ + ( (bytes) ? RWBS_FLAG_READ : \ + ( 0 )))) \ + | ((rw) & (1 << BIO_RW_AHEAD) ? RWBS_FLAG_RAHEAD : 0) \ + | ((rw) & (1 << BIO_RW_SYNCIO) ? RWBS_FLAG_SYNC : 0) \ + | ((rw) & (1 << BIO_RW_META) ? RWBS_FLAG_META : 0) \ + | ((rw) & (1 << BIO_RW_BARRIER) ? RWBS_FLAG_BARRIER : 0)) + +#endif + DECLARE_EVENT_CLASS(block_rq_with_error, TP_PROTO(struct request_queue *q, struct request *rq), @@ -261,9 +313,15 @@ TRACE_EVENT(block_bio_bounce, */ TRACE_EVENT(block_bio_complete, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) TP_PROTO(struct request_queue *q, struct bio *bio, int error), TP_ARGS(q, bio, error), +#else + TP_PROTO(struct request_queue *q, struct bio *bio), + + TP_ARGS(q, bio), +#endif TP_STRUCT__entry( __field( dev_t, dev ) @@ -277,7 +335,11 @@ TRACE_EVENT(block_bio_complete, tp_assign(dev, bio->bi_bdev->bd_dev) tp_assign(sector, bio->bi_sector) tp_assign(nr_sector, bio->bi_size >> 9) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) tp_assign(error, error) +#else + tp_assign(error, 0) +#endif blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size) ), @@ -452,9 +514,15 @@ TRACE_EVENT(block_plug, DECLARE_EVENT_CLASS(block_unplug, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), TP_ARGS(q, depth, explicit), +#else + TP_PROTO(struct request_queue *q), + + TP_ARGS(q), +#endif TP_STRUCT__entry( __field( int, nr_rq ) @@ -462,13 +530,33 @@ DECLARE_EVENT_CLASS(block_unplug, ), TP_fast_assign( +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) tp_assign(nr_rq, depth) +#else + tp_assign(nr_rq, q->rq.count[READ] + q->rq.count[WRITE]) +#endif tp_memcpy(comm, current->comm, TASK_COMM_LEN) ), TP_printk("[%s] %d", __entry->comm, __entry->nr_rq) ) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) +/** + * block_unplug_timer - timed release of operations requests in queue to device driver + * @q: request queue to unplug + * + * Unplug the request queue @q because a timer expired and allow block + * operation requests to be sent to the device driver. + */ +DEFINE_EVENT(block_unplug, block_unplug_timer, + + TP_PROTO(struct request_queue *q), + + TP_ARGS(q) +) +#endif + /** * block_unplug - release of operations requests in request queue * @q: request queue to unplug @@ -478,11 +566,21 @@ DECLARE_EVENT_CLASS(block_unplug, * Unplug request queue @q because device driver is scheduled to work * on elements in the request queue. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) DEFINE_EVENT(block_unplug, block_unplug, +#else +DEFINE_EVENT(block_unplug, block_unplug_io, +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), TP_ARGS(q, depth, explicit) +#else + TP_PROTO(struct request_queue *q), + + TP_ARGS(q) +#endif ) /** @@ -537,7 +635,11 @@ TRACE_EVENT(block_split, * An operation for a logical device has been mapped to the * raw block device. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) TRACE_EVENT(block_bio_remap, +#else +TRACE_EVENT(block_remap, +#endif TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev, sector_t from), @@ -571,6 +673,7 @@ TRACE_EVENT(block_bio_remap, (unsigned long long)__entry->old_sector) ) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) /** * block_rq_remap - map request for a block operation request * @q: queue holding the operation @@ -615,6 +718,7 @@ TRACE_EVENT(block_rq_remap, MAJOR(__entry->old_dev), MINOR(__entry->old_dev), (unsigned long long)__entry->old_sector) ) +#endif #undef __print_rwbs_flags #undef blk_fill_rwbs diff --git a/instrumentation/events/mainline/block.h b/instrumentation/events/mainline/block.h index bf366547..05c5e61f 100644 --- a/instrumentation/events/mainline/block.h +++ b/instrumentation/events/mainline/block.h @@ -8,6 +8,8 @@ #include #include +#define RWBS_LEN 8 + DECLARE_EVENT_CLASS(block_rq_with_error, TP_PROTO(struct request_queue *q, struct request *rq), @@ -19,7 +21,7 @@ DECLARE_EVENT_CLASS(block_rq_with_error, __field( sector_t, sector ) __field( unsigned int, nr_sector ) __field( int, errors ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN ) __dynamic_array( char, cmd, blk_cmd_buf_len(rq) ) ), @@ -104,7 +106,7 @@ DECLARE_EVENT_CLASS(block_rq, __field( sector_t, sector ) __field( unsigned int, nr_sector ) __field( unsigned int, bytes ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN ) __array( char, comm, TASK_COMM_LEN ) __dynamic_array( char, cmd, blk_cmd_buf_len(rq) ) ), @@ -183,7 +185,7 @@ TRACE_EVENT(block_bio_bounce, __field( dev_t, dev ) __field( sector_t, sector ) __field( unsigned int, nr_sector ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN ) __array( char, comm, TASK_COMM_LEN ) ), @@ -222,7 +224,7 @@ TRACE_EVENT(block_bio_complete, __field( sector_t, sector ) __field( unsigned, nr_sector ) __field( int, error ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN) ), TP_fast_assign( @@ -249,7 +251,7 @@ DECLARE_EVENT_CLASS(block_bio, __field( dev_t, dev ) __field( sector_t, sector ) __field( unsigned int, nr_sector ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN ) __array( char, comm, TASK_COMM_LEN ) ), @@ -321,7 +323,7 @@ DECLARE_EVENT_CLASS(block_get_rq, __field( dev_t, dev ) __field( sector_t, sector ) __field( unsigned int, nr_sector ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN ) __array( char, comm, TASK_COMM_LEN ) ), @@ -456,7 +458,7 @@ TRACE_EVENT(block_split, __field( dev_t, dev ) __field( sector_t, sector ) __field( sector_t, new_sector ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN ) __array( char, comm, TASK_COMM_LEN ) ), @@ -498,7 +500,7 @@ TRACE_EVENT(block_bio_remap, __field( unsigned int, nr_sector ) __field( dev_t, old_dev ) __field( sector_t, old_sector ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN) ), TP_fast_assign( @@ -542,7 +544,7 @@ TRACE_EVENT(block_rq_remap, __field( unsigned int, nr_sector ) __field( dev_t, old_dev ) __field( sector_t, old_sector ) - __array( char, rwbs, 6 ) + __array( char, rwbs, RWBS_LEN) ), TP_fast_assign( diff --git a/probes/lttng-probe-block.c b/probes/lttng-probe-block.c index c0c2702c..3eb668ff 100644 --- a/probes/lttng-probe-block.c +++ b/probes/lttng-probe-block.c @@ -29,6 +29,8 @@ */ #include +#include "../wrapper/tracepoint.h" + /* * Create LTTng tracepoint probes. */ -- 2.34.1