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 1129AA59 for ; Fri, 13 Mar 2026 09:46:18 +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=1773395179; cv=none; b=bZ7JidqKWayrNjtAMnRQELrbENEuG/IFVW1GOdYN3wYaIFcnrd1+oCHExuRvK0f7MEyPzfDz2h+kwMroo44FSB6DVzJDrwquPNKfEqxSL3hwWWOOn1U1R53+ZT+pWbffxJu0DFdlHuXtXMM30trSViZNHvuQ6tD1JWr+FT3ZW3s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773395179; c=relaxed/simple; bh=eT7S5UGDFQybEveqjDWuZ6ct7J1Kr6WUThqpPDxzJnw=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=djJsI1TLHneQdJf+3hsRvhKtCf3VvK7cReQ0z1EPaElYR9BE5Llf+2BFjzK4fGemczfNSbx6Dqi19847khTDheHRRO0vO3mEPxeNu23V6kQyHkRKMA9tmx0TqMWK0G1No4kGj6w20kFUmZ+HlwEka1/mV6FfWS++U82zcwqeaM4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F4nu0SdS; 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="F4nu0SdS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0702AC19421; Fri, 13 Mar 2026 09:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773395178; bh=eT7S5UGDFQybEveqjDWuZ6ct7J1Kr6WUThqpPDxzJnw=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=F4nu0SdSgFBEzn6o6+oNrlQuLG135cNvyhQYIDgRsQUK+F7DrNz1Zcqd8jYSkU8DU 6vcL8dKo5ivufAP+wN24W/BtE5lfRnQ+2h4p7tg82jFaUcBvqTKaWvMwrPzyvLnhKH SzQ0ZZaF79lv4go65JrioUojE5ON6/+66a7vW77C88/a0dOC0S10tKls2pO6G5NZtv YP4fOMVHRmmYNbtDx7bH2owseWaURPy8ErZcC8K9x53u7oFccKeGmz2Lkzu3IcPLZg 6zEGLvF4mjK0KZ3BeaqJkqBRqDa9KkuGeYzaQNLk55JFWdKqjOiqSuGxytxppQyD3q 4wrUhvkoyBSUg== Message-ID: <94d89d84-c009-470e-a401-1ac75228cd92@kernel.org> Date: Fri, 13 Mar 2026 10:46:15 +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 1/3] slab: decouple pointer to barn from kmem_cache_node Content-Language: en-US To: Harry Yoo Cc: Ming Lei , Hao Li , 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-1-70ab850be4ce@kernel.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/13/26 10:27, Harry Yoo wrote: > On Wed, Mar 11, 2026 at 09:25:55AM +0100, Vlastimil Babka (SUSE) wrote: >> The pointer to barn currently exists in struct kmem_cache_node. That >> struct is instantiated for every NUMA node with memory, but we want to >> have a barn for every online node (including memoryless). >> >> Thus decouple the two structures. In struct kmem_cache we have an array >> for kmem_cache_node pointers that appears to be sized MAX_NUMNODES but >> the actual size calculation in kmem_cache_init() uses nr_node_ids. >> Therefore we can't just add another array of barn pointers. Instead >> change the array to newly introduced struct kmem_cache_per_node_ptrs >> holding both kmem_cache_node and barn pointer. >> >> Adjust barn accessor and allocation/initialization code accordingly. For >> now no functional change intended, barns are created 1:1 together with >> kmem_cache_nodes. >> >> Signed-off-by: Vlastimil Babka (SUSE) >> --- >> mm/slab.h | 7 +++- >> mm/slub.c | 128 +++++++++++++++++++++++++++++++++++--------------------------- >> 2 files changed, 78 insertions(+), 57 deletions(-) >> >> diff --git a/mm/slab.h b/mm/slab.h >> index e9ab292acd22..c735e6b4dddb 100644 >> --- a/mm/slab.h >> +++ b/mm/slab.h >> @@ -247,7 +252,7 @@ struct kmem_cache { >> struct kmem_cache_stats __percpu *cpu_stats; >> #endif >> >> - struct kmem_cache_node *node[MAX_NUMNODES]; >> + struct kmem_cache_per_node_ptrs per_node[MAX_NUMNODES]; >> }; > > We should probably turn this into a true flexible array at some point, > but that's out of scope for this patchset. Right. >> diff --git a/mm/slub.c b/mm/slub.c >> index 20cb4f3b636d..609a183f8533 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c >> @@ -436,26 +436,24 @@ struct kmem_cache_node { >> /* >> - * Get the barn of the current cpu's closest memory node. It may not exist on >> - * systems with memoryless nodes but without CONFIG_HAVE_MEMORYLESS_NODES >> + * Get the barn of the current cpu's memory node. It may be a memoryless node. >> */ >> static inline struct node_barn *get_barn(struct kmem_cache *s) >> { >> - struct kmem_cache_node *n = get_node(s, numa_mem_id()); >> - >> - if (!n) >> - return NULL; >> - >> - return n->barn; >> + return get_barn_node(s, numa_node_id()); >> } > > Previously, memoryless nodes on architectures w/ CONFIG_HAVE_MEMORYLESS_NODES > shared the barn of the nearest NUMA node with memory. > > But now memoryless nodes will have their own barns (after patch 2) > regardless of CONFIG_HAVE_MEMORYLESS_NODES, and that's intentional, right? Yeah it improves their caching capacity, but good point, will mention it in the changelog. > Otherwise LGTM! >