[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bf6aa4f9-7c6f-4e28-88c0-0e20c5e4a854@gmail.com>
Date: Sat, 31 May 2025 11:28:48 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: io-uring@...r.kernel.org, Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Cc: netdev@...r.kernel.org, Eric Dumazet <edumazet@...gle.com>,
Kuniyuki Iwashima <kuniyu@...zon.com>, Paolo Abeni <pabeni@...hat.com>,
Willem de Bruijn <willemb@...gle.com>, "David S . Miller"
<davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Richard Cochran <richardcochran@...il.com>
Subject: Re: [PATCH 2/5] io_uring/poll: introduce io_arm_apoll()
On 5/30/25 13:18, Pavel Begunkov wrote:
> In preparation to allowing commands to do file polling, add a helper
> that takes the desired poll event mask and arms it for polling. We won't
> be able to use io_arm_poll_handler() with IORING_OP_URING_CMD as it
> tries to infer the mask from the opcode data, and we can't unify it
> across all commands.
>
> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
> ---
... - if (req->flags & REQ_F_CLEAR_POLLIN)
> - mask &= ~EPOLLIN;
> - } else {
> - mask |= EPOLLOUT | EPOLLWRNORM;
> - }
> - if (def->poll_exclusive)
> - mask |= EPOLLEXCLUSIVE;
> -
> apoll = io_req_alloc_apoll(req, issue_flags);
> if (!apoll)
> return IO_APOLL_ABORTED;
> @@ -712,6 +696,31 @@ int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
> return IO_APOLL_OK;
> }
>
> +int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
> +{
> + const struct io_issue_def *def = &io_issue_defs[req->opcode];
> + __poll_t mask = POLLPRI | POLLERR | EPOLLET;
> +
> + if (!def->pollin && !def->pollout)
> + return IO_APOLL_ABORTED;
> + if (!io_file_can_poll(req))
> + return IO_APOLL_ABORTED;
> +
> + if (def->pollin) {
> + mask |= EPOLLIN | EPOLLRDNORM;
> +
> + /* If reading from MSG_ERRQUEUE using recvmsg, ignore POLLIN */
> + if (req->flags & REQ_F_CLEAR_POLLIN)
> + mask &= ~EPOLLIN;
fwiw, I need to fix tabulation here
> + } else {
> + mask |= EPOLLOUT | EPOLLWRNORM;
> + }
> + if (def->poll_exclusive)
> + mask |= EPOLLEXCLUSIVE;
> +
> + return io_arm_apoll(req, issue_flags, mask);
> +}
--
Pavel Begunkov
Powered by blists - more mailing lists