From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (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 12F6427AC4D for ; Mon, 20 Jul 2026 03:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784519033; cv=none; b=H7FkEznw9y7tk9JVpNaTAnOUU//XqJdh8nvHnc9xVWipt6ESVZ1HHh2zi1/IK1/IJx3UE0hD2U3fJEm5TA7FdLGSsaao8Q2RrjDODY+bZTg3id1UkAQU/CIHI27R2WoM7yOsP7DVhdAzFXx2m2eZyj8dUh2pRYFlrLhBVUeM5rY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784519033; c=relaxed/simple; bh=Xgs098YJVZ4UgHH8rjIThRpYMakvn5aK3RCoaiy+tIs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g7OOGYCNkeHWJvbhhjmJeYLLcFRzaEXh1U6C+x7gFuCgVwbU1wN4h0slxUN4iZlgbseXrzTIg0f0Nd7TgeOwcAifZrZ3hITJzzN7e1TwR8o3xy797YpYxpobad2/sbz+5XpYL8EjZrT47NFC08UBKba4rxCnFPWkpOS4BGh97sY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Kx6j5QYS; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Kx6j5QYS" Date: Mon, 20 Jul 2026 11:43:08 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784519028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7lEXVEdljxakidze8KbnFPa4EtaHgiEgN8dn9BC8AeE=; b=Kx6j5QYSV/p0XFn5ZOQiiievVQthPII5IrKq3y7kWmKFVLly4nN0c870ivFxoqDuqY1AM3 +CZwG5RGoSTVcKCi9T6Nx8a9BV29anl475Stuej91CBxydN3cNjLmw+rCVtEKa/AJ51DE5 N9P/qr9jI2MOhFkjDAboZIJYP7579nA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Li To: hu.shengming@zte.com.cn Cc: vbabka@kernel.org, harry@kernel.org, akpm@linux-foundation.org, 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 Subject: Re: [PATCH] mm/slub: prevent pfmemalloc objects from entering the barn Message-ID: References: <20260719113701797vZ3R8NxiqYt8dEfeUxtON@zte.com.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260719113701797vZ3R8NxiqYt8dEfeUxtON@zte.com.cn> X-Migadu-Flow: FLOW_OUT On Sun, Jul 19, 2026 at 11:37:01AM +0800, 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 returned sheaves are refilled only from normal > memory. If that fails, flush and free the sheaf instead. > > Signed-off-by: Shengming Hu > --- > mm/slub.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 53b4976d3831..34f17ecbde87 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) >= MAX_FULL_SHEAVES || > - refill_sheaf(s, sheaf, gfp)) { > + refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC)) { maybe we can add __GFP_NOWARN as this is just an refilling attempt? refilling failure could be acceptable. > sheaf_flush_unused(s, sheaf); > free_empty_sheaf(s, sheaf); > return; > -- > 2.25.1