From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A81C395AE9 for ; Tue, 21 Jul 2026 05:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784610203; cv=none; b=VBlhJTBJi4mcY8p2QZjfPwyh5grt5cMdwnjKS5Wa89y8IY9naCFOqdNEOTg23k0iLx/pXYtGDdLAm3z88J6oKOhgYSqiRseZpYaLqTn67ctx0NN0Kzayuf9Owg05CL6YvW8mM/y/njbHRCBL+5PGVYH1OVNIA2bv0bKL1JOK3CA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784610203; c=relaxed/simple; bh=LQ3qkJmlLZ6LDotX9bT96Rgp2Ut0GW3iGYXQBIEZXqc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Kh3EAr1aKVfX4s8juMDPo+ZdjT2pH3ub6VKXLPjgghvgSXSjWQT7G26k66i2lXkSW8eyn1ojat+I4wGBlf3wUqctilg+qgLIavIqMqcpTXrAG0cpv9v0kEMjQWPYDgJgjVVprJL1AdnnAncQ0NW5Li0ajiLF/uuS+ST3jEBBi1E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A/+FvBBd; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A/+FvBBd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A36F81F000E9; Tue, 21 Jul 2026 05:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784610202; bh=yL7QhE7xap8/XcGHCblR4GvLd+vs1TKDkVYo+vOFs48=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=A/+FvBBdCq1YbkKYfBH1h73jKORqxBWSQppcc8yzKws5C/sp4cMqSiHp8DpCta/Io qgh0c+KQVrTeIpJZ/JW0/2QIOf0ohcZG6v8pA1tRtaYMA6FIkoYixakEjFaPo/8z0X aiDW8eXdivI/nTxWzWqptEChsvLeDSMNzJ1Jg/cYKvTq+sXUUf+/XjbrsHbaIYe9LC tKLpmKxvstU/8FwUnRzKwe4hje65XGnG+WxNn0Qg/Z3Fcpin7g5Xd9RRIc6qVdXeAf UdAzAInZ7St3PAp8ixwjfHP0IazV3kOoXAYmTM2D5R2crCcDTaf5Yi27eLz+0mLox3 TMUrLCROczK4A== Message-ID: Date: Tue, 21 Jul 2026 14:03:14 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm/slub: prevent pfmemalloc objects from entering the barn To: hu.shengming@zte.com.cn, vbabka@kernel.org, akpm@linux-foundation.org Cc: hao.li@linux.dev, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhang.run@zte.com.cn, cai.qu@zte.com.cn References: <20260721084522552ZPa16p1SRj3PYat3sqxuN@zte.com.cn> Content-Language: en-US From: Harry Yoo In-Reply-To: <20260721084522552ZPa16p1SRj3PYat3sqxuN@zte.com.cn> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------u6dQlMPgp5OPkjpABcZEdPVJ" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------u6dQlMPgp5OPkjpABcZEdPVJ Content-Type: multipart/mixed; boundary="------------F5vY0xrhNe7uLF58JxD6r8qZ"; protected-headers="v1" From: Harry Yoo To: hu.shengming@zte.com.cn, vbabka@kernel.org, akpm@linux-foundation.org Cc: hao.li@linux.dev, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhang.run@zte.com.cn, cai.qu@zte.com.cn Message-ID: Subject: Re: [PATCH v3] mm/slub: prevent pfmemalloc objects from entering the barn References: <20260721084522552ZPa16p1SRj3PYat3sqxuN@zte.com.cn> In-Reply-To: <20260721084522552ZPa16p1SRj3PYat3sqxuN@zte.com.cn> --------------F5vY0xrhNe7uLF58JxD6r8qZ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 7/21/26 9:45 AM, hu.shengming@zte.com.cn wrote: > From: Shengming Hu >=20 > kmem_cache_return_sheaf() may refill a partially consumed sheaf before > placing it in the barn. Without an explicit restriction, this refill ma= y > draw objects from pfmemalloc slabs and consume emergency reserves. >=20 > Add __GFP_NOMEMALLOC so that returned sheaves are refilled only from > non-pfmemalloc slabs. Also add __GFP_NOWARN, as suggested by Hao Li, > because this refill is a best-effort attempt and failure is acceptable.= > If the refill fails, flush and free the sheaf instead. >=20 > Fixes: 3c1ea5c5019f ("slab: sheaf prefilling for guaranteed allocations= ") > Cc: stable@vger.kernel.org > Signed-off-by: Shengming Hu > --- Looks good to me, Reviewed-by: Harry Yoo (Oracle) > Changes in v3: > - Replace =E2=80=9Cnormal memory=E2=80=9D with the more precise =E2=80=9C= non-pfmemalloc slabs=E2=80=9D, > and add Fixes: and Cc: stable@vger.kernel.org, as suggested by Harry.= > - Link to v2: https://lore.kernel.org/all/20260720211127124sYtTNbvsxCXN= 9_pDh-pwt@zte.com.cn/ >=20 > Changes in v2: > - Add __GFP_NOWARN as suggested by Hao. > - Link to v1: https://lore.kernel.org/all/20260719113701797vZ3R8NxiqYt8= dEfeUxtON@zte.com.cn/ >=20 > --- > mm/slub.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/mm/slub.c b/mm/slub.c > index 53b4976d3831..357b7522c817 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -5123,7 +5123,7 @@ void kmem_cache_return_sheaf(struct kmem_cache *s= , gfp_t gfp, > * simply flush and free it. > */ > if (!barn || data_race(barn->nr_full) >=3D MAX_FULL_SHEAVES || > - refill_sheaf(s, sheaf, gfp)) { > + refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) { > sheaf_flush_unused(s, sheaf); > free_empty_sheaf(s, sheaf); > return; --=20 Cheers, Harry / Hyeonggon --------------F5vY0xrhNe7uLF58JxD6r8qZ-- --------------u6dQlMPgp5OPkjpABcZEdPVJ Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCal79kgAKCRCGXBN6rc5S 1sysAP0bLAe71suWu01qjf0IJEMD72FgCsyul/qZocwTW4mnoQD9F1YuVGXav7BX FGTXMAHMF5tDbJMquxnqzzWItq0ihQY= =1FCG -----END PGP SIGNATURE----- --------------u6dQlMPgp5OPkjpABcZEdPVJ--