From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796551497; b=5Wlr2LhU5PBHE76pY1o0rQmv+KfjfTO0DEGfVqjTQQDQQ7p7b0QvPlwVsksCCHD5UMwr yQ4OTR5zSESNr/+sP0DkFpREv/Wo7Rp9rMUonETDh+NgqaYrpuj4h5/oEIchd4W89hGqK B8uW8turBuLH4J7oQPnznE7YeVbdp57Wgab0GF+vfC8ZihwZx4iFPKuwja49ml4nGEfxj yadWFmDAEzQzUsPMfv8L9orj1NpzE/O2ULqee5XYVZFrdhSF6UelAtar8ox2vMZSctG01 h79+Os1UWKwKHzZZp0X1czFF45LCM2k4ccfl2Tlx3+S5sIT6hPOc8EN8+6Y5rKjrmNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796551497; 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:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=WN3AcsHou+sTL+PfM8qLzmwGwpFDK/iXWzXydDVibIU=; b=pWlvZl7hopOA7o06Fvh8VT0ppCuZloMaPJmu0sLhMPmZhpowftdojoq5k2KNcyY5FiYN 4TEg0fL+2hCX1FMPDW1vd4FlaNCr077+MVkGFeiZBsCphE2LPYxzB2JCswmwFT263zSF9 NikXxHR6skAs7oBbBBxiWf+7Sn6Zi3cdN/LPsg9Sd/VWKYCOKU4pGW0u2Qb34p8jpOgFw nxo62Vuz4uqyzqfgYhASNU3frqZLk0MW+FGD9sz8m7ZiwMHROVh6qtWd2xTRrl5Yyyhvi YQYcBglcsmQHPi933kTtvNNGAUHltM6deYmZL+qGETTaleTm1AA46wWWOSSxaB29L7Q== 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=nZpxKvfS; arc=none smtp.remote-ip=74.125.82.46 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (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 1D6FF606A339 for ; Sun, 6 Dec 2026 10:04:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1D6FF606A339 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=nZpxKvfS Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-1b5d5f5a5adso4665682c88.1 for ; Sun, 06 Dec 2026 02:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796551496; x=1797156296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WN3AcsHou+sTL+PfM8qLzmwGwpFDK/iXWzXydDVibIU=; b=nZpxKvfSY/+uAbaPTWU3hMhSqgeB9pF7QWJ3pwLKnVN1YfclukY6rpJMLuDpmY5i5r 7Fkd47EummiUPzqdbZ0j97xL9f4o++zlLCMu3zlJ1gQ7MHeMeiaC4kZRS7l4aO7HoLOP Mft2P7vF2Fv+UaXxUUmkXFFG63Ta5qcMqbrafs1HUq1ZrubHdrrqYHVFVcS5JUaS+Zp6 ue/kHgDwyeGQHU4Bbgh5fKVRj9hjmEmulYSBLRRTMeesojO/Q66j1obznhxLnot/E2Pz RL45PQOSWqyjq6LziFkt4krwiDOkt0fsMSXu4OgRL28LsxCEp9shZ07OoYBvga+lD+nI 1CYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796551496; x=1797156296; h=content-transfer-encoding:mime-version:references:in-reply-to :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=WN3AcsHou+sTL+PfM8qLzmwGwpFDK/iXWzXydDVibIU=; b=C0N/VFNOAD5vxLQ8N6mGcLLo9toKWAv4ww2w+dBi7vQcqEPKhKBYI+I2411mR4sQzg KYx1octlbDq9Dn8JxahvTVAuZpSexPhbuYdqxLcTLVuqOLsJzjlozaBHad/K9aWYJ4fp DkeqT37brh1JCRzi0H//gRxP89G09oQhjQ1cKdaC68riu7zVYHIkV1LPfygjykYOX7JO Vu294HcezskkYrQMIr6AKZNnSyJbFBpX+UOkjIn/DXZzT54h3IzpocwQCJCh8oOs317F uPuGljmYbZKckEdy0ePDQyXx1WcVPAk0UvCmdbpJBwX8HBC/c+lDx29ibMvAAPSOs0WO 4BHg== X-Forwarded-Encrypted: i=1; AL+hErGp5LweL8tL18jqq7Tra0bmml+tYcxEv8Pf/cBmGh0tIZYpq1yq7AlA+N7LH/IyxKVrSXs8LxShc8Mk15E=@vger.kernel.org X-Gm-Message-State: APuU4Z/hWCnv4yfE7CN1QUDa9FB7DQ025Q1tdMCji7XWf9vErr4Um4XJ wJcMilVFj/Tzjlv7TiO/uhISVmdhfSRJDrwtMklMFh9DlbQIdhFsY2kq X-Gm-Gg: AZFdTZeoG/A+ukmabx86VB+2XTp2SZWo5ojqL5E71TqyEBlEbcFbIjX4vEYeWUvHJoW 1TI/xTLqNtunggUxi59zuru0i1BRe68SkvPam0uCbXPSONsVye66+mPlN+D1MMcAAyjScfAtUux +yPS6BECuIyFjt9EjQ/CLJ5qmadRXWGv1RgPejHrYGYNLOiUr/oEpelyub314SEleE81cW56Ix5 9FvxU6pJ9AJw3ZenrI1T7dNIJyvNxFz40sGJJmMwt6SogEle9e9qkvWRkSHc37Eg8Wx89bHGDhJ XFuQIRxWMBQH6Rknl1mAVw5CoBu+QfT+qsRbHb4jmazIa7ZrQ4eJTckcrIWLATO5zK9gl72ICn2 VBBcFMknkhfuPRMFsf1qJJAQ5JxoeQXWo67xdGFVjZGiNVJ7lqu2ydhdV7a0FwJw48xAoJb9p9N g604AfkbfEzidvo94CftKDUVzXEzfZEgBdCEcIehZ8vQKz+H27Wl6zHG8PLrpmCYsZckb+gcAIA 0UEVZMq4ZtwXEnlQ4457kBdWHn59rOmWyqPhrUfKvshlNnBtABcPsPnc6RL/G7VIH1yckICaCqJ Wz2Je9zeuUQiqIAY5VK4urRzc+SFLciu30eAw0gPuOkrAy9vqGcDKdSo3+HYFVWXOQ== X-Received: by 2002:a05:7023:e4d:10b0:1b5:87bb:e4c3 with SMTP id a92af1059eb24-1b5d70c08efmr6896743c88.9.1796551495707; Sun, 06 Dec 2026 02:04:55 -0800 (PST) Received: from 6610b1a2ef46 ([203.116.140.24]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d64706d3sm24295789c88.13.2026.12.06.02.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 02:04:55 -0800 (PST) From: Hang Zhengyang To: Jens Axboe Cc: Tao Cui , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] io_uring: charge request async data to memcg Date: Sun, 6 Dec 2026 10:04:48 +0000 Message-ID: <20261206100449.2060856-2-hang.zhengyang1010@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261206100449.2060856-1-hang.zhengyang1010@gmail.com> References: <20261206100449.2060856-1-hang.zhengyang1010@gmail.com> 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 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