[RFC 1/2] tracing: add additional IO tracepoints

From: He Kuang
Date: Fri Feb 06 2015 - 01:59:29 EST


Add tracepoints according to IO data stream to trace data propagate
in vfs, fs, block layers.

Signed-off-by: He Kuang <hekuang@xxxxxxxxxx>
---
block/bio.c | 1 +
block/blk-core.c | 4 +++
drivers/scsi/virtio_scsi.c | 3 ++
fs/ext4/page-io.c | 4 +++
include/trace/events/block.h | 81 ++++++++++++++++++++++++++++++++++++++++++
include/trace/events/ext4.h | 21 +++++++++++
include/trace/events/filemap.h | 25 +++++++++++++
include/trace/events/scsi.h | 21 +++++++++++
mm/filemap.c | 2 ++
9 files changed, 162 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index 471d738..208fb63 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1827,6 +1827,7 @@ void bio_endio(struct bio *bio, int error)
} else {
if (bio->bi_end_io)
bio->bi_end_io(bio, error);
+ trace_bio_endio(bio);
bio = NULL;
}
}
diff --git a/block/blk-core.c b/block/blk-core.c
index 30f6153..7a8ceff 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1442,6 +1442,7 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));

blk_account_io_start(req, false);
+ trace_bio_attempt_back_merge(req, bio);
return true;
}

@@ -1466,6 +1467,7 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req,
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));

blk_account_io_start(req, false);
+ trace_bio_attempt_front_merge(req, bio);
return true;
}

@@ -1612,6 +1614,8 @@ get_rq:
* Returns with the queue unlocked.
*/
req = get_request(q, rw_flags, bio, GFP_NOIO);
+ trace_blk_queue_bio(req, bio);
+
if (IS_ERR(req)) {
bio_endio(bio, PTR_ERR(req)); /* @q is dead */
goto out_unlock;
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index c52bb5d..9fde3e0 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -30,6 +30,8 @@
#include <scsi/scsi_tcq.h>
#include <linux/seqlock.h>

+#include <trace/events/scsi.h>
+
#define VIRTIO_SCSI_MEMPOOL_SZ 64
#define VIRTIO_SCSI_EVENT_LEN 8
#define VIRTIO_SCSI_VQ_BASE 2
@@ -464,6 +466,7 @@ static int virtscsi_add_cmd(struct virtqueue *vq,
sgs[out_num + in_num++] = in->sgl;
}

+ trace_virtscsi_add_cmd(vq, sc->request);
return virtqueue_add_sgs(vq, sgs, out_num, in_num, cmd, GFP_ATOMIC);
}

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index b24a254..d5b618d 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -31,6 +31,8 @@
#include "xattr.h"
#include "acl.h"

+#include <trace/events/ext4.h>
+
static struct kmem_cache *io_end_cachep;

int __init ext4_init_pageio(void)
@@ -478,6 +480,8 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
redirty_page_for_writepage(wbc, page);
break;
}
+ trace_ext4_bio_write_page(io, page);
+
nr_submitted++;
clear_buffer_dirty(bh);
} while ((bh = bh->b_this_page) != head);
diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index e8a5eca..67b572c 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -667,6 +667,87 @@ TRACE_EVENT(block_rq_remap,
(unsigned long long)__entry->old_sector, __entry->nr_bios)
);

+TRACE_EVENT(blk_queue_bio,
+
+ TP_PROTO(struct request *rq, struct bio* bio),
+
+ TP_ARGS(rq, bio),
+
+ TP_STRUCT__entry(
+ __field( void* , rq_base )
+ __field( void*, bio_base)
+ ),
+
+ TP_fast_assign(
+ __entry->rq_base = rq;
+ __entry->bio_base = bio;
+ ),
+
+ TP_printk("Node3 bio=%p rq=%p",
+ __entry->bio_base,
+ __entry->rq_base)
+ );
+
+TRACE_EVENT(bio_attempt_back_merge,
+
+ TP_PROTO(struct request *rq, struct bio* bio),
+
+ TP_ARGS(rq, bio),
+
+ TP_STRUCT__entry(
+ __field( void*, rq_base )
+ __field( void*, bio_base)
+ ),
+
+ TP_fast_assign(
+ __entry->rq_base = rq;
+ __entry->bio_base = bio;
+ ),
+
+ TP_printk("Node3 bio=%p rq=%p",
+ __entry->bio_base,
+ __entry->rq_base)
+ );
+
+TRACE_EVENT(bio_attempt_front_merge,
+
+ TP_PROTO(struct request *rq, struct bio* bio),
+
+ TP_ARGS(rq, bio),
+
+ TP_STRUCT__entry(
+ __field( void*, rq_base )
+ __field( void*, bio_base )
+ ),
+
+ TP_fast_assign(
+ __entry->rq_base = rq;
+ __entry->bio_base = bio;
+ ),
+
+ TP_printk("Node3 bio=%p rq=%p",
+ __entry->bio_base,
+ __entry->rq_base)
+ );
+
+TRACE_EVENT(bio_endio,
+
+ TP_PROTO(struct bio* bio),
+
+ TP_ARGS(bio),
+
+ TP_STRUCT__entry(
+ __field( void*, bio_base )
+ ),
+
+ TP_fast_assign(
+ __entry->bio_base = bio;
+ ),
+
+ TP_printk("Node5 bio=%p",
+ __entry->bio_base)
+ );
+
#endif /* _TRACE_BLOCK_H */

/* This part must be outside protection */
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 6cfb841..507ac24 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -2476,6 +2476,27 @@ TRACE_EVENT(ext4_es_shrink,
__entry->scan_time, __entry->nr_skipped, __entry->retried)
);

+TRACE_EVENT(ext4_bio_write_page,
+ TP_PROTO(struct ext4_io_submit *io, struct page *page),
+
+ TP_ARGS(io, page),
+
+ TP_STRUCT__entry(
+ __field( struct page *, page )
+ __field( struct bio*, bio )
+ ),
+
+ TP_fast_assign(
+ __entry->page = page;
+ __entry->bio = io->io_bio;
+ ),
+
+ TP_printk("Node2 page=%p bio=%p",
+ __entry->page,
+ __entry->bio)
+ );
+
+
#endif /* _TRACE_EXT4_H */

/* This part must be outside protection */
diff --git a/include/trace/events/filemap.h b/include/trace/events/filemap.h
index 0421f49..3173e60 100644
--- a/include/trace/events/filemap.h
+++ b/include/trace/events/filemap.h
@@ -11,6 +11,8 @@
#include <linux/device.h>
#include <linux/kdev_t.h>

+#include <linux/uio.h>
+
DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,

TP_PROTO(struct page *page),
@@ -52,6 +54,29 @@ DEFINE_EVENT(mm_filemap_op_page_cache, mm_filemap_add_to_page_cache,
TP_ARGS(page)
);

+
+
+TRACE_EVENT(iov_iter_copy_from_user_atomic,
+
+ TP_PROTO(struct page *page, struct iov_iter *i),
+
+ TP_ARGS(page, i),
+
+ TP_STRUCT__entry(
+ __field(struct page *, page)
+ __field(void*, iov_base)
+ ),
+
+ TP_fast_assign(
+ __entry->page = page;
+ __entry->iov_base = i->iov->iov_base;
+ ),
+
+ TP_printk("Node1 iov=%p page=%p",
+ __entry->iov_base,
+ __entry->page)
+ );
+
#endif /* _TRACE_FILEMAP_H */

/* This part must be outside protection */
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index 079bd10..e6c0c3a 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -8,6 +8,7 @@
#include <scsi/scsi_host.h>
#include <linux/tracepoint.h>
#include <linux/trace_seq.h>
+#include <linux/virtio.h>

#define scsi_opcode_name(opcode) { opcode, #opcode }
#define show_opcode_name(val) \
@@ -359,6 +360,26 @@ TRACE_EVENT(scsi_eh_wakeup,
TP_printk("host_no=%u", __entry->host_no)
);

+TRACE_EVENT(virtscsi_add_cmd,
+
+ TP_PROTO(struct virtqueue *vq, struct request *req),
+
+ TP_ARGS(vq, req),
+
+ TP_STRUCT__entry(
+ __field( unsigned int, vq_index )
+ __field( void *, req_base )
+ ),
+
+ TP_fast_assign(
+ __entry->vq_index = vq->index;
+ __entry->req_base = req;
+ ),
+
+ TP_printk("Node4 req=%p index=%u", __entry->req_base,
+ __entry->vq_index)
+ );
+
#endif /* _TRACE_SCSI_H */

/* This part must be outside protection */
diff --git a/mm/filemap.c b/mm/filemap.c
index 673e458..d6dd161 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2497,6 +2497,8 @@ again:
if (mapping_writably_mapped(mapping))
flush_dcache_page(page);

+ trace_iov_iter_copy_from_user_atomic(page, i);
+
copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes);
flush_dcache_page(page);

--
2.2.0.33.gc18b867

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/