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 3E5843BFE41 for ; Tue, 26 May 2026 06:02:31 +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=1779775353; cv=none; b=CdVCHUZ0V5E1YStJGWdWeqYw3QlNkwShdJvvuapwsqv27K7tm70+nz/JOABGtGVTsGfPfPmaHp1Cz1QIkW4sYUw3KSMWTaXf6t2sHPWy0RTMZeaFscKkIYcZxEcSKfC9ld+UwBUXTfJX+QirfU0UgtKJo65cw+RrqS7goMlzx+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779775353; c=relaxed/simple; bh=mXk/4bFNgkc49ZYdpd3Iw6653RWaaznPjJP4XMIIsXs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YOMpXzuQYunHIDW/8Iaadr5ZeikgyDQHhP3YlUN9TgyXatPrbYz0D0azpqFmnslxJPaQ7zeA/UXdLK2uY26P5BXasUieTIEOuFQkY5euprTk9UplWNB9phzBED5vz7nMjtmN/BhbvN0uHSwB370dxn0GPvHgVptcMLK8i0y5M4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FoCIuHQ4; 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="FoCIuHQ4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBD7B1F000E9; Tue, 26 May 2026 06:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779775351; bh=wIML6hcZOx6vGfksbYoDCW3080B/pxhLrq7CokdoqsU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=FoCIuHQ4Ojm6OkdDncOAQow5VjfnqV/DfcWzWqbK/Nvtt8oDhIE+z0TII334uPVGx Z0cJTgA1CPnEVCvD9W2zPsHZLvc4ippyMi8vNAjhpQK8/Y68A69/WgkQNwpHHckGdB BGcy4CBeT1LgpIlmXWIez4X/ZfG1pBrUH0wV8X1a9MPSswUyBvHTwOE4hkIC4vbD2P 3A1BXKoFCZFTcFNaimWUL3YF8StsORoJHdnrYU6HC7+gcYW7Y1xO6rd2LZ+xw/BDuO ORGQyKWuCg0bc1sOV3BIHQ/naPFe8BRuCq6VaI4rNQxMixe/fBA90i8a41NQ9A0KSo /hfWpcb5CbZaQ== Message-ID: <799bdd0f-2771-4fad-8617-fbe4165689d9@kernel.org> Date: Tue, 26 May 2026 15:02:28 +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: free prefilled empty sheaves consistently 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: <20260525211000387LYqTHmxYL900XIB8qwV3h@zte.com.cn> Content-Language: en-US From: Harry Yoo In-Reply-To: <20260525211000387LYqTHmxYL900XIB8qwV3h@zte.com.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/25/26 10:10 PM, hu.shengming@zte.com.cn wrote: > From: Shengming Hu > > Empty sheaves allocated by alloc_empty_sheaf() should be released with > free_empty_sheaf(). > > Move the empty-sheaf capacity initialization into __alloc_empty_sheaf() > and use it for oversized prefilled sheaves as well. > > This keeps the prefill paths consistent: after flushing an oversized or > pfmemalloc sheaf, release the now-empty sheaf through free_empty_sheaf() > instead of kfree(). > > Signed-off-by: Shengming Hu > --- > mm/slub.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 04692a6f9128..f4c06bf43f2d 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -2782,6 +2782,7 @@ static struct slab_sheaf *__alloc_empty_sheaf(struct kmem_cache *s, gfp_t gfp, > return NULL; > > sheaf->cache = s; > + sheaf->capacity = capacity; the capacity field is only used by oversized sheaves (for now). It should be outside __alloc_empty_sheaf(). > stat(s, SHEAF_ALLOC); > > @@ -5015,21 +5016,15 @@ kmem_cache_prefill_sheaf(struct kmem_cache *s, gfp_t gfp, unsigned int size) > > if (unlikely(size > s->sheaf_capacity)) { > > - sheaf = kzalloc_flex(*sheaf, objects, size, gfp); > + sheaf = __alloc_empty_sheaf(s, gfp, size); > if (!sheaf) > return NULL; > > stat(s, SHEAF_PREFILL_OVERSIZE); So now SHEAF_ALLOC and SHEAF_FREE include oversized sheaves. I think that's fine, but can we update the commit message and the comment? the comment: SHEAF_ALLOC, /* Allocation of an empty sheaf including oversized ones */ SHEAF_FREE, /* Freeing of an empty sheaf including oversized ones */ > - sheaf->cache = s; > - sheaf->capacity = size; > - /* > - * we do not need to care about pfmemalloc here because oversize > - * sheaves area always flushed and freed when returned > - */ the comment is still worth having? > if (!__kmem_cache_alloc_bulk(s, gfp, size, > &sheaf->objects[0])) { > - kfree(sheaf); > + free_empty_sheaf(s, sheaf); > return NULL; > } -- Cheers, Harry / Hyeonggon