The io_kiocb of a request is charged to memcg, but its async data is usually allocated with plain GFP_KERNEL. A request that waits, such as a read on an empty pipe, holds its async data until it completes. 50000 such reads took 29MiB of unreclaimable slab, of which 13MiB was charged. Use GFP_KERNEL_ACCOUNT, as commit 6e0d71c288fd ("io_uring/futex: use GFP_KERNEL_ACCOUNT for futex data allocation") did for futexv. Both async data allocations could already sleep, so at memory.max the charge reclaims like any other. Found, fixed and tested by Claude Code, I handled the review process. Signed-off-by: Hang Zhengyang --- io_uring/io_uring.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index ef30ddf4cbf7..d5a9534a4bb0 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -343,7 +343,7 @@ static inline bool io_uring_alloc_cached_async_data(struct io_alloc_cache *cache, struct io_kiocb *req) { - if (!io_cache_alloc(cache, GFP_KERNEL, &req->async_data)) + if (!io_cache_alloc(cache, GFP_KERNEL_ACCOUNT, &req->async_data)) return false; io_req_set_flags(req, REQ_F_ASYNC_DATA); @@ -355,7 +355,7 @@ static inline void *io_uring_alloc_async_data(struct io_kiocb *req) const struct io_issue_def *def = &io_issue_defs[req->opcode]; WARN_ON_ONCE(!def->async_size); - req->async_data = kmalloc(def->async_size, GFP_KERNEL); + req->async_data = kmalloc(def->async_size, GFP_KERNEL_ACCOUNT); if (req->async_data) io_req_set_flags(req, REQ_F_ASYNC_DATA); return req->async_data; -- 2.53.0