From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 167073D5657 for ; Wed, 18 Mar 2026 12:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773835923; cv=none; b=kB2CXBpYwQQg6tJx+v35gOxh//kbYQd2D3X2hl4l6N0z7fjt4Tz3UZQjsRDvqAJGwaSZxdehAn6azmu7aFP4sSwoEe9gLe2Ug05uH6ExcbqMcv8hlR9a2BlWOXMmv8hXESUwiS1s5Q5ujcdNWBdtR0o5o5itTXwtgzZ9bIdpUac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773835923; c=relaxed/simple; bh=ZMYbeHXn5zcZyLE7ospsCFai3TF1Q88zpyazKVHp95c=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=iYkt66zBpHUdz0caFIvYOmDbj2Vi1K8QGycjNGawsWG4P+S8wYNTKt+KFNxk38HqAp8dFOjR1zju0qIg/wl4hAQhKJsjFN1+qvbiFTSoIV5BHIpSSfjX9D2bABLgVu79AVj2Y4AyKKl9cMwuaDpm99mJP6YZulVzxMo09JDmXMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kVTfzGBL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kVTfzGBL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E764EC19421; Wed, 18 Mar 2026 12:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773835922; bh=ZMYbeHXn5zcZyLE7ospsCFai3TF1Q88zpyazKVHp95c=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=kVTfzGBLiLfFZZLfDcB7uMhQXM6phIcJMoOUvNZkUbV0grhPwH3kOkp+KJvXGGl6O wt04L80HUJ1EjG7ELX8/nMRIiZv/Eg41E0I95mIwx1eHr/QMbBlcVKhU6mKIn2ly4o xOn0UVITpVe9bURrSCD0vJQ5OTZpwNME943JPU149h4z9G//vQkhgvFNdFdHRSHn0t noO5kPzor/Thi26xccF3eDjlhtT4PdVT9HcTtpDaijjWgSc4VQ+qP20UqFjpV0Ati7 sz+pD3v93INrBTR1RgE71vkb9nsdqeVnuI1rWDvQ5vke/gOQsNJ0hSOH/xhFhgXL28 OYkSV3BT5XRUA== Message-ID: <4659c675-6949-4295-b385-1ab26921a975@kernel.org> Date: Wed, 18 Mar 2026 13:11:58 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: "Vlastimil Babka (SUSE)" Subject: Re: [PATCH 2/3] slab: create barns for online memoryless nodes To: Hao Li Cc: Ming Lei , Harry Yoo , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20260311-b4-slab-memoryless-barns-v1-0-70ab850be4ce@kernel.org> <20260311-b4-slab-memoryless-barns-v1-2-70ab850be4ce@kernel.org> <4xvvslwdcqafc2yfthpgv7panejdgmbdoueqiqkaeikohjutgx@3imnb6zlk6ew> Content-Language: en-US In-Reply-To: <4xvvslwdcqafc2yfthpgv7panejdgmbdoueqiqkaeikohjutgx@3imnb6zlk6ew> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/18/26 10:27, Hao Li wrote: > On Wed, Mar 11, 2026 at 09:25:56AM +0100, Vlastimil Babka (SUSE) wrote: >> Ming Lei has reported [1] a performance regression due to replacing cpu >> (partial) slabs with sheaves. With slub stats enabled, a large amount of >> slowpath allocations were observed. The affected system has 8 online >> NUMA nodes but only 2 have memory. >> >> For sheaves to work effectively on given cpu, its NUMA node has to have >> struct node_barn allocated. Those are currently only allocated on nodes >> with memory (N_MEMORY) where kmem_cache_node also exist as the goal is >> to cache only node-local objects. But in order to have good performance >> on a memoryless node, we need its barn to exist and use sheaves to cache >> non-local objects (as no local objects can exist anyway). >> >> Therefore change the implementation to allocate barns on all online >> nodes, tracked in a new nodemask slab_barn_nodes. Also add a cpu hotplug >> callback as that's when a memoryless node can become online. >> >> Change rcu_sheaf->node assignment to numa_node_id() so it's returned to >> the barn of the local cpu's (potentially memoryless) node, and not to >> the nearest node with memory anymore. >> >> Reported-by: Ming Lei >> Link: https://lore.kernel.org/all/aZ0SbIqaIkwoW2mB@fedora/ [1] >> Signed-off-by: Vlastimil Babka (SUSE) >> --- >> mm/slub.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- >> 1 file changed, 59 insertions(+), 4 deletions(-) >> >> diff --git a/mm/slub.c b/mm/slub.c >> index 609a183f8533..d8496b37e364 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c > [...] >> >> /* >> @@ -7597,7 +7648,7 @@ static int init_kmem_cache_nodes(struct kmem_cache *s) >> if (slab_state == DOWN || !cache_has_sheaves(s)) >> return 1; >> >> - for_each_node_mask(node, slab_nodes) { >> + for_each_node_mask(node, slab_barn_nodes) { >> struct node_barn *barn; >> >> barn = kmalloc_node(sizeof(*barn), GFP_KERNEL, node); >> @@ -8250,6 +8301,7 @@ static int slab_mem_going_online_callback(int nid) >> * and barn initialized for the new node. >> */ >> node_set(nid, slab_nodes); >> + node_set(nid, slab_barn_nodes); > > I had a somewhat related question here. > > During memory hotplug, we call node_set() on slab_nodes when memory is brought > online, but we do not seem to call node_clear() when memory is taken offline. I > was wondering what the reasoning behind this is. Probably nobody took the task the implement the necessary teardown. > That also made me wonder about a related case. If I am understanding this > correctly, even if all memory of a node has been offlined, slab_nodes would > still make it appear that the node has memory, even though in reality it no > longer does. If so, then in patch 3, the condition > "if (unlikely(!node_isset(numa_node, slab_nodes)))" in can_free_to_pcs() seems > would cause the object free path to skip sheaves. Maybe the condition should be looking at N_MEMORY then? Also ideally we should be using N_NORMAL_MEMORY everywhere for slab_nodes. Oh we actually did, but give that up in commit 1bf47d4195e45. Note in practice full memory offline of a node can only be achieved if it was all ZONE_MOVABLE and thus no slab allocations ever happened on it. But if it has only movable memory, it's practically memoryless for slab purposes. Maybe the condition should be looking at N_NORMAL_MEMORY then. That would cover the case when it became offline and also the case when it's online but with only movable memory? I don't know if with CONFIG_HAVE_MEMORYLESS_NODES it's possible that numa_mem_id() (the closest node with memory) would be ZONE_MOVABLE only. Maybe let's hope not, and not adjust that part?