Lines Matching refs:ctx

79 	struct io_ring_ctx *ctx;
82 list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
83 sq_thread_idle = max(sq_thread_idle, ctx->sq_thread_idle);
87 void io_sq_thread_finish(struct io_ring_ctx *ctx)
89 struct io_sq_data *sqd = ctx->sq_data;
93 list_del_init(&ctx->sqd_list);
98 ctx->sq_data = NULL;
167 static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
172 to_submit = io_sqring_entries(ctx);
177 if (!wq_list_empty(&ctx->iopoll_list) || to_submit) {
180 if (ctx->sq_creds != current_cred())
181 creds = override_creds(ctx->sq_creds);
183 mutex_lock(&ctx->uring_lock);
184 if (!wq_list_empty(&ctx->iopoll_list))
185 io_do_iopoll(ctx, true);
191 if (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)) &&
192 !(ctx->flags & IORING_SETUP_R_DISABLED))
193 ret = io_submit_sqes(ctx, to_submit);
194 mutex_unlock(&ctx->uring_lock);
196 if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))
197 wake_up(&ctx->sqo_sq_wait);
225 struct io_ring_ctx *ctx;
254 list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
255 int ret = __io_sq_thread(ctx, cap_entries);
257 if (!sqt_spin && (ret > 0 || !wq_list_empty(&ctx->iopoll_list)))
279 list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
281 &ctx->rings->sq_flags);
282 if ((ctx->flags & IORING_SETUP_IOPOLL) &&
283 !wq_list_empty(&ctx->iopoll_list)) {
294 if (io_sqring_entries(ctx)) {
306 list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
308 &ctx->rings->sq_flags);
317 list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
318 atomic_or(IORING_SQ_NEED_WAKEUP, &ctx->rings->sq_flags);
326 void io_sqpoll_wait_sq(struct io_ring_ctx *ctx)
331 if (!io_sqring_full(ctx))
333 prepare_to_wait(&ctx->sqo_sq_wait, &wait, TASK_INTERRUPTIBLE);
335 if (!io_sqring_full(ctx))
340 finish_wait(&ctx->sqo_sq_wait, &wait);
343 __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
349 if ((ctx->flags & (IORING_SETUP_ATTACH_WQ | IORING_SETUP_SQPOLL)) ==
362 if (ctx->flags & IORING_SETUP_SQPOLL) {
377 ctx->sq_creds = get_current_cred();
378 ctx->sq_data = sqd;
379 ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle);
380 if (!ctx->sq_thread_idle)
381 ctx->sq_thread_idle = HZ;
384 list_add(&ctx->sqd_list, &sqd->ctx_list);
415 ret = io_uring_alloc_task_context(tsk, ctx);
427 complete(&ctx->sq_data->exited);
429 io_sq_thread_finish(ctx);
433 __cold int io_sqpoll_wq_cpu_affinity(struct io_ring_ctx *ctx,
436 struct io_sq_data *sqd = ctx->sq_data;