From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 85B873A5E7D for ; Tue, 7 Apr 2026 10:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775556213; cv=none; b=GkR12CGci+6J5ihVCSdw2mRjV8RdhLyyXvzX3r51eW7IXHMQ9WCe35F2no3PI+I2t84+U7e+BoQrjaUy9qvmqVVrNLLxEgqOPtulgEGd32s2BDTE/jQRf4FnTlZln32JmO0W35V2BRM+mRzOVEXqYAgSDKrSHbKq+4vrUbhNPVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775556213; c=relaxed/simple; bh=bGMpZEWCYa94PRXICoUsf8UfnbBJHFAveICTndgklNY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=l+Ap/BpqlAGFACiVqt4apykemKh/RcjQqS2KZemAQ7j0tORKguFuYNCX894IGbgjJOeVV/5jZN5Tx9I9K8Uvf7c/POqN6VUti/ous6no4obhECiNjjd0dpChgxKWnUILEBJHCsalM7pk8AjKzuYh6wgwBJ2p4MFaElR5w6wqguc= 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=o86HUI89; arc=none smtp.client-ip=95.215.58.170 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="o86HUI89" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775556209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=W1wNHcMUrRgAHGDgB1gxeB7wyCO1ksdZstgGcDHOw4s=; b=o86HUI89rg9hZA8LmXsYQrcEWivSI5WRZ/OsQ0xO91mzlyje11mdqSIYxCnN++b55PyQ1p kcKFvOOH0GhCvfau4cakCw2kJiKDC2Xgr2nnbJyrtYG6kj4H4G31vtDokYAoYRGKujRtFf ro36EdB0eXrse9AoxOs4SkjhmxuJYng= From: Hao Li To: vbabka@kernel.org, harry@kernel.org, akpm@linux-foundation.org Cc: cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hao Li Subject: [PATCH v2] slub: clarify kmem_cache_refill_sheaf() comments Date: Tue, 7 Apr 2026 17:59:10 +0800 Message-ID: <20260407100255.40035-1-hao.li@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT In the in-place refill case, some objects may already have been added before the function returns -ENOMEM. Clarify this behavior and polish the rest of the comment for readability. Signed-off-by: Hao Li --- Thanks Harry for suggestions on v1! --- mm/slub.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 4927407c9699..a45eb1bd2ce5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5120,12 +5120,15 @@ void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp, } /* - * refill a sheaf previously returned by kmem_cache_prefill_sheaf to at least - * the given size + * Refill a sheaf previously returned by kmem_cache_prefill_sheaf to at least + * the given size. * - * the sheaf might be replaced by a new one when requesting more than - * s->sheaf_capacity objects if such replacement is necessary, but the refill - * fails (returning -ENOMEM), the existing sheaf is left intact + * Return: 0 on success. The sheaf will contain at least @size objects. + * The sheaf might be replaced with a new one if more than sheaf->capacity + * objects are requested. + * + * Return: -ENOMEM on failure. The refill might partially fill the existing + * sheaf or leave it unchanged, but it will not replace the existing sheaf. * * In practice we always refill to full sheaf's capacity. */ -- 2.50.1