Commit 443e5755 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe
Browse files

io_uring: combine poll tw handlers



Merge apoll and regular poll tw handlers, it will help with inlining.

Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/482e59edb9fc81bd275fdbf486837330fb27120a.1669821213.git.asml.silence@gmail.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c3bfb57e
Loading
Loading
Loading
Loading
+21 −33
Original line number Diff line number Diff line
@@ -321,33 +321,24 @@ static void io_poll_task_func(struct io_kiocb *req, bool *locked)
	ret = io_poll_check_events(req, locked);
	if (ret == IOU_POLL_NO_ACTION)
		return;
	io_poll_remove_entries(req);
	io_poll_tw_hash_eject(req, locked);

	if (req->opcode == IORING_OP_POLL_ADD) {
		if (ret == IOU_POLL_DONE) {
		struct io_poll *poll = io_kiocb_to_cmd(req, struct io_poll);
			struct io_poll *poll;

			poll = io_kiocb_to_cmd(req, struct io_poll);
			req->cqe.res = mangle_poll(req->cqe.res & poll->events);
		} else if (ret != IOU_POLL_REMOVE_POLL_USE_RES) {
			req->cqe.res = ret;
			req_set_fail(req);
		}

	io_poll_remove_entries(req);
	io_poll_tw_hash_eject(req, locked);

		io_req_set_res(req, req->cqe.res, 0);
		io_req_task_complete(req, locked);
}

static void io_apoll_task_func(struct io_kiocb *req, bool *locked)
{
	int ret;

	ret = io_poll_check_events(req, locked);
	if (ret == IOU_POLL_NO_ACTION)
		return;

	} else {
		io_tw_lock(req->ctx, locked);
	io_poll_remove_entries(req);
	io_poll_tw_hash_eject(req, locked);

		if (ret == IOU_POLL_REMOVE_POLL_USE_RES)
			io_req_task_complete(req, locked);
@@ -356,15 +347,12 @@ static void io_apoll_task_func(struct io_kiocb *req, bool *locked)
		else
			io_req_defer_failed(req, ret);
	}
}

static void __io_poll_execute(struct io_kiocb *req, int mask)
{
	io_req_set_res(req, mask, 0);

	if (req->opcode == IORING_OP_POLL_ADD)
	req->io_task_work.func = io_poll_task_func;
	else
		req->io_task_work.func = io_apoll_task_func;

	trace_io_uring_task_add(req, mask);
	io_req_task_work_add(req);