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 4C52C3CE481 for ; Mon, 25 May 2026 07:15:54 +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=1779693356; cv=none; b=Fxgq7Ar1urdQJ5r3WHZdZb+MICKvVQZDXMIOnSvANd2ALT3scTLE7y7wYaokbUtSBSrViyPKlksSR2AmxRARSWTU5kzudo/qYLRy13hX1GGsv/gdLsMWKkRnhWrmOMpkDDlycMPnkJKpDA8PhPbj6h5ZGiMTTU8EnQi7MiwKs1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779693356; c=relaxed/simple; bh=/nWoiJJsnTihdn/aLF9NmyfM/nuL4TRAwcvbckhdCOQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Z09N9UyWCntC452+K8uMJO1AW7hv1G7mAfJ9QN7jvY2vDIpqMUvk5M1LuujA95un7zhUG/3V6F/rYUKVxK8R8+Ns61XqBXjKS0agLmYP6iSd3VINA36BYi92C6383N1NN2LnEaLWYY9YleGp3bVhLmeFhvgE6AC0RRquZSa99+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bU3SbVn9; 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="bU3SbVn9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC1511F000E9; Mon, 25 May 2026 07:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779693354; bh=T63Bqc31lmcxY2myxBMwsjJ8z6BwCskmI51/Qnu07gQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=bU3SbVn9pOYKZcc+xFPSPV57BDiCS3p/GHIYS9W5yMafJwWvtVle0M2xY4vP5XJFj A2OXN/OQ4Q4KQtoTcXmOLZHXn8C1QFbt61m4fFVTrJMo5s03Zf1w6IEeJxnoH/itS9 NinNn5xwWV9SVG2VXvY+3EQF7PN8R81FRtjwoy/UzPU4ELxHlXT3I+FO0fkI4O/bAU fzL3trNISBI6VAHRz0IR3SfqrReHJcfxhIHlF9WSQChwlEgKLLzxGjsGcX1P6FG8Hz FZ6PnDA/WyfyIuhUSQYFO/Gj/Kkf0+tB2b9KZOfgOK9f3IYBLciX3ZcnkJhIHqQIao Vag4TuEMN09bQ== Message-ID: <80d69c1c-a779-4402-af89-3be67b7f0e47@kernel.org> Date: Mon, 25 May 2026 09:15:49 +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 2/2] mm, slab: simplify returning slab in __refill_objects_node() To: Hao Li Cc: Harry Yoo , Christoph Lameter , David Rientjes , Roman Gushchin , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, hu.shengming@zte.com.cn, Vinicius Costa Gomes References: <20260522-b4-refill-optimistic-return-v3-0-2ba78ec1c6ed@kernel.org> <20260522-b4-refill-optimistic-return-v3-2-2ba78ec1c6ed@kernel.org> From: "Vlastimil Babka (SUSE)" Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/25/26 08:47, Hao Li wrote: > On Fri, May 22, 2026 at 04:23:21PM +0200, Vlastimil Babka (SUSE) wrote: >> When we return slabs to the partial list because we didn't fully refill >> from them, we observe the min_partial limit when the returned slab is >> empty, and discard it when over the limit. But it's unlikely for the >> limit to be reached while we were refilling, and the worst outcome is to >> have temporarily more free slabs on the list than necessary. > > Just wondering if the empty slabs temporarily exceed the limit and then some > objects get allocated from them, would this lead to more fragmented slabs in > the node partial list? I think since we're adding the slabs to tail and refill from head, it shouldn't happen that easily. Fragmenting is possible in general due to bad luck, I doubt this change could make it noticeably worse. >> So just >> drop that code and simplify the function. >> >> Signed-off-by: Vlastimil Babka (SUSE) >> --- >> mm/slub.c | 10 ---------- >> 1 file changed, 10 deletions(-) >> >> diff --git a/mm/slub.c b/mm/slub.c >> index 5816fcfc7a90..074d57c0390b 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c >> @@ -7196,21 +7196,11 @@ __refill_objects_node(struct kmem_cache *s, void **p, gfp_t gfp, unsigned int mi >> >> list_for_each_entry_safe(slab, slab2, &pc.slabs, slab_list) { >> >> - if (unlikely(!slab->inuse && n->nr_partial >= s->min_partial)) >> - continue; >> - >> list_del(&slab->slab_list); >> add_partial(n, slab, ADD_TO_TAIL); >> } >> >> spin_unlock_irqrestore(&n->list_lock, flags); >> - >> - /* any slabs left are completely free and for discard */ >> - list_for_each_entry_safe(slab, slab2, &pc.slabs, slab_list) { >> - >> - list_del(&slab->slab_list); >> - discard_slab(s, slab); >> - } >> } >> >> return refilled; >> >> -- >> 2.54.0 >> >