Skip to contentSkip to conversation

io_uring: store pid of sqthread for userspace usage

PATCH New Hao Xu 1 participant 1 message Jul 12, 2021

Subsystems (2)
lore
Share & tools
lore

Hao Xu

author
#0 lore raw

PATCH 2/2 io_uring: store pid of sqthread for userspace usage

users may want to change the schedule policy and priority of sqthread. So it's good to store this info in io_uring_params.

---
 fs/io_uring.c                 | 1 +
 include/uapi/linux/io_uring.h | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
fs/io_uring.c +1 -0
index ca9172f51a77..9f7101f3c28d 100644
@@ -8054,6 +8054,7 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
 		wake_up_new_task(tsk);
 		if (ret)
 			goto err;
+		p->sq_thread_pid = task_pid_vnr(tsk);
 	} else if (p->flags & IORING_SETUP_SQ_AFF) {
 		/* Can't have SQ_AFF without SQPOLL */
 		ret = -EINVAL;
include/uapi/linux/io_uring.h +4 -1
index 79126d5cd289..07b624be7a66 100644
@@ -254,7 +254,10 @@ struct io_uring_params {
 	__u32 sq_entries;
 	__u32 cq_entries;
 	__u32 flags;
-	__u32 sq_thread_cpu;
+	union {
+		__u32 sq_thread_cpu;
+		__s32 sq_thread_pid;
+	};
 	__u32 sq_thread_idle;
 	__u32 features;
 	__u32 wq_fd;
Signature · 1 line
2.24.4