Skip to content

Commit 3fd4172

Browse files
riteshharjaniDarrick J. Wong
authored andcommitted
iomap: Add DIO tracepoints
Add trace_iomap_dio_rw_begin, trace_iomap_dio_rw_queued and trace_iomap_dio_complete tracepoint. trace_iomap_dio_rw_queued is mostly only to know that the request was queued and -EIOCBQUEUED was returned. It is mostly trace_iomap_dio_rw_begin & trace_iomap_dio_complete which has all the details. <example output log> a.out-2073 [006] 134.225717: iomap_dio_rw_begin: dev 7:7 ino 0xe size 0x0 offset 0x0 length 0x1000 done_before 0x0 flags DIRECT|WRITE dio_flags DIO_FORCE_WAIT aio 1 a.out-2073 [006] 134.226234: iomap_dio_complete: dev 7:7 ino 0xe size 0x1000 offset 0x1000 flags DIRECT|WRITE aio 1 error 0 ret 4096 a.out-2074 [006] 136.225975: iomap_dio_rw_begin: dev 7:7 ino 0xe size 0x1000 offset 0x0 length 0x1000 done_before 0x0 flags DIRECT dio_flags aio 1 a.out-2074 [006] 136.226173: iomap_dio_rw_queued: dev 7:7 ino 0xe size 0x1000 offset 0x1000 length 0x0 ksoftirqd/3-31 [003] 136.226389: iomap_dio_complete: dev 7:7 ino 0xe size 0x1000 offset 0x1000 flags DIRECT aio 1 error 0 ret 4096 a.out-2075 [003] 141.674969: iomap_dio_rw_begin: dev 7:7 ino 0xe size 0x1000 offset 0x0 length 0x1000 done_before 0x0 flags DIRECT|WRITE dio_flags aio 1 a.out-2075 [003] 141.676085: iomap_dio_rw_queued: dev 7:7 ino 0xe size 0x1000 offset 0x1000 length 0x0 kworker/2:0-27 [002] 141.676432: iomap_dio_complete: dev 7:7 ino 0xe size 0x1000 offset 0x1000 flags DIRECT|WRITE aio 1 error 0 ret 4096 a.out-2077 [006] 143.443746: iomap_dio_rw_begin: dev 7:7 ino 0xe size 0x1000 offset 0x0 length 0x1000 done_before 0x0 flags DIRECT dio_flags aio 1 a.out-2077 [006] 143.443866: iomap_dio_rw_queued: dev 7:7 ino 0xe size 0x1000 offset 0x1000 length 0x0 ksoftirqd/5-41 [005] 143.444134: iomap_dio_complete: dev 7:7 ino 0xe size 0x1000 offset 0x1000 flags DIRECT aio 1 error 0 ret 4096 a.out-2078 [007] 146.716833: iomap_dio_rw_begin: dev 7:7 ino 0xe size 0x1000 offset 0x0 length 0x1000 done_before 0x0 flags DIRECT dio_flags aio 0 a.out-2078 [007] 146.717639: iomap_dio_complete: dev 7:7 ino 0xe size 0x1000 offset 0x1000 flags DIRECT aio 0 error 0 ret 4096 a.out-2079 [006] 148.972605: iomap_dio_rw_begin: dev 7:7 ino 0xe size 0x1000 offset 0x0 length 0x1000 done_before 0x0 flags DIRECT dio_flags aio 0 a.out-2079 [006] 148.973099: iomap_dio_complete: dev 7:7 ino 0xe size 0x1000 offset 0x1000 flags DIRECT aio 0 error 0 ret 4096 Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> [djwong: line up strings all prettylike] Signed-off-by: Darrick J. Wong <djwong@kernel.org>
1 parent d3bff1f commit 3fd4172

3 files changed

Lines changed: 85 additions & 1 deletion

File tree

fs/iomap/direct-io.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
130130
if (ret > 0)
131131
ret += dio->done_before;
132132

133+
trace_iomap_dio_complete(iocb, dio->error, ret);
133134
kfree(dio);
134135

135136
return ret;
@@ -493,6 +494,8 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
493494
struct blk_plug plug;
494495
struct iomap_dio *dio;
495496

497+
trace_iomap_dio_rw_begin(iocb, iter, dio_flags, done_before);
498+
496499
if (!iomi.len)
497500
return NULL;
498501

@@ -650,8 +653,10 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
650653
*/
651654
dio->wait_for_completion = wait_for_completion;
652655
if (!atomic_dec_and_test(&dio->ref)) {
653-
if (!wait_for_completion)
656+
if (!wait_for_completion) {
657+
trace_iomap_dio_rw_queued(inode, iomi.pos, iomi.len);
654658
return ERR_PTR(-EIOCBQUEUED);
659+
}
655660

656661
for (;;) {
657662
set_current_state(TASK_UNINTERRUPTIBLE);

fs/iomap/trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2019 Christoph Hellwig
44
*/
55
#include <linux/iomap.h>
6+
#include <linux/uio.h>
67

78
/*
89
* We include this last to have the helpers above available for the trace

fs/iomap/trace.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ DEFINE_RANGE_EVENT(iomap_writepage);
8383
DEFINE_RANGE_EVENT(iomap_release_folio);
8484
DEFINE_RANGE_EVENT(iomap_invalidate_folio);
8585
DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
86+
DEFINE_RANGE_EVENT(iomap_dio_rw_queued);
8687

8788
#define IOMAP_TYPE_STRINGS \
8889
{ IOMAP_HOLE, "HOLE" }, \
@@ -107,6 +108,11 @@ DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
107108
{ IOMAP_F_BUFFER_HEAD, "BH" }, \
108109
{ IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" }
109110

111+
#define IOMAP_DIO_STRINGS \
112+
{IOMAP_DIO_FORCE_WAIT, "DIO_FORCE_WAIT" }, \
113+
{IOMAP_DIO_OVERWRITE_ONLY, "DIO_OVERWRITE_ONLY" }, \
114+
{IOMAP_DIO_PARTIAL, "DIO_PARTIAL" }
115+
110116
DECLARE_EVENT_CLASS(iomap_class,
111117
TP_PROTO(struct inode *inode, struct iomap *iomap),
112118
TP_ARGS(inode, iomap),
@@ -183,6 +189,78 @@ TRACE_EVENT(iomap_iter,
183189
(void *)__entry->caller)
184190
);
185191

192+
TRACE_EVENT(iomap_dio_rw_begin,
193+
TP_PROTO(struct kiocb *iocb, struct iov_iter *iter,
194+
unsigned int dio_flags, size_t done_before),
195+
TP_ARGS(iocb, iter, dio_flags, done_before),
196+
TP_STRUCT__entry(
197+
__field(dev_t, dev)
198+
__field(ino_t, ino)
199+
__field(loff_t, isize)
200+
__field(loff_t, pos)
201+
__field(size_t, count)
202+
__field(size_t, done_before)
203+
__field(int, ki_flags)
204+
__field(unsigned int, dio_flags)
205+
__field(bool, aio)
206+
),
207+
TP_fast_assign(
208+
__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
209+
__entry->ino = file_inode(iocb->ki_filp)->i_ino;
210+
__entry->isize = file_inode(iocb->ki_filp)->i_size;
211+
__entry->pos = iocb->ki_pos;
212+
__entry->count = iov_iter_count(iter);
213+
__entry->done_before = done_before;
214+
__entry->ki_flags = iocb->ki_flags;
215+
__entry->dio_flags = dio_flags;
216+
__entry->aio = !is_sync_kiocb(iocb);
217+
),
218+
TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx length 0x%zx done_before 0x%zx flags %s dio_flags %s aio %d",
219+
MAJOR(__entry->dev), MINOR(__entry->dev),
220+
__entry->ino,
221+
__entry->isize,
222+
__entry->pos,
223+
__entry->count,
224+
__entry->done_before,
225+
__print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
226+
__print_flags(__entry->dio_flags, "|", IOMAP_DIO_STRINGS),
227+
__entry->aio)
228+
);
229+
230+
TRACE_EVENT(iomap_dio_complete,
231+
TP_PROTO(struct kiocb *iocb, int error, ssize_t ret),
232+
TP_ARGS(iocb, error, ret),
233+
TP_STRUCT__entry(
234+
__field(dev_t, dev)
235+
__field(ino_t, ino)
236+
__field(loff_t, isize)
237+
__field(loff_t, pos)
238+
__field(int, ki_flags)
239+
__field(bool, aio)
240+
__field(int, error)
241+
__field(ssize_t, ret)
242+
),
243+
TP_fast_assign(
244+
__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
245+
__entry->ino = file_inode(iocb->ki_filp)->i_ino;
246+
__entry->isize = file_inode(iocb->ki_filp)->i_size;
247+
__entry->pos = iocb->ki_pos;
248+
__entry->ki_flags = iocb->ki_flags;
249+
__entry->aio = !is_sync_kiocb(iocb);
250+
__entry->error = error;
251+
__entry->ret = ret;
252+
),
253+
TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx flags %s aio %d error %d ret %zd",
254+
MAJOR(__entry->dev), MINOR(__entry->dev),
255+
__entry->ino,
256+
__entry->isize,
257+
__entry->pos,
258+
__print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
259+
__entry->aio,
260+
__entry->error,
261+
__entry->ret)
262+
);
263+
186264
#endif /* _IOMAP_TRACE_H */
187265

188266
#undef TRACE_INCLUDE_PATH

0 commit comments

Comments
 (0)