mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hang Zhengyang <hang.zhengyang1010@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Tao Cui <cui.tao@linux.dev>,
	io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] io_uring: charge request async data and iovec arrays to memcg
Date: Sun,  6 Dec 2026 10:04:47 +0000	[thread overview]
Message-ID: <20261206100449.2060856-1-hang.zhengyang1010@gmail.com> (raw)

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


             reply	other threads:[~2026-12-06 10:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06 10:04 Hang Zhengyang [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206100449.2060856-1-hang.zhengyang1010@gmail.com \
    --to=hang.zhengyang1010@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=cui.tao@linux.dev \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®