linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitrii Dolgov <9erthalion6@gmail.com>
To: axboe@kernel.dk, linux-block@vger.kernel.org
Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
Subject: [RFC v1] io_uring: add io_uring_link trace event
Date: Tue,  8 Oct 2019 14:53:57 +0200	[thread overview]
Message-ID: <20191008125357.25265-1-9erthalion6@gmail.com> (raw)

To trace io_uring activity one can get an information from workqueue and
io trace events, but looks like some parts could be hard to identify.
E.g. it's not easy to figure out that one work was started after another
due to a link between them.

For that purpose introduce io_uring_link trace event, that will be fired
when a request is added to a link_list.

Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com>
---
 fs/io_uring.c                   |  4 ++++
 include/Kbuild                  |  1 +
 include/trace/events/io_uring.h | 42 +++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+)
 create mode 100644 include/trace/events/io_uring.h

diff --git a/fs/io_uring.c b/fs/io_uring.c
index bfbb7ab3c4e..63e4b592d69 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -71,6 +71,9 @@
 #include <linux/sizes.h>
 #include <linux/hugetlb.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/io_uring.h>
+
 #include <uapi/linux/io_uring.h>
 
 #include "internal.h"
@@ -2488,6 +2491,7 @@ static void io_submit_sqe(struct io_ring_ctx *ctx, struct sqe_submit *s,
 
 		s->sqe = sqe_copy;
 		memcpy(&req->submit, s, sizeof(*s));
+		trace_io_uring_link(&req->work, &prev->work);
 		list_add_tail(&req->list, &prev->link_list);
 	} else if (s->sqe->flags & IOSQE_IO_LINK) {
 		req->flags |= REQ_F_LINK;
diff --git a/include/Kbuild b/include/Kbuild
index ffba79483cc..61b66725d25 100644
--- a/include/Kbuild
+++ b/include/Kbuild
@@ -1028,6 +1028,7 @@ header-test-			+= trace/events/fsi_master_gpio.h
 header-test-			+= trace/events/huge_memory.h
 header-test-			+= trace/events/ib_mad.h
 header-test-			+= trace/events/ib_umad.h
+header-test-			+= trace/events/io_uring.h
 header-test-			+= trace/events/iscsi.h
 header-test-			+= trace/events/jbd2.h
 header-test-			+= trace/events/kvm.h
diff --git a/include/trace/events/io_uring.h b/include/trace/events/io_uring.h
new file mode 100644
index 00000000000..56245c31a1e
--- /dev/null
+++ b/include/trace/events/io_uring.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM io_uring
+
+#if !defined(_TRACE_IO_URING_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_IO_URING_H
+
+#include <linux/tracepoint.h>
+
+/**
+ * io_uring_link - called immediately before the io_uring work added into
+ * 				   link_list of the another request.
+ * @work:			pointer to linked struct work_struct
+ * @target_work:	pointer to previous struct work_struct,
+ * 					that would contain @work
+ *
+ * Allows to track linked requests in io_uring.
+ */
+TRACE_EVENT(io_uring_link,
+
+	TP_PROTO(struct work_struct *work, struct work_struct *target_work),
+
+	TP_ARGS(work, target_work),
+
+	TP_STRUCT__entry (
+		__field(  void *,	work			)
+		__field(  void *,	target_work		)
+	),
+
+	TP_fast_assign(
+		__entry->work			= work;
+		__entry->target_work	= target_work;
+	),
+
+	TP_printk("io_uring work struct %p linked after %p",
+			  __entry->work, __entry->target_work)
+);
+
+#endif /* _TRACE_IO_URING_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
-- 
2.21.0


             reply	other threads:[~2019-10-08 12:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 12:53 Dmitrii Dolgov [this message]
2019-10-08 12:54 ` [RFC v1] io_uring: add io_uring_link trace event Dmitry Dolgov
2019-10-08 13:01   ` Jens Axboe
2019-10-08 13:11     ` Dmitry Dolgov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191008125357.25265-1-9erthalion6@gmail.com \
    --to=9erthalion6@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).