summaryrefslogtreecommitdiff
path: root/io_uring/rsrc.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2022-07-25 10:52:05 +0100
committerJens Axboe <axboe@kernel.dk>2022-07-25 09:48:25 -0600
commit6a9ce66f4d0872861e0bbc67eee6ce5dca5dd886 (patch)
tree81e66222f137d24bf38d367a9d29d4e91c6dd6c5 /io_uring/rsrc.c
parent2e32ba5607ee2b668baa8831dd74f7cc867a1f7e (diff)
downloadlwn-6a9ce66f4d0872861e0bbc67eee6ce5dca5dd886.tar.gz
lwn-6a9ce66f4d0872861e0bbc67eee6ce5dca5dd886.zip
io_uring/net: make page accounting more consistent
Make network page accounting more consistent with how buffer registration is working, i.e. account all memory to ctx->user. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/4aacfe64bbb81b27f9ecf5d5c219c69a07e5aa56.1658742118.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.c')
-rw-r--r--io_uring/rsrc.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 9165fdf64269..59704b9ac537 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -44,17 +44,13 @@ void io_rsrc_refs_drop(struct io_ring_ctx *ctx)
}
}
-static inline void __io_unaccount_mem(struct user_struct *user,
- unsigned long nr_pages)
-{
- atomic_long_sub(nr_pages, &user->locked_vm);
-}
-
-static inline int __io_account_mem(struct user_struct *user,
- unsigned long nr_pages)
+int __io_account_mem(struct user_struct *user, unsigned long nr_pages)
{
unsigned long page_limit, cur_pages, new_pages;
+ if (!nr_pages)
+ return 0;
+
/* Don't allow more pages than we can safely lock */
page_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;