io_uring.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef IOU_CORE_H
  3. #define IOU_CORE_H
  4. #include <linux/errno.h>
  5. #include <linux/lockdep.h>
  6. #include <linux/resume_user_mode.h>
  7. #include <linux/poll.h>
  8. #include <linux/io_uring_types.h>
  9. #include <uapi/linux/eventpoll.h>
  10. #include "alloc_cache.h"
  11. #include "io-wq.h"
  12. #include "slist.h"
  13. #include "tw.h"
  14. #include "opdef.h"
  15. #ifndef CREATE_TRACE_POINTS
  16. #include <trace/events/io_uring.h>
  17. #endif
  18. struct io_rings_layout {
  19. /* size of CQ + headers + SQ offset array */
  20. size_t rings_size;
  21. size_t sq_size;
  22. size_t sq_array_offset;
  23. };
  24. struct io_ctx_config {
  25. struct io_uring_params p;
  26. struct io_rings_layout layout;
  27. struct io_uring_params __user *uptr;
  28. };
  29. #define IORING_FEAT_FLAGS (IORING_FEAT_SINGLE_MMAP |\
  30. IORING_FEAT_NODROP |\
  31. IORING_FEAT_SUBMIT_STABLE |\
  32. IORING_FEAT_RW_CUR_POS |\
  33. IORING_FEAT_CUR_PERSONALITY |\
  34. IORING_FEAT_FAST_POLL |\
  35. IORING_FEAT_POLL_32BITS |\
  36. IORING_FEAT_SQPOLL_NONFIXED |\
  37. IORING_FEAT_EXT_ARG |\
  38. IORING_FEAT_NATIVE_WORKERS |\
  39. IORING_FEAT_RSRC_TAGS |\
  40. IORING_FEAT_CQE_SKIP |\
  41. IORING_FEAT_LINKED_FILE |\
  42. IORING_FEAT_REG_REG_RING |\
  43. IORING_FEAT_RECVSEND_BUNDLE |\
  44. IORING_FEAT_MIN_TIMEOUT |\
  45. IORING_FEAT_RW_ATTR |\
  46. IORING_FEAT_NO_IOWAIT)
  47. #define IORING_SETUP_FLAGS (IORING_SETUP_IOPOLL |\
  48. IORING_SETUP_SQPOLL |\
  49. IORING_SETUP_SQ_AFF |\
  50. IORING_SETUP_CQSIZE |\
  51. IORING_SETUP_CLAMP |\
  52. IORING_SETUP_ATTACH_WQ |\
  53. IORING_SETUP_R_DISABLED |\
  54. IORING_SETUP_SUBMIT_ALL |\
  55. IORING_SETUP_COOP_TASKRUN |\
  56. IORING_SETUP_TASKRUN_FLAG |\
  57. IORING_SETUP_SQE128 |\
  58. IORING_SETUP_CQE32 |\
  59. IORING_SETUP_SINGLE_ISSUER |\
  60. IORING_SETUP_DEFER_TASKRUN |\
  61. IORING_SETUP_NO_MMAP |\
  62. IORING_SETUP_REGISTERED_FD_ONLY |\
  63. IORING_SETUP_NO_SQARRAY |\
  64. IORING_SETUP_HYBRID_IOPOLL |\
  65. IORING_SETUP_CQE_MIXED |\
  66. IORING_SETUP_SQE_MIXED |\
  67. IORING_SETUP_SQ_REWIND)
  68. #define IORING_ENTER_FLAGS (IORING_ENTER_GETEVENTS |\
  69. IORING_ENTER_SQ_WAKEUP |\
  70. IORING_ENTER_SQ_WAIT |\
  71. IORING_ENTER_EXT_ARG |\
  72. IORING_ENTER_REGISTERED_RING |\
  73. IORING_ENTER_ABS_TIMER |\
  74. IORING_ENTER_EXT_ARG_REG |\
  75. IORING_ENTER_NO_IOWAIT)
  76. #define SQE_VALID_FLAGS (IOSQE_FIXED_FILE |\
  77. IOSQE_IO_DRAIN |\
  78. IOSQE_IO_LINK |\
  79. IOSQE_IO_HARDLINK |\
  80. IOSQE_ASYNC |\
  81. IOSQE_BUFFER_SELECT |\
  82. IOSQE_CQE_SKIP_SUCCESS)
  83. #define IO_REQ_LINK_FLAGS (REQ_F_LINK | REQ_F_HARDLINK)
  84. /*
  85. * Complaint timeout for io_uring cancelation exits, and for io-wq exit
  86. * worker waiting.
  87. */
  88. #define IO_URING_EXIT_WAIT_MAX (HZ * 60 * 5)
  89. enum {
  90. IOU_COMPLETE = 0,
  91. IOU_ISSUE_SKIP_COMPLETE = -EIOCBQUEUED,
  92. /*
  93. * The request has more work to do and should be retried. io_uring will
  94. * attempt to wait on the file for eligible opcodes, but otherwise
  95. * it'll be handed to iowq for blocking execution. It works for normal
  96. * requests as well as for the multi shot mode.
  97. */
  98. IOU_RETRY = -EAGAIN,
  99. /*
  100. * Requeue the task_work to restart operations on this request. The
  101. * actual value isn't important, should just be not an otherwise
  102. * valid error code, yet less than -MAX_ERRNO and valid internally.
  103. */
  104. IOU_REQUEUE = -3072,
  105. };
  106. struct io_defer_entry {
  107. struct list_head list;
  108. struct io_kiocb *req;
  109. };
  110. struct io_wait_queue {
  111. struct wait_queue_entry wq;
  112. struct io_ring_ctx *ctx;
  113. unsigned cq_tail;
  114. unsigned cq_min_tail;
  115. unsigned nr_timeouts;
  116. int hit_timeout;
  117. ktime_t min_timeout;
  118. ktime_t timeout;
  119. struct hrtimer t;
  120. #ifdef CONFIG_NET_RX_BUSY_POLL
  121. ktime_t napi_busy_poll_dt;
  122. bool napi_prefer_busy_poll;
  123. #endif
  124. };
  125. static inline struct io_rings *io_get_rings(struct io_ring_ctx *ctx)
  126. {
  127. return rcu_dereference_check(ctx->rings_rcu,
  128. lockdep_is_held(&ctx->uring_lock) ||
  129. lockdep_is_held(&ctx->completion_lock));
  130. }
  131. static inline bool io_should_wake(struct io_wait_queue *iowq)
  132. {
  133. struct io_ring_ctx *ctx = iowq->ctx;
  134. struct io_rings *rings;
  135. int dist;
  136. guard(rcu)();
  137. rings = io_get_rings(ctx);
  138. /*
  139. * Wake up if we have enough events, or if a timeout occurred since we
  140. * started waiting. For timeouts, we always want to return to userspace,
  141. * regardless of event count.
  142. */
  143. dist = READ_ONCE(rings->cq.tail) - (int) iowq->cq_tail;
  144. return dist >= 0 || atomic_read(&ctx->cq_timeouts) != iowq->nr_timeouts;
  145. }
  146. #define IORING_MAX_ENTRIES 32768
  147. #define IORING_MAX_CQ_ENTRIES (2 * IORING_MAX_ENTRIES)
  148. int io_prepare_config(struct io_ctx_config *config);
  149. bool io_cqe_cache_refill(struct io_ring_ctx *ctx, bool overflow, bool cqe32);
  150. void io_req_defer_failed(struct io_kiocb *req, s32 res);
  151. bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags);
  152. void io_add_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags);
  153. bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags);
  154. bool io_req_post_cqe32(struct io_kiocb *req, struct io_uring_cqe src_cqe[2]);
  155. void __io_commit_cqring_flush(struct io_ring_ctx *ctx);
  156. unsigned io_linked_nr(struct io_kiocb *req);
  157. void io_req_track_inflight(struct io_kiocb *req);
  158. struct file *io_file_get_normal(struct io_kiocb *req, int fd);
  159. struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
  160. unsigned issue_flags);
  161. void io_req_task_queue(struct io_kiocb *req);
  162. void io_req_task_complete(struct io_tw_req tw_req, io_tw_token_t tw);
  163. void io_req_task_queue_fail(struct io_kiocb *req, int ret);
  164. void io_req_task_submit(struct io_tw_req tw_req, io_tw_token_t tw);
  165. __cold void io_uring_drop_tctx_refs(struct task_struct *task);
  166. int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file,
  167. int start, int end);
  168. void io_req_queue_iowq(struct io_kiocb *req);
  169. int io_poll_issue(struct io_kiocb *req, io_tw_token_t tw);
  170. int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr);
  171. int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin);
  172. __cold void io_iopoll_try_reap_events(struct io_ring_ctx *ctx);
  173. void __io_submit_flush_completions(struct io_ring_ctx *ctx);
  174. struct io_wq_work *io_wq_free_work(struct io_wq_work *work);
  175. void io_wq_submit_work(struct io_wq_work *work);
  176. void io_free_req(struct io_kiocb *req);
  177. void io_queue_next(struct io_kiocb *req);
  178. void io_task_refs_refill(struct io_uring_task *tctx);
  179. bool __io_alloc_req_refill(struct io_ring_ctx *ctx);
  180. void io_activate_pollwq(struct io_ring_ctx *ctx);
  181. void io_restriction_clone(struct io_restriction *dst, struct io_restriction *src);
  182. static inline void io_lockdep_assert_cq_locked(struct io_ring_ctx *ctx)
  183. {
  184. #if defined(CONFIG_PROVE_LOCKING)
  185. lockdep_assert(in_task());
  186. if (ctx->flags & IORING_SETUP_DEFER_TASKRUN)
  187. lockdep_assert_held(&ctx->uring_lock);
  188. if (ctx->flags & IORING_SETUP_IOPOLL) {
  189. lockdep_assert_held(&ctx->uring_lock);
  190. } else if (!ctx->task_complete) {
  191. lockdep_assert_held(&ctx->completion_lock);
  192. } else if (ctx->submitter_task) {
  193. /*
  194. * ->submitter_task may be NULL and we can still post a CQE,
  195. * if the ring has been setup with IORING_SETUP_R_DISABLED.
  196. * Not from an SQE, as those cannot be submitted, but via
  197. * updating tagged resources.
  198. */
  199. if (!percpu_ref_is_dying(&ctx->refs))
  200. lockdep_assert(current == ctx->submitter_task);
  201. }
  202. #endif
  203. }
  204. static inline bool io_is_compat(struct io_ring_ctx *ctx)
  205. {
  206. return IS_ENABLED(CONFIG_COMPAT) && unlikely(ctx->compat);
  207. }
  208. static inline void io_submit_flush_completions(struct io_ring_ctx *ctx)
  209. {
  210. if (!wq_list_empty(&ctx->submit_state.compl_reqs) ||
  211. ctx->submit_state.cq_flush)
  212. __io_submit_flush_completions(ctx);
  213. }
  214. #define io_for_each_link(pos, head) \
  215. for (pos = (head); pos; pos = pos->link)
  216. static inline bool io_get_cqe_overflow(struct io_ring_ctx *ctx,
  217. struct io_uring_cqe **ret,
  218. bool overflow, bool cqe32)
  219. {
  220. io_lockdep_assert_cq_locked(ctx);
  221. if (unlikely(ctx->cqe_sentinel - ctx->cqe_cached < (cqe32 + 1))) {
  222. if (unlikely(!io_cqe_cache_refill(ctx, overflow, cqe32)))
  223. return false;
  224. }
  225. *ret = ctx->cqe_cached;
  226. ctx->cached_cq_tail++;
  227. ctx->cqe_cached++;
  228. if (ctx->flags & IORING_SETUP_CQE32) {
  229. ctx->cqe_cached++;
  230. } else if (cqe32 && ctx->flags & IORING_SETUP_CQE_MIXED) {
  231. ctx->cqe_cached++;
  232. ctx->cached_cq_tail++;
  233. }
  234. WARN_ON_ONCE(ctx->cqe_cached > ctx->cqe_sentinel);
  235. return true;
  236. }
  237. static inline bool io_get_cqe(struct io_ring_ctx *ctx, struct io_uring_cqe **ret,
  238. bool cqe32)
  239. {
  240. return io_get_cqe_overflow(ctx, ret, false, cqe32);
  241. }
  242. static inline bool io_defer_get_uncommited_cqe(struct io_ring_ctx *ctx,
  243. struct io_uring_cqe **cqe_ret)
  244. {
  245. io_lockdep_assert_cq_locked(ctx);
  246. ctx->submit_state.cq_flush = true;
  247. return io_get_cqe(ctx, cqe_ret, ctx->flags & IORING_SETUP_CQE_MIXED);
  248. }
  249. static __always_inline bool io_fill_cqe_req(struct io_ring_ctx *ctx,
  250. struct io_kiocb *req)
  251. {
  252. bool is_cqe32 = req->cqe.flags & IORING_CQE_F_32;
  253. struct io_uring_cqe *cqe;
  254. /*
  255. * If we can't get a cq entry, userspace overflowed the submission
  256. * (by quite a lot).
  257. */
  258. if (unlikely(!io_get_cqe(ctx, &cqe, is_cqe32)))
  259. return false;
  260. memcpy(cqe, &req->cqe, sizeof(*cqe));
  261. if (ctx->flags & IORING_SETUP_CQE32 || is_cqe32) {
  262. memcpy(cqe->big_cqe, &req->big_cqe, sizeof(*cqe));
  263. memset(&req->big_cqe, 0, sizeof(req->big_cqe));
  264. }
  265. if (trace_io_uring_complete_enabled())
  266. trace_io_uring_complete(req->ctx, req, cqe);
  267. return true;
  268. }
  269. static inline void req_set_fail(struct io_kiocb *req)
  270. {
  271. req->flags |= REQ_F_FAIL;
  272. if (req->flags & REQ_F_CQE_SKIP) {
  273. req->flags &= ~REQ_F_CQE_SKIP;
  274. req->flags |= REQ_F_SKIP_LINK_CQES;
  275. }
  276. }
  277. static inline void io_req_set_res(struct io_kiocb *req, s32 res, u32 cflags)
  278. {
  279. req->cqe.res = res;
  280. req->cqe.flags = cflags;
  281. }
  282. static inline u32 ctx_cqe32_flags(struct io_ring_ctx *ctx)
  283. {
  284. if (ctx->flags & IORING_SETUP_CQE_MIXED)
  285. return IORING_CQE_F_32;
  286. return 0;
  287. }
  288. static inline void io_req_set_res32(struct io_kiocb *req, s32 res, u32 cflags,
  289. __u64 extra1, __u64 extra2)
  290. {
  291. req->cqe.res = res;
  292. req->cqe.flags = cflags | ctx_cqe32_flags(req->ctx);
  293. req->big_cqe.extra1 = extra1;
  294. req->big_cqe.extra2 = extra2;
  295. }
  296. static inline void *io_uring_alloc_async_data(struct io_alloc_cache *cache,
  297. struct io_kiocb *req)
  298. {
  299. if (cache) {
  300. req->async_data = io_cache_alloc(cache, GFP_KERNEL);
  301. } else {
  302. const struct io_issue_def *def = &io_issue_defs[req->opcode];
  303. WARN_ON_ONCE(!def->async_size);
  304. req->async_data = kmalloc(def->async_size, GFP_KERNEL);
  305. }
  306. if (req->async_data)
  307. req->flags |= REQ_F_ASYNC_DATA;
  308. return req->async_data;
  309. }
  310. static inline bool req_has_async_data(struct io_kiocb *req)
  311. {
  312. return req->flags & REQ_F_ASYNC_DATA;
  313. }
  314. static inline void io_req_async_data_clear(struct io_kiocb *req,
  315. io_req_flags_t extra_flags)
  316. {
  317. req->flags &= ~(REQ_F_ASYNC_DATA|extra_flags);
  318. req->async_data = NULL;
  319. }
  320. static inline void io_req_async_data_free(struct io_kiocb *req)
  321. {
  322. kfree(req->async_data);
  323. io_req_async_data_clear(req, 0);
  324. }
  325. static inline void io_put_file(struct io_kiocb *req)
  326. {
  327. if (!(req->flags & REQ_F_FIXED_FILE) && req->file)
  328. fput(req->file);
  329. }
  330. static inline void io_ring_submit_unlock(struct io_ring_ctx *ctx,
  331. unsigned issue_flags)
  332. {
  333. lockdep_assert_held(&ctx->uring_lock);
  334. if (unlikely(issue_flags & IO_URING_F_UNLOCKED))
  335. mutex_unlock(&ctx->uring_lock);
  336. }
  337. static inline void io_ring_submit_lock(struct io_ring_ctx *ctx,
  338. unsigned issue_flags)
  339. {
  340. /*
  341. * "Normal" inline submissions always hold the uring_lock, since we
  342. * grab it from the system call. Same is true for the SQPOLL offload.
  343. * The only exception is when we've detached the request and issue it
  344. * from an async worker thread, grab the lock for that case.
  345. */
  346. if (unlikely(issue_flags & IO_URING_F_UNLOCKED))
  347. mutex_lock(&ctx->uring_lock);
  348. lockdep_assert_held(&ctx->uring_lock);
  349. }
  350. static inline void io_commit_cqring(struct io_ring_ctx *ctx)
  351. {
  352. /* order cqe stores with ring update */
  353. smp_store_release(&ctx->rings->cq.tail, ctx->cached_cq_tail);
  354. }
  355. static inline void __io_wq_wake(struct wait_queue_head *wq)
  356. {
  357. /*
  358. *
  359. * Pass in EPOLLIN|EPOLL_URING_WAKE as the poll wakeup key. The latter
  360. * set in the mask so that if we recurse back into our own poll
  361. * waitqueue handlers, we know we have a dependency between eventfd or
  362. * epoll and should terminate multishot poll at that point.
  363. */
  364. if (wq_has_sleeper(wq))
  365. __wake_up(wq, TASK_NORMAL, 0, poll_to_key(EPOLL_URING_WAKE | EPOLLIN));
  366. }
  367. static inline void io_poll_wq_wake(struct io_ring_ctx *ctx)
  368. {
  369. __io_wq_wake(&ctx->poll_wq);
  370. }
  371. static inline void io_cqring_wake(struct io_ring_ctx *ctx)
  372. {
  373. /*
  374. * Trigger waitqueue handler on all waiters on our waitqueue. This
  375. * won't necessarily wake up all the tasks, io_should_wake() will make
  376. * that decision.
  377. */
  378. __io_wq_wake(&ctx->cq_wait);
  379. }
  380. static inline bool __io_sqring_full(struct io_ring_ctx *ctx)
  381. {
  382. struct io_rings *r = io_get_rings(ctx);
  383. /*
  384. * SQPOLL must use the actual sqring head, as using the cached_sq_head
  385. * is race prone if the SQPOLL thread has grabbed entries but not yet
  386. * committed them to the ring. For !SQPOLL, this doesn't matter, but
  387. * since this helper is just used for SQPOLL sqring waits (or POLLOUT),
  388. * just read the actual sqring head unconditionally.
  389. */
  390. return READ_ONCE(r->sq.tail) - READ_ONCE(r->sq.head) == ctx->sq_entries;
  391. }
  392. static inline bool io_sqring_full(struct io_ring_ctx *ctx)
  393. {
  394. guard(rcu)();
  395. return __io_sqring_full(ctx);
  396. }
  397. static inline unsigned int __io_sqring_entries(struct io_ring_ctx *ctx)
  398. {
  399. struct io_rings *rings = io_get_rings(ctx);
  400. unsigned int entries;
  401. /* make sure SQ entry isn't read before tail */
  402. entries = smp_load_acquire(&rings->sq.tail) - ctx->cached_sq_head;
  403. return min(entries, ctx->sq_entries);
  404. }
  405. static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx)
  406. {
  407. guard(rcu)();
  408. return __io_sqring_entries(ctx);
  409. }
  410. /*
  411. * Don't complete immediately but use deferred completion infrastructure.
  412. * Protected by ->uring_lock and can only be used either with
  413. * IO_URING_F_COMPLETE_DEFER or inside a tw handler holding the mutex.
  414. */
  415. static inline void io_req_complete_defer(struct io_kiocb *req)
  416. __must_hold(&req->ctx->uring_lock)
  417. {
  418. struct io_submit_state *state = &req->ctx->submit_state;
  419. lockdep_assert_held(&req->ctx->uring_lock);
  420. wq_list_add_tail(&req->comp_list, &state->compl_reqs);
  421. }
  422. static inline void io_commit_cqring_flush(struct io_ring_ctx *ctx)
  423. {
  424. if (unlikely(ctx->off_timeout_used ||
  425. ctx->has_evfd || ctx->poll_activated))
  426. __io_commit_cqring_flush(ctx);
  427. }
  428. static inline void io_get_task_refs(int nr)
  429. {
  430. struct io_uring_task *tctx = current->io_uring;
  431. tctx->cached_refs -= nr;
  432. if (unlikely(tctx->cached_refs < 0))
  433. io_task_refs_refill(tctx);
  434. }
  435. static inline bool io_req_cache_empty(struct io_ring_ctx *ctx)
  436. {
  437. return !ctx->submit_state.free_list.next;
  438. }
  439. extern struct kmem_cache *req_cachep;
  440. static inline struct io_kiocb *io_extract_req(struct io_ring_ctx *ctx)
  441. {
  442. struct io_kiocb *req;
  443. req = container_of(ctx->submit_state.free_list.next, struct io_kiocb, comp_list);
  444. wq_stack_extract(&ctx->submit_state.free_list);
  445. return req;
  446. }
  447. static inline bool io_alloc_req(struct io_ring_ctx *ctx, struct io_kiocb **req)
  448. {
  449. if (unlikely(io_req_cache_empty(ctx))) {
  450. if (!__io_alloc_req_refill(ctx))
  451. return false;
  452. }
  453. *req = io_extract_req(ctx);
  454. return true;
  455. }
  456. static inline void io_req_queue_tw_complete(struct io_kiocb *req, s32 res)
  457. {
  458. io_req_set_res(req, res, 0);
  459. req->io_task_work.func = io_req_task_complete;
  460. io_req_task_work_add(req);
  461. }
  462. static inline bool io_file_can_poll(struct io_kiocb *req)
  463. {
  464. if (req->flags & REQ_F_CAN_POLL)
  465. return true;
  466. if (req->file && file_can_poll(req->file)) {
  467. req->flags |= REQ_F_CAN_POLL;
  468. return true;
  469. }
  470. return false;
  471. }
  472. static inline bool io_is_uring_cmd(const struct io_kiocb *req)
  473. {
  474. return req->opcode == IORING_OP_URING_CMD ||
  475. req->opcode == IORING_OP_URING_CMD128;
  476. }
  477. static inline ktime_t io_get_time(struct io_ring_ctx *ctx)
  478. {
  479. if (ctx->clockid == CLOCK_MONOTONIC)
  480. return ktime_get();
  481. return ktime_get_with_offset(ctx->clock_offset);
  482. }
  483. enum {
  484. IO_CHECK_CQ_OVERFLOW_BIT,
  485. IO_CHECK_CQ_DROPPED_BIT,
  486. };
  487. static inline bool io_has_work(struct io_ring_ctx *ctx)
  488. {
  489. return test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq) ||
  490. io_local_work_pending(ctx);
  491. }
  492. #endif