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 B2ACE433040 for ; Tue, 21 Jul 2026 14:43:39 +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=1784645020; cv=none; b=TkG9tt+DVJYaUGKuqlgxIh8r3AP309epePqoRLHlQPTM2FAW2FNX/4L9tWLP7PWxKlh24DwC18z9AoIezDteqCFp/z2Zo8MPkKnoHzXnqE/E/kE9LZHE3rLhKvLQIy+CA64AoFqv7FZbSFji1iDwWYlkkqdbu9O5aiTLTK0wkXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784645020; c=relaxed/simple; bh=74LJ8jPwjKICv++2qBEcxq4vCnLXFi0zqh27aYaS+Oc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=N51JACrvyPaQV38LiyNd/DPuMnUBg55WrDHoiT0fSH2rOWcmagGqmnpu0l4eyCXWUWrgXL6pJhQPqiRFTtBltBoCA4kASkseeCpf5fLIcKb6ug1xWTqEnwA/9H75igx+eaY9nWeLxYNhKGlPfrHKH7LBTRWJUlU6P7XKOhTUhtA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n+e9OZZi; 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="n+e9OZZi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25F371F000E9; Tue, 21 Jul 2026 14:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784645019; bh=olLhFfLQoyr4q/gUUxf2G5MJgNcHZvq8RkoA1mPtdUY=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=n+e9OZZi58BM08zRIJazklblOQRdvuRQmcPvTPji+ceOCw/wzktUOqjA2Q65Gw70X bsUf1aBB4De3Ntgx0D3QASJsT42BFhTZYhhTYAGtdEEC2QdhESo8sZ6Fpm2SAfYy1k KtlEJ0GgZNBq5b2C59FuxEenLWQ/ek5VmtjNAZHksSqwbvOrhMR/jqi6p3BaIAsYwR s6aBg7mDXw2uwfsKowcYq/LXgYDAjln2l9ITibmiQcmOrL5q70+XBgmqGvPygeuPgM H7W6KhllzepBnsFXaqM5i6VyTct2Y79mu+KAh3aK63fjTI2rOFv83Klbb3myV/bZ3x glc8aE/vZPi7A== Message-ID: <348dcc9c-00bc-4b59-a266-4f11bd2990e0@kernel.org> Date: Tue, 21 Jul 2026 16:43:34 +0200 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 Content-Language: en-US To: Harry Yoo , hu.shengming@zte.com.cn Cc: akpm@linux-foundation.org, 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: <20260721171753509I9L8xNy2kiOGQFKloTnrG@zte.com.cn> <85ddd27a-ade6-4f27-80ab-cb91caa4e171@kernel.org> From: "Vlastimil Babka (SUSE)" Autocrypt: addr=vbabka@kernel.org; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej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di8OdU/+V+R3O4 0PXWvX8qrvqYapVbZ+9KqT74FsuB0Ya9uXwgBF2Q6cRuETZk5vqaqKxzqoQZCO8AOz/58j6O 2RHNy/mZEN+7tJ5Tsq42zVJ4jxsT8b9YplavCMsnBgDeRWhcbYhCyttoL7nYISyWg4kQYZ/P wIV3OuNv2f8iKYsxNsRuClOAF82+gvqOy1/1pprFjy8uo2pkoOrb63aOP3vO5VHnRKgra6dq NcaZ+c6J4H+nEJGi2SkHAUJz5oBzuThvPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: <85ddd27a-ade6-4f27-80ab-cb91caa4e171@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/21/26 16:27, Harry Yoo wrote: > On 7/21/26 6:17 PM, hu.shengming@zte.com.cn wrote: >> Vlastimil wrote: >>> On 7/21/26 02:45, hu.shengming@zte.com.cn wrote: >>>> From: Shengming Hu >>>> >>>> kmem_cache_return_sheaf() may refill a partially consumed sheaf before >>>> placing it in the barn. Without an explicit restriction, this refill may >>>> draw objects from pfmemalloc slabs and consume emergency reserves. >>>> >>>> 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. >>>> >>>> Fixes: 3c1ea5c5019f ("slab: sheaf prefilling for guaranteed allocations") >>>> Cc: stable@vger.kernel.org >>>> Signed-off-by: Shengming Hu >>> >>> Ah so per sashiko [1] we should consider adding also a __GFP_NORETRY to >>> avoid an OOM kill. Seems reasonable that an API for returning memory should >>> not cause an OOM kill... it's unusual enough that it takes gfp flags > > Ideally the caller should not specify gfp flags that could invoke > OOMs.... but even GFP_KERNEL for non-costly order could invoke them. > >> but I >> thought defaulting to GFP_NOWAIT would be an unnecessary limitation. > > I think it's reasonable to drop gfp parameter and default to GFP_NOWAIT > rather than relying on the callers to avoid OOMs or implicitly > overriding the behavior. > > It wouldn't be too limiting given that it's for returning memory (!) and > other free APIs don't take GFP flags and assume GFP_NOWAIT e.g.) when > allocating a new sheaf. Indeed, let's do that as a separate cleanup. >> I can add __GFP_NORETRY locally if others agree. >> >>> [1] >>> https://sashiko.dev/#/patchset/20260721084522552ZPa16p1SRj3PYat3sqxuN%40zte.com.cn >> >> Agreed, adding __GFP_NORETRY seems reasonable, since this best-effort >> refill should not trigger the OOM killer. >> >> However, I wonder whether the same scope consideration that Harry raised >> for __GFP_NOFAIL also applies here, and whether __GFP_NORETRY should be >> discussed separately rather than folded into this pfmemalloc fix. > > Agreed that this is an independent issue. Yeah I won't add __GFP_NORETRY to this patch. Thanks! >> The earlier discussion is here: >> >> [2] >> https://lore.kernel.org/linux-mm/33a1cb67-8d23-4b51-b4d8-9e95e8de00c7@kernel.org/ >> >> -- >> With Best Regards, >> Shengming >