diff mbox series

[RFCv4,9/9] iomap: Add couple of DIO tracepoints

Message ID 793d0cc2d49ef472038fca2cbe638e18be40cb0c.1681544352.git.ritesh.list@gmail.com
State Not Applicable
Headers show
Series ext2: DIO to use iomap | expand

Commit Message

Ritesh Harjani (IBM) April 15, 2023, 7:44 a.m. UTC
Add iomap_dio_rw_queued and iomap_dio_complete tracepoint.
iomap_dio_rw_queued is mostly only to know that the request was queued
and -EIOCBQUEUED was returned. It is mostly iomap_dio_complete which has
all the details.

<output log>
           a.out-1827  [004]   707.806763: iomap_dio_rw_queued:  dev 7:7 ino 0xd size 0x1000 offset 0x1000 length 0x0
     ksoftirqd/3-31    [003]   707.806968: iomap_dio_complete:   dev 7:7 ino 0xd size 0x1000 offset 0x1000 flags DIRECT aio 1 error 0 ret 4096

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 fs/iomap/direct-io.c |  5 ++++-
 fs/iomap/trace.c     |  1 +
 fs/iomap/trace.h     | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig April 16, 2023, 5:59 a.m. UTC | #1
On Sat, Apr 15, 2023 at 01:14:30PM +0530, Ritesh Harjani (IBM) wrote:
> Add iomap_dio_rw_queued and iomap_dio_complete tracepoint.
> iomap_dio_rw_queued is mostly only to know that the request was queued
> and -EIOCBQUEUED was returned. It is mostly iomap_dio_complete which has
> all the details.

Everything that is here looks good to me.  But it seems like we lost
the _begin tracepoint?
Christoph Hellwig April 16, 2023, 6:44 a.m. UTC | #2
On Sun, Apr 16, 2023 at 05:24:25PM +0530, Ritesh Harjani wrote:
> Sorry, my bad, I might have only partially understood your review
> comment then. Will quickly send the next rev.
> So in the next rev. will only just add a _begin tracepoint in
> __iomap_dio_rw() function. Rest everything should be as is.

Thanks and sorry for beeing unclear.
Ritesh Harjani (IBM) April 16, 2023, 11:54 a.m. UTC | #3
Christoph Hellwig <hch@infradead.org> writes:

> On Sat, Apr 15, 2023 at 01:14:30PM +0530, Ritesh Harjani (IBM) wrote:
>> Add iomap_dio_rw_queued and iomap_dio_complete tracepoint.
>> iomap_dio_rw_queued is mostly only to know that the request was queued
>> and -EIOCBQUEUED was returned. It is mostly iomap_dio_complete which has
>> all the details.
>
> Everything that is here looks good to me.  But it seems like we lost
> the _begin tracepoint?

Sorry, my bad, I might have only partially understood your review
comment then. Will quickly send the next rev.
So in the next rev. will only just add a _begin tracepoint in
__iomap_dio_rw() function. Rest everything should be as is.

Right?
diff mbox series

Patch

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 36ab1152dbea..cef28cfd77b7 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -130,6 +130,7 @@  ssize_t iomap_dio_complete(struct iomap_dio *dio)
 	if (ret > 0)
 		ret += dio->done_before;
 
+	trace_iomap_dio_complete(iocb, dio->error, ret);
 	kfree(dio);
 
 	return ret;
@@ -650,8 +651,10 @@  __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	 */
 	dio->wait_for_completion = wait_for_completion;
 	if (!atomic_dec_and_test(&dio->ref)) {
-		if (!wait_for_completion)
+		if (!wait_for_completion) {
+			trace_iomap_dio_rw_queued(inode, iomi.pos, iomi.len);
 			return ERR_PTR(-EIOCBQUEUED);
+		}
 
 		for (;;) {
 			set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/fs/iomap/trace.c b/fs/iomap/trace.c
index da217246b1a9..728d5443daf5 100644
--- a/fs/iomap/trace.c
+++ b/fs/iomap/trace.c
@@ -3,6 +3,7 @@ 
  * Copyright (c) 2019 Christoph Hellwig
  */
 #include <linux/iomap.h>
+#include <linux/uio.h>
 
 /*
  * We include this last to have the helpers above available for the trace
diff --git a/fs/iomap/trace.h b/fs/iomap/trace.h
index f6ea9540d082..9c017af93302 100644
--- a/fs/iomap/trace.h
+++ b/fs/iomap/trace.h
@@ -83,6 +83,7 @@  DEFINE_RANGE_EVENT(iomap_writepage);
 DEFINE_RANGE_EVENT(iomap_release_folio);
 DEFINE_RANGE_EVENT(iomap_invalidate_folio);
 DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
+DEFINE_RANGE_EVENT(iomap_dio_rw_queued);
 
 #define IOMAP_TYPE_STRINGS \
 	{ IOMAP_HOLE,		"HOLE" }, \
@@ -183,6 +184,40 @@  TRACE_EVENT(iomap_iter,
 		   (void *)__entry->caller)
 );
 
+TRACE_EVENT(iomap_dio_complete,
+	TP_PROTO(struct kiocb *iocb, int error, ssize_t ret),
+	TP_ARGS(iocb, error, ret),
+	TP_STRUCT__entry(
+		__field(dev_t,	dev)
+		__field(ino_t,	ino)
+		__field(loff_t, isize)
+		__field(loff_t, pos)
+		__field(int,	ki_flags)
+		__field(bool,	aio)
+		__field(int,	error)
+		__field(ssize_t, ret)
+	),
+	TP_fast_assign(
+		__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
+		__entry->ino = file_inode(iocb->ki_filp)->i_ino;
+		__entry->isize = file_inode(iocb->ki_filp)->i_size;
+		__entry->pos = iocb->ki_pos;
+		__entry->ki_flags = iocb->ki_flags;
+		__entry->aio = !is_sync_kiocb(iocb);
+		__entry->error = error;
+		__entry->ret = ret;
+	),
+	TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx flags %s aio %d error %d ret %zd",
+		  MAJOR(__entry->dev), MINOR(__entry->dev),
+		  __entry->ino,
+		  __entry->isize,
+		  __entry->pos,
+		  __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
+		  __entry->aio,
+		  __entry->error,
+		  __entry->ret)
+);
+
 #endif /* _IOMAP_TRACE_H */
 
 #undef TRACE_INCLUDE_PATH