mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] io_uring: charge request async data and iovec arrays to memcg
@ 2026-12-06 10:04 Hang Zhengyang
  2026-12-06 10:04 ` [PATCH 1/2] io_uring: charge request async data " Hang Zhengyang
  2026-12-06 10:04 ` [PATCH 2/2] io_uring: charge imported iovec arrays " Hang Zhengyang
  0 siblings, 2 replies; 3+ messages in thread
From: Hang Zhengyang @ 2026-12-06 10:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Tao Cui, io-uring, linux-kernel

Requests that wait, such as readv requests on an empty pipe, hold
allocations that aren't charged to memcg, so a cgroup can hold several
times its memory.max in unreclaimable slab. Patch 1 charges the async
data, and patch 2 the iovec arrays that vectored requests import.

The poll entries and the data of a single futex wait stay uncharged.
They are allocated with GFP_ATOMIC and GFP_NOWAIT. With __GFP_ACCOUNT,
the first is charged past memory.max, and the second fails there without
reclaiming, even if the cgroup holds reclaimable page cache.

Tested on for-7.5/io_uring in a KVM guest without KASAN or lockdep, as
an unprivileged task in a cgroup with memory.max at 64MiB. Each run
queues requests that wait: reads and readv on an empty pipe, or recvmsg
on an empty socketpair. The table shows the growth of the cgroup's
slab_unreclaimable out of the growth of the system's SUnreclaim, in MiB:

                                      unpatched      both patches
  50000 reads                         12.6 of 28.8   25.2 of 29.4
  2000 readv, 1024 iovecs each        0.5 of 32.4    32.2 of 32.2
  2000 recvmsg, 1024 iovecs each      0.0 of 32.7    32.7 of 32.8
  40000 readv, 1024 iovecs each       10.1 of 648    OOM-killed in
                                                     the cgroup

The full liburing suite shows no new failures, on this kernel and on one
with KASAN and lockdep. The charge was not measured for compat iovecs,
writev, sendmsg and vectored sends.

Tao Cui's io_uring patches [1][2] charge other allocations and don't
touch these.

Found, fixed and tested by Claude Code, I handled the review process.

[1] https://lore.kernel.org/io-uring/20261106131829.3228926-7-cui.tao@linux.dev/
[2] https://lore.kernel.org/io-uring/20261106131829.3228926-8-cui.tao@linux.dev/

Hang Zhengyang (2):
  io_uring: charge request async data to memcg
  io_uring: charge imported iovec arrays to memcg

 io_uring/io_uring.h |  4 ++--
 io_uring/net.c      |  4 ++++
 io_uring/rsrc.h     | 12 ++++++++++++
 io_uring/rw.c       |  4 ++++
 4 files changed, 22 insertions(+), 2 deletions(-)


base-commit: 416f1d31a8acea8b45b5da50e78147b83ccf63a8
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-06 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-06 10:04 [PATCH 0/2] io_uring: charge request async data and iovec arrays to memcg Hang Zhengyang
2026-12-06 10:04 ` [PATCH 1/2] io_uring: charge request async data " Hang Zhengyang
2026-12-06 10:04 ` [PATCH 2/2] io_uring: charge imported iovec arrays " Hang Zhengyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®