Commit e8375e43 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: consolidate hash_locked io-wq handling

Don't duplicate code disabling REQ_F_HASH_LOCKED for IO_URING_F_UNLOCKED
(i.e. io-wq), move the handling into __io_arm_poll_handler().
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/0ff0ffdfaa65b3d536131535c3dad3c63d9b7bb0.1657203020.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b21a51e2
...@@ -523,8 +523,12 @@ static int __io_arm_poll_handler(struct io_kiocb *req, ...@@ -523,8 +523,12 @@ static int __io_arm_poll_handler(struct io_kiocb *req,
* io_poll_can_finish_inline() tries to deal with that. * io_poll_can_finish_inline() tries to deal with that.
*/ */
ipt->owning = issue_flags & IO_URING_F_UNLOCKED; ipt->owning = issue_flags & IO_URING_F_UNLOCKED;
atomic_set(&req->poll_refs, (int)ipt->owning); atomic_set(&req->poll_refs, (int)ipt->owning);
/* io-wq doesn't hold uring_lock */
if (issue_flags & IO_URING_F_UNLOCKED)
req->flags &= ~REQ_F_HASH_LOCKED;
mask = vfs_poll(req->file, &ipt->pt) & poll->events; mask = vfs_poll(req->file, &ipt->pt) & poll->events;
if (unlikely(ipt->error || !ipt->nr_entries)) { if (unlikely(ipt->error || !ipt->nr_entries)) {
...@@ -618,8 +622,7 @@ int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags) ...@@ -618,8 +622,7 @@ int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
* apoll requests already grab the mutex to complete in the tw handler, * apoll requests already grab the mutex to complete in the tw handler,
* so removal from the mutex-backed hash is free, use it by default. * so removal from the mutex-backed hash is free, use it by default.
*/ */
if (!(issue_flags & IO_URING_F_UNLOCKED)) req->flags |= REQ_F_HASH_LOCKED;
req->flags |= REQ_F_HASH_LOCKED;
if (!def->pollin && !def->pollout) if (!def->pollin && !def->pollout)
return IO_APOLL_ABORTED; return IO_APOLL_ABORTED;
...@@ -876,8 +879,7 @@ int io_poll_add(struct io_kiocb *req, unsigned int issue_flags) ...@@ -876,8 +879,7 @@ int io_poll_add(struct io_kiocb *req, unsigned int issue_flags)
* If sqpoll or single issuer, there is no contention for ->uring_lock * If sqpoll or single issuer, there is no contention for ->uring_lock
* and we'll end up holding it in tw handlers anyway. * and we'll end up holding it in tw handlers anyway.
*/ */
if (!(issue_flags & IO_URING_F_UNLOCKED) && if (req->ctx->flags & (IORING_SETUP_SQPOLL|IORING_SETUP_SINGLE_ISSUER))
(req->ctx->flags & (IORING_SETUP_SQPOLL | IORING_SETUP_SINGLE_ISSUER)))
req->flags |= REQ_F_HASH_LOCKED; req->flags |= REQ_F_HASH_LOCKED;
ret = __io_arm_poll_handler(req, poll, &ipt, poll->events, issue_flags); ret = __io_arm_poll_handler(req, poll, &ipt, poll->events, issue_flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment