xref: /linux/io_uring/sqpoll.h (revision 360395e8dbf9d23579f74b84a1af11190813b0f8)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 struct io_sq_data {
4 	refcount_t		refs;
5 	/* one for all the rings, one for the thread: the last put frees */
6 	refcount_t		free_refs;
7 	atomic_t		park_pending;
8 	struct mutex		lock;
9 
10 	/* ctx's that are using this sqd */
11 	struct list_head	ctx_list;
12 
13 	struct task_struct __rcu *thread;
14 	struct wait_queue_head	wait;
15 
16 	unsigned		sq_thread_idle;
17 	int			sq_cpu;
18 	pid_t			task_pid;
19 	pid_t			task_tgid;
20 
21 	u64			work_time;
22 	unsigned long		state;
23 };
24 
25 int io_sq_offload_create(struct io_ring_ctx *ctx, struct io_uring_params *p);
26 void io_sq_thread_finish(struct io_ring_ctx *ctx);
27 void io_sq_thread_stop(struct io_sq_data *sqd);
28 void io_sq_thread_park(struct io_sq_data *sqd);
29 void io_sq_thread_unpark(struct io_sq_data *sqd);
30 void io_put_sq_data(struct io_sq_data *sqd);
31 void io_sqpoll_wait_sq(struct io_ring_ctx *ctx);
32 int io_sqpoll_wq_cpu_affinity(struct io_ring_ctx *ctx, cpumask_var_t mask);
33 u64 io_sq_cpu_usec(struct task_struct *tsk);
34 
35 static inline struct task_struct *sqpoll_task_locked(struct io_sq_data *sqd)
36 {
37 	return rcu_dereference_protected(sqd->thread,
38 					 lockdep_is_held(&sqd->lock));
39 }
40