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 51E543BB111 for ; Mon, 20 Jul 2026 14:17:35 +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=1784557056; cv=none; b=QI5jiE0FIDdsKeNyeetS/xmCXFdFEN+SIj78EWZx1McQWff6OOE6FGPNyUmREGz4NyFIPJlcEz+mHllPBDEYoXoM6E2ShRaqk64rzUXjV+U89i3AOnxJQVJ7oQdOeqFRqj6P9F0d7MKMBayPEI1N9pMpT+QZj1P5XAVaevWBYdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784557056; c=relaxed/simple; bh=i1BcNR5C4G5ebUntODck0pIzwAqfiGjZTzd0SPBlfYI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CoDaPVPymJMC0acYINIvj5f4UIOTpMb8618+A62qxaj4FtyNTp7domW1GZcLgetMYb/trbf4xX2P+YsigHCvhOE5rV9Qjv/Das31s7E7mRpDyyqDVaI3XJiD7rigySF1MASgUeKinXoS/U0WefRW5linKx6z1NDBvZ+SBnA5ccE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AbSIsfXs; 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="AbSIsfXs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF4E21F000E9; Mon, 20 Jul 2026 14:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784557055; bh=Bcg+lq4YYVZFe9NUBLJTEPf7ouJ+niHtp2yRG82CKTY=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=AbSIsfXsTm2pEHE0IhoMOmYWOzpgccCL+cwyYwc3EBZlQXevSkmZMQT9DAkyTaoN2 pk9RzrmeBTk0pru8CDGx0ovU+nnAoy1uDCu/0gZ6Qchz/EEvumGNEmurbcl7NZtwvI AH+38QgBOeTbmyvU34y0y+97xFIBupMQgIR7QwSY0iBC7iAoD9C0imzhS9IqayGr5F bwjZHDhVguSrYLKNfB98zFH5AWMdDoTkVd5NAem2eLP0fwq0BFCinys1jVXrLIVYfk aMzp33zKlRIV4c+922gFHvpuE9PWmS2ZTt8du9/iZKNbOLiLc+ii3xHWA00h1J7Ufw rHlvqTYJcsR7A== Message-ID: <32ffd484-6fb4-418e-b30a-7e2344dfe35f@kernel.org> Date: Mon, 20 Jul 2026 23:17:17 +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 v2] 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: <20260720211127124sYtTNbvsxCXN9_pDh-pwt@zte.com.cn> Content-Language: en-US From: Harry Yoo In-Reply-To: <20260720211127124sYtTNbvsxCXN9_pDh-pwt@zte.com.cn> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------a7k9JHHmnpHlPMfnRu0AhtCJ" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------a7k9JHHmnpHlPMfnRu0AhtCJ Content-Type: multipart/mixed; boundary="------------URmXiOWeRnM7023fUf4kisMU"; 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: <32ffd484-6fb4-418e-b30a-7e2344dfe35f@kernel.org> Subject: Re: [PATCH v2] mm/slub: prevent pfmemalloc objects from entering the barn References: <20260720211127124sYtTNbvsxCXN9_pDh-pwt@zte.com.cn> In-Reply-To: <20260720211127124sYtTNbvsxCXN9_pDh-pwt@zte.com.cn> --------------URmXiOWeRnM7023fUf4kisMU Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 7/20/26 10:11 PM, 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 > normal memory. Also add __GFP_NOWARN, as suggested by Hao Li, because t= his normal memory -> non-pfmemalloc slabs? > refill is a best-effort attempt and failure is acceptable. If the refil= l > fails, flush and free the sheaf instead. > > Signed-off-by: Shengming Hu > --- Overall looks good to me. Probably worth adding Fixes: and Cc: stable to make processes' life slightly easier under low memory situations? Given that the API is not widely used yet I'm not sure how bad it would be in practice, but the fix is quite simple. > 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 --------------URmXiOWeRnM7023fUf4kisMU-- --------------a7k9JHHmnpHlPMfnRu0AhtCJ Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCal4t9AAKCRCGXBN6rc5S 1tiRAP9uy7YoCzN7G79L8h0HvO3ST9NZoN48h2vB9G0bq4jkQQEAoNuZ8D/in+Fy tqqPNLkBMGA1aasMpcs+zqafFkJMeQ4= =v6oj -----END PGP SIGNATURE----- --------------a7k9JHHmnpHlPMfnRu0AhtCJ--