* [PATCH RESEND] io_uring: show sqthread pid and cpu in fdinfo
@ 2020-09-24 2:55 Joseph Qi
2020-09-24 10:04 ` Stefano Garzarella
2020-09-24 19:49 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Joseph Qi @ 2020-09-24 2:55 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, Xiaoguang Wang
In most cases we'll specify IORING_SETUP_SQPOLL and run multiple
io_uring instances in a host. Since all sqthreads are named
"io_uring-sq", it's hard to distinguish the relations between
application process and its io_uring sqthread.
With this patch, application can get its corresponding sqthread pid
and cpu through show_fdinfo.
Steps:
1. Get io_uring fd first.
$ ls -l /proc/<pid>/fd | grep -w io_uring
2. Then get io_uring instance related info, including corresponding
sqthread pid and cpu.
$ cat /proc/<pid>/fdinfo/<io_uring_fd>
pos: 0
flags: 02000002
mnt_id: 13
SqThread: 6929
SqThreadCpu: 2
UserFiles: 1
0: testfile
UserBufs: 0
PollList:
Signed-off-by: Joseph Qi <[email protected]>
---
fs/io_uring.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8b426aa..9c8b3b3 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8415,6 +8415,10 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
int i;
mutex_lock(&ctx->uring_lock);
+ seq_printf(m, "SqThread:\t%d\n", (ctx->flags & IORING_SETUP_SQPOLL) ?
+ task_pid_nr(ctx->sqo_thread) : -1);
+ seq_printf(m, "SqThreadCpu:\t%d\n", (ctx->flags & IORING_SETUP_SQPOLL) ?
+ task_cpu(ctx->sqo_thread) : -1);
seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files);
for (i = 0; i < ctx->nr_user_files; i++) {
struct fixed_file_table *table;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] io_uring: show sqthread pid and cpu in fdinfo
2020-09-24 2:55 [PATCH RESEND] io_uring: show sqthread pid and cpu in fdinfo Joseph Qi
@ 2020-09-24 10:04 ` Stefano Garzarella
2020-09-24 19:49 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2020-09-24 10:04 UTC (permalink / raw)
To: Joseph Qi; +Cc: Jens Axboe, io-uring, Xiaoguang Wang
On Thu, Sep 24, 2020 at 10:55:24AM +0800, Joseph Qi wrote:
> In most cases we'll specify IORING_SETUP_SQPOLL and run multiple
> io_uring instances in a host. Since all sqthreads are named
> "io_uring-sq", it's hard to distinguish the relations between
> application process and its io_uring sqthread.
> With this patch, application can get its corresponding sqthread pid
> and cpu through show_fdinfo.
> Steps:
> 1. Get io_uring fd first.
> $ ls -l /proc/<pid>/fd | grep -w io_uring
> 2. Then get io_uring instance related info, including corresponding
> sqthread pid and cpu.
> $ cat /proc/<pid>/fdinfo/<io_uring_fd>
>
> pos: 0
> flags: 02000002
> mnt_id: 13
> SqThread: 6929
> SqThreadCpu: 2
> UserFiles: 1
> 0: testfile
> UserBufs: 0
> PollList:
>
> Signed-off-by: Joseph Qi <[email protected]>
> ---
> fs/io_uring.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 8b426aa..9c8b3b3 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -8415,6 +8415,10 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
> int i;
>
> mutex_lock(&ctx->uring_lock);
> + seq_printf(m, "SqThread:\t%d\n", (ctx->flags & IORING_SETUP_SQPOLL) ?
> + task_pid_nr(ctx->sqo_thread) : -1);
What about 'SqThreadPID'?
> + seq_printf(m, "SqThreadCpu:\t%d\n", (ctx->flags & IORING_SETUP_SQPOLL) ?
> + task_cpu(ctx->sqo_thread) : -1);
> seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files);
> for (i = 0; i < ctx->nr_user_files; i++) {
> struct fixed_file_table *table;
> --
> 1.8.3.1
>
With or without that changed, it looks good to me:
Reviewed-by: Stefano Garzarella <[email protected]>
Thanks,
Stefano
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] io_uring: show sqthread pid and cpu in fdinfo
2020-09-24 2:55 [PATCH RESEND] io_uring: show sqthread pid and cpu in fdinfo Joseph Qi
2020-09-24 10:04 ` Stefano Garzarella
@ 2020-09-24 19:49 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-09-24 19:49 UTC (permalink / raw)
To: Joseph Qi; +Cc: io-uring, Xiaoguang Wang
On 9/23/20 8:55 PM, Joseph Qi wrote:
> In most cases we'll specify IORING_SETUP_SQPOLL and run multiple
> io_uring instances in a host. Since all sqthreads are named
> "io_uring-sq", it's hard to distinguish the relations between
> application process and its io_uring sqthread.
> With this patch, application can get its corresponding sqthread pid
> and cpu through show_fdinfo.
> Steps:
> 1. Get io_uring fd first.
> $ ls -l /proc/<pid>/fd | grep -w io_uring
> 2. Then get io_uring instance related info, including corresponding
> sqthread pid and cpu.
> $ cat /proc/<pid>/fdinfo/<io_uring_fd>
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-24 19:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-24 2:55 [PATCH RESEND] io_uring: show sqthread pid and cpu in fdinfo Joseph Qi
2020-09-24 10:04 ` Stefano Garzarella
2020-09-24 19:49 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox