Skip to content

Commit

Permalink
io_uring: account locked pages for non-fixed zc
Browse files Browse the repository at this point in the history
Fixed buffers are RLIMIT_MEMLOCK accounted, however it doesn't cover iovec
based zerocopy sends. Do the accounting on the io_uring side.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/19b6e3975440f59f1f6199c7ee7acf977b4eecdc.1657643355.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed Jul 25, 2022
1 parent 06a5464 commit e29e3bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions io_uring/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
ret = import_single_range(WRITE, zc->buf, zc->len, &iov, &msg.msg_iter);
if (unlikely(ret))
return ret;
mm_account_pinned_pages(&notif->uarg.mmp, zc->len);

msg_flags = zc->msg_flags | MSG_ZEROCOPY;
if (issue_flags & IO_URING_F_NONBLOCK)
Expand Down
6 changes: 6 additions & 0 deletions io_uring/notif.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ static void __io_notif_complete_tw(struct callback_head *cb)
struct io_notif *notif = container_of(cb, struct io_notif, task_work);
struct io_rsrc_node *rsrc_node = notif->rsrc_node;
struct io_ring_ctx *ctx = notif->ctx;
struct mmpin *mmp = &notif->uarg.mmp;

if (mmp->user) {
atomic_long_sub(mmp->num_pg, &mmp->user->locked_vm);
free_uid(mmp->user);
mmp->user = NULL;
}
if (likely(notif->task)) {
io_put_task(notif->task, 1);
notif->task = NULL;
Expand Down

0 comments on commit e29e3bd

Please sign in to comment.