From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796551495; b=R1IwVWUiOK4x1N8VSCiTaW7loMER117dNyB1Yo0hX1NsL455vqewB6aWxF3lLYH0DRW2 1FDmwla0mtOdTAJC4gf1jtB5/udIlO19YXr897z9LBFEe7GSaBaVTiWDe94nHN9f5iF5n u4ltGdggdA0cvYoqMB2JzCk3hrTBQp9A1XjyhWwkCCI2Zo+4z188nwxBPIveKdF5VWeSu 1cemHEfKwrlf8iJzDKM7j21mGxIrAVbNxmN0bwQxR1P4rPHJoTZbE8rBQR49osDXRnxTz 4jI8hRIJq1KBXT/h7OtpdJ4CwQSWg8ffM05DQOj+7maOIa0TFGRPvpkYb4/KCUv/l8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796551495; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=SjvAYSauOjY2G6CBkRKbFbTPM5sS4PqmGW1fNyzx34s=; b=u2JJ+TiU7ohQSWxoPUS+B8KoA4IXXxLfj7t4JbwBxIttljTs3bXHPUPxrnRfGw+fSmwb D7naVsYpr5jow/7/6IOkeKAmPbaBnDeoE3rQGwXUTM+b6y3C6S7kz9GjpjrbwEjKM1jRc wpYx7oTolVUk+qYwCfMi0YWd4Xpv7rybqzyn/oZ/A2sDqQ3c0K/lcYErQn2urjr+6BWvg 8Mhmv5s1Kx/Ncqq3xwGmdWQNALIcTG0ftbmqJcS+eVS66+Yet8dBBDfpfDJcmRjsDKBmg z14uttKZWQkZ5rm/7++iEDWFr1wyFaony9gHJNQyzGN15MwFGGxXe71xGM5Ky3zt8+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=p8y1KVZu; arc=none smtp.remote-ip=74.125.82.50 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61E5A606A321 for ; Sun, 6 Dec 2026 10:04:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61E5A606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=p8y1KVZu Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1a3c08d6928so3524499c88.0 for ; Sun, 06 Dec 2026 02:04:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796551494; x=1797156294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=SjvAYSauOjY2G6CBkRKbFbTPM5sS4PqmGW1fNyzx34s=; b=p8y1KVZumT6aCwwt964hpDXbL9osViguafkIZPyM9kgyGpvFviALDiZJAdFQ9Eutdt 97xdBR6mxUheKdexpaC5x/DB+c6dmCm/Mi/Uvvq1GgWBP2nbJHkD3sILk0AWBj7o5zVG GtbmwkGJ6z3pAT4Z0EdapXXYbjtAwdaKGrRjC51g29vCKrR3Jn2UIJi8EtYErPd7YGt4 5UgLkm335lk4scB3XIea2Hn8M/cCD1sP3pV0mtUAq8lHn9iG/evf9khRE4XGl2q7Gx1Z YYhFZy8+myQkszoCrQEI6WJsTMIPmGO7XQrtCnJathW+w5OEEfTNSOQbBH1zT7cMF0eE TgJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796551494; x=1797156294; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SjvAYSauOjY2G6CBkRKbFbTPM5sS4PqmGW1fNyzx34s=; b=ze3ue3BU0EG5DrnPl7cxrdVHg/LCu7onhZum300d6mSF3T/XVmYns7gHVrnI8Bpe9V r5Vf+adN/YFhvKEORU3iDBc/lePkEbmfdE1Kj+iTtFI0o9/MxsJSrNjBPCe09oWjJ3b6 E8grTNA7u2NMkOFai5aCoIFqetl1B749IwbrV+vW+n8ax3KrWjY8sSScMLcVth+2YOQC H8TObhfo1Nd+aLwx3ZDa/r0S02COwF4/2RS8MxArS0DjZzaAWoTWMYJaTWAheEJ3c5cz 9MaHLPUNu0HNo3K3ibCdwwf/qCRyHn9aK6FVX6MXE36K6PjQtwdKbzGLswsCnYhmBSAe ZRqg== X-Forwarded-Encrypted: i=1; AL+hErFlSSLqdR7AlbvCfkgcLOxV0LOEvgeaiRgb17+hRfLNE9Js58GwNrWSu6+sg/4IkXAhaH0S8zzmokA/Zig=@vger.kernel.org X-Gm-Message-State: APuU4Z/TIeYq5N2cGk3lR4l8nunLxT9/4g3DeF42Sd3+d3ixqYBvbG5e BdKIluG+3DbA8uHli81h4v7qtnjTAhJtMhmlL5fuL8UKyx2KQOOg055e/eKiX0dlvbqdgA== X-Gm-Gg: AZFdTZdJV9hcYWaa+c/EXhyfUHjl/XPQCyNgzIVOGxnwpQRA81oJLBvXjBasUtpSvjd rYn8peQM0ddesP+knitanulYTQq61zY0kMaGGiOMgBHd4vJOYEPGEsN0/Bay0zY3usIs8nmfWpO S9rczL6xj12xhYUF53uwO9grBzMa/LQqrNaHenYahp5rY7Q33Nx3UYMuswGrda3/gx7vl3ekBAW 3VvRzmOt0CGzQcuMfkWEWCALFVl/imK/FaD2XyMoMRk/nePZgGfhH8XrjDncgkGKQkloTJ5n3dX rHNJGzA5VzdIgAueZfs3Mb7EMmK0F2C8EBPvGFuOOOXDmsTuNljGS84D09fkRCdV9N2bKSdmgkG eoRmOe9/ZdAPzaO6gtPvyeQR35tMG9PXgQyZ9kqnnqvcfp8MAKKIrZBLYOUL8T7vXfyr4Qr02BH HuNKYJp1VdBmVeCfVgVVp0jmNZzmvrus/QZwDTvEUeUIgmNPSI0hdg1WhVs9VfH/xzidbF75tO+ cQQLD2JetjWqlyX+WbJrfZi99mr9+q/reRke17wyQgXGyWov3MfxXXN+x/WKIrSkqu77tK+wpoo bIQrPnjPWzEudULbNlajUiaHqn2d4hvcG68UZJuRDfDKTUqBbQ2eAA95slpPtcDLzg== X-Received: by 2002:a05:701b:4502:20b0:1b5:cf2b:e2e6 with SMTP id a92af1059eb24-1b5d7258c9fmr6980154c88.31.1796551493947; Sun, 06 Dec 2026 02:04:53 -0800 (PST) Received: from 6610b1a2ef46 ([203.116.140.24]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d64706d3sm24295789c88.13.2026.12.06.02.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 02:04:53 -0800 (PST) From: Hang Zhengyang To: Jens Axboe Cc: Tao Cui , 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 Message-ID: <20261206100449.2060856-1-hang.zhengyang1010@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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