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 6F0243ED5AC for ; Tue, 9 Jun 2026 10:14:58 +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=1781000099; cv=none; b=GPHJa/EMt03sh9zJyzWU2czrY/e9XvLyx1iRX2B0DtsXgduVVKkDkQc4+4U/U6CjeP1uDQsDRnLrSQ7C1w/qWTczloowx76oUl18DSS3aqHHtGzk5tlSejZ7WTQwu4uKXum9IZETq3aGAjLux+C6CrKwjmX/n87/bAvPp1mNGUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781000099; c=relaxed/simple; bh=rTbS6pFIIZ2hntX9UvuGf4kTSN0bsu6m61l6bet4XEE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EucuPEt57aHdf1BqU/4JuLtv36RgH4XZ9Y0fXneH6R7DSSk1jQYwNb7maRZfyIU7JBX2qD/cvrzkvkEqGna4YdLFvhIuqs1CbQ0/QJiLK8CWN7Ck7bpJ/kR+Ob4P4R72LRITB4TBNTQUIrOVsNPqzn0U4LxL6SJTQQeHDKZjueI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e2N/6LAi; 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="e2N/6LAi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97C441F00893; Tue, 9 Jun 2026 10:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781000098; bh=oe68d4vJMX8BTuAelw2E6Iqw/eVTlmlqYKm4lxOkTlw=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=e2N/6LAiZ3lmiOQCT7v1GbceXrHi0XCDbgiPs+4M/QY/AtQXyUFVQBv6VN4/+wwnR 9VQDGaGwK3UVL+oaPqcLFD9l4X4AT7sZrQkpBhgeXSiG8a7K7CAwRz1aUAhoGeQeEm qKHVHInPdCy3tMRm59aXN7qSmn2uwxU58TpKXnJm42TH63tVOFoVa6rYwAZTkc8ZgE bJYkg1sCLmFJRaeOPKqr4+NFM1/pNlgp+4u4sPJRyiAlOnVQ/RoBH2nIxGR3z2TNfG Sf/ronQ3jqRYY4B8PIyoVSPFg7wgqO2T2PASbVCkq7fl4L1w8p96FEMReNNhOZySik 7+0vy7xtx5zQA== Message-ID: Date: Tue, 9 Jun 2026 12:14:55 +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 v2] mm/slub: allocate sheaves on local memory nodes Content-Language: en-US To: Harry Yoo , Hao Li Cc: akpm@linux-foundation.org, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20260601095706.106551-1-hao.li@linux.dev> <33506b25-ab2f-4f31-a380-7c0fe65567a3@kernel.org> <5d8abe93-edd1-4b18-9ea4-7731dc831223@kernel.org> From: "Vlastimil Babka (SUSE)" Autocrypt: addr=vbabka@kernel.org; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ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9uXwgBF2Q6cRuETZk5vqaqKxzqoQZCO8AOz/58j6O 2RHNy/mZEN+7tJ5Tsq42zVJ4jxsT8b9YplavCMsnBgDeRWhcbYhCyttoL7nYISyWg4kQYZ/P wIV3OuNv2f8iKYsxNsRuClOAF82+gvqOy1/1pprFjy8uo2pkoOrb63aOP3vO5VHnRKgra6dq NcaZ+c6J4H+nEJGi2SkHAUJz5oBzuThvPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: <5d8abe93-edd1-4b18-9ea4-7731dc831223@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/9/26 05:41, Harry Yoo wrote: > > > On 6/3/26 1:26 PM, Hao Li wrote: >> On Mon, Jun 01, 2026 at 08:28:16PM +0900, Harry Yoo wrote: >>> On 6/1/26 6:56 PM, Hao Li wrote: >>>> Sheaf structs are exchanged through node-local barns. Since barn structs >>>> are already allocated from their local NUMA node, this patch aims to >>>> allocate sheaf structs from their local memory nodes as well. >>>> >>>> To achieve this, the obvious choice would be using cpu_to_mem(). >>>> However, init_percpu_sheaves() and bootstrap_cache_sheaves() iterate >>>> through possible CPUs, whereas cpu_to_mem() is only initialized for >>>> online CPUs. Therefore, we cannot use cpu_to_mem() and instead need to >>>> use local_memory_node(cpu_to_node(cpu)), similar to what >>>> __build_all_zonelists() does. >>>> >>>> The primary goal of this patch is to improve NUMA node locality. >>>> Although the actual performance impact is minor, it still yields a ~1% >>>> improvement on a 192-core, 8-NUMA-node system when testing with the >>>> will-it-scale mmap test case. >>> >>> Oh, nice :) >>> >>> I have a question though... >>> >>> I wonder if would be better to handle this by e.g.) not returning empty >>> sheaves back to barn and freeing them if the node id doesn't match and >>> it's not a memoryless node. >>> >>> init_percpu_sheaves() and bootstrap_cache_sheaves() are not the only >>> places that can allocate sheaves from remote nodes; sheaves allocation >>> could fall back to other nodes and then SLUB could keep reusing those >>> sheaves from remote nodes even after memory is reclaimed. >> >> This is a good catch. In addition to the fallback mechanism, task migration >> between CPUs in __pcs_replace_empty_main() and __pcs_replace_full_main() can >> also mix up sheaf structs across different barns. So yeah, changing allocation >> locality is not a silver bullet. >> >>> If this works well, we probably don't need to handle it in >>> init_percpu_sheaves() and bootstrap_cache_sheaves() at all as they will >>> eventually be freed, while covering the other case too? >> >> freeing the empty sheaf if the NUMA node mismatches instead of putting it back >> into the barn is indeed a good idea. I like it. But unfortunately, my testing >> didn't show a clear performance improvement, though there was no noticeable >> degradation either. :-( > > Hmm... the idea still makes sense to me, but yeah, it's not late to fix > it when we have data to back up. I think if that approach doesn't complicate things unreasonably, it makes sense to do it even if there are no clear wins (as long as there are no regressions).