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 313601C84A0 for ; Wed, 20 May 2026 04:35:10 +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=1779251712; cv=none; b=Kbju7p+u0IRBCHHu2+xyM/ixkab+LQBmL8mJYggwz845C5RsSt+zOZF1KnD2vyZY1znUO9kIOWLsR3FWvYnoqBI/bhhP98KFXLGQqZZo8+MDGZ/CbTfBqI6tUCKpIODyI+Qo0NZI6o7jW9Lr28HuHq/jRCm6i0rkxq42SDRPgPs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779251712; c=relaxed/simple; bh=o9/WVOcZ5ezt/YUoagP6iFc+8c6/6Tc7xTG0GJuL6Oo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r50ljOzERiBiI6u2Orwlfdg3ebdUzwN19o2ZEvuLB98QLpoSEQbAeEIzB1IGcOFDq7lllebg0f1GgpNbNMnZuZFZjcIsQbHJ3JmAro0wrEhG7Z1xZu9hvOdHFRtYpNzNMYuDr8oVGiZulf0dDdcBu+U8gqRdsG6YEBaOd7HWViE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BnRzqq5O; 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="BnRzqq5O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96CD01F000E9; Wed, 20 May 2026 04:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779251710; bh=D+KrNjyuJa7ESBMWINTdASPtDIBlZuk36q7PQc9bb7c=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=BnRzqq5O7cuKjfAmBZU3gZkvYJpuSNdKpHuoPs6+RmYSOmnvHXgYghagiLjy0sLva 8a+WJFBVlia+iIBfWGYX8CJKZEeMeG+xYWM5JEwmV338KeWaSl2CEY/GOD3yjLWqBc wa6P/+uthgAA875bYKlOi77vHkyME0vF1aE9zbvtKwLx6Ps/DhB2iXlawx2nmf+Lrb zkq1nYAojXUeCjpoTg+7fDzvKwsbMiYGC0Yxt1T9pWN83p5niDpe4oGkEjeMNE4ii2 sALDIQrrT7YqueWFDDfFHqcj3jRlc2k+HqK8H20H/mzN7HmuYkGsErHOF2s0IVuXC/ 03bmJ1qHNyGKA== Message-ID: <682945f5-2d00-4bc8-8e23-59189b4472c6@kernel.org> Date: Wed, 20 May 2026 13:35:07 +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 RFC 0/8] mm/slab: enable runtime sheaves tuning To: Pedro Falcato Cc: Vlastimil Babka , Andrew Morton , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , "Liam R. Howlett" References: <20260516-sheaves-tuning-v1-0-221aa3e1d829@kernel.org> Content-Language: en-US From: Harry Yoo In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/18/26 8:52 PM, Pedro Falcato wrote: > On Sat, May 16, 2026 at 01:24:24AM +0900, Harry Yoo (Oracle) wrote: >> Background >> ========== >> >> Sheaves were introduced in v6.18, and starting from v7.0, they are >> enabled for all slab caches (except for kmem_cache{,_node}). In the >> pre-sheaves era, there was a cpu_partial parameter to tune the number >> of objects cached per CPU. However, sheaves don't have an equivalent >> and the sheaf capacity is determined in the kernel code. > > What semantic do you need from this? The intent is to allow adjusting sheaf capacity to mitigate per-node barn / slab list contention on the slowpath (for servers with many CPUs), similar to the 'cpu_partial' tunable in SLUB and the 'limit' tunable in SLAB. However, the semantics are slightly different from 'cpu_partial' and 'limit', as changing sheaf_capacity also affects the number of objects cached in the barn. >> Challenges >> ========== >> >> 1. Allocations and frees can happen concurrently at any point between >> these steps, and we cannot introduce heavyweight synchronization >> mechanisms on the fastpath. >> >> 2. Currently, cache_has_sheaves() checks whether a cache has sheaves. >> This works now because sheaves cannot be enabled or disabled once >> the cache is created. >> >> The question "Does this cache has sheaves?" should be split into >> "Does this cache support sheaves?" and "Does this CPU actually has >> sheaves enabled right now?". >> >> 3. Once the sheaf capacity update is complete, no sheaf with stale >> capacity must remain. > > Why? I don't see a huge problem with having multiple sheaves with different > capacities, as long as you adequately, opportunistically kill the sheaves > if they don't have the desired size (say, once a sheaf is fully empty). Haha, you got me. Right, enforcing a single capacity at any given point introduced so much complexity that I started wondering myself about whether this is really essential. My main concern was that the performance characteristics would become too unpredictable, but actually, users can avoid that by disabling sheaves, shrinking it, and re-enabling it. So that's not an enough justification. When I first started, I was quite cautious and obsessed with the invariant because many parts of the current implementation assume "a kmem_cache has only a single capacity, and it doesn't change", but that's also addressed by this patchset. So that's not a big issue either. I agree that it is worth trying to allow sheaves of different capacities and hopefully that would be less intrusive. Let's see. Thank you, Pedro. -- Cheers, Harry / Hyeonggon