public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [RFC] io_uring: print COMM on ctx_exit hang
Date: Wed,  6 Oct 2021 16:15:29 +0100	[thread overview]
Message-ID: <77c68af25c707073c2708465ae576f1a231cf961.1633533200.git.asml.silence@gmail.com> (raw)

io_ring_exit_work() hangs are hard to debug partly because there is not
much information of who created the ctx by the time it's exiting, and
the function is running in a wq context, so the task name tells us
nothing. Save creator's task comm and print it when it hangs.

Signed-off-by: Pavel Begunkov <[email protected]>
---

Just for discussion, I hope there are better ways of doing it.

It leaves out the second wait_for_completion() in io_ring_exit_work(),
which is of interest, so would be great to cover the case as well.

 fs/io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 73135c5c6168..db0065637549 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -447,6 +447,8 @@ struct io_ring_ctx {
 		struct work_struct		exit_work;
 		struct list_head		tctx_list;
 		struct completion		ref_comp;
+		/* save owner thread's comm for debugging purposes */
+		char				owner_comm[TASK_COMM_LEN];
 	};
 };
 
@@ -9344,7 +9346,8 @@ static __cold void io_ring_exit_work(struct work_struct *work)
 
 		io_req_caches_free(ctx);
 
-		if (WARN_ON_ONCE(time_after(jiffies, timeout))) {
+		if (WARN_ONCE(time_after(jiffies, timeout), "comm %s\n",
+			      ctx->owner_comm)) {
 			/* there is little hope left, don't run it too often */
 			interval = HZ * 60;
 		}
@@ -10266,6 +10269,8 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
 	if (!capable(CAP_IPC_LOCK))
 		ctx->user = get_uid(current_user());
 
+	get_task_comm(ctx->owner_comm, current);
+
 	/*
 	 * This is just grabbed for accounting purposes. When a process exits,
 	 * the mm is exited and dropped before the files, hence we need to hang
-- 
2.33.0


             reply	other threads:[~2021-10-06 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 15:15 Pavel Begunkov [this message]
2021-10-06 16:00 ` [RFC] io_uring: print COMM on ctx_exit hang Jens Axboe

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=77c68af25c707073c2708465ae576f1a231cf961.1633533200.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /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