io_uring: show sqthread pid and cpu in fdinfo
PATCH 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:
---
1. Go to upstream/4.9/4.19?(N)
2. Backport from upstream?(N)
3. Summarized pre-commmit testing in Aone (Y)
4. Aone URL (https://aone.alibaba-inc.com/task/29517834)
5. Use CONFIG_xxx ? (N)
6. Use sysfs or boot parameter to turn off code changes? (N)
7. Any kernel-userspace API/ABI changes? (N)
8. I have full maintenance commitments for my 50+ code changes (Y)
fs/io_uring.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/io_uring.c +4 -0
@@ -7934,6 +7934,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