Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/zctx: separate notification user_data

People previously asked for the notification CQE to have a different
user_data value from the main request completion. It's useful to
separate buffer and request handling logic and avoid separately
refcounting the request.

Let the user pass the notification user_data in sqe->addr3. If zero,
it'll inherit sqe->user_data as before. It doesn't change the rules for
when the user can expect a notification CQE, and it should still check
the IORING_CQE_F_MORE flag.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
cb948733 dce00c83

+7 -2
+7 -2
io_uring/net.c
··· 1333 1333 struct io_ring_ctx *ctx = req->ctx; 1334 1334 struct io_async_msghdr *iomsg; 1335 1335 struct io_kiocb *notif; 1336 + u64 user_data; 1336 1337 int ret; 1337 1338 1338 1339 zc->done_io = 0; 1339 1340 1340 - if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3))) 1341 + if (unlikely(READ_ONCE(sqe->__pad2[0]))) 1341 1342 return -EINVAL; 1342 1343 /* we don't support IOSQE_CQE_SKIP_SUCCESS just yet */ 1343 1344 if (req->flags & REQ_F_CQE_SKIP) ··· 1347 1346 notif = zc->notif = io_alloc_notif(ctx); 1348 1347 if (!notif) 1349 1348 return -ENOMEM; 1350 - notif->cqe.user_data = req->cqe.user_data; 1349 + user_data = READ_ONCE(sqe->addr3); 1350 + if (!user_data) 1351 + user_data = req->cqe.user_data; 1352 + 1353 + notif->cqe.user_data = user_data; 1351 1354 notif->cqe.res = 0; 1352 1355 notif->cqe.flags = IORING_CQE_F_NOTIF; 1353 1356 req->flags |= REQ_F_NEED_CLEANUP | REQ_F_POLL_NO_LAZY;