io_uring: show sqthread pid and cpu in fdinfo
PATCH RESEND 1/1 io_uring: show sqthread pid and cpu in fdinfo
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: 02000002mnt_id: 13
SqThread: 6929
SqThreadCpu: 2
UserFiles: 1
0: testfile
UserBufs: 0
PollList:
--- fs/io_uring.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/io_uring.c +4 -0
@@ -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;
Signature · 1 line
1.8.3.1
Quoted 33 lines · Joseph Qi
In most cases we'll specify
IORING_SETUP_SQPOLLand run multipleio_uringinstances in a host. Since all sqthreads are named "io_uring-sq", it's hard to distinguish the relations between application process and itsio_uringsqthread.
With this patch, application can get its corresponding sqthread pid and cpu throughshow_fdinfo.
Steps:
1. Getio_uringfd 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: 02000002mnt_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(+)fs/io_uring.c +0
-0
fs/io_uring.c static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) · line 8419
Quoted 5 lines
fs/io_uring.c +2
-0@@ -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'?
Quoted 8 lines
fs/io_uring.c +2
-0+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;Signature · 1 line
1.8.3.1
With or without that changed, it looks good to me:
Thanks,
Stefano
Quoted 8 lines · Joseph Qi
In most cases we'll specify
IORING_SETUP_SQPOLLand run multipleio_uringinstances in a host. Since all sqthreads are named "io_uring-sq", it's hard to distinguish the relations between application process and itsio_uringsqthread.
With this patch, application can get its corresponding sqthread pid and cpu throughshow_fdinfo.
Steps:
1. Getio_uringfd first.
Quoted 4 lines
$ 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.
Signature · 1 line
Jens Axboe