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 1145133ADAC for ; Wed, 10 Jun 2026 01:49:31 +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=1781056174; cv=none; b=t81AmP1AG20bzlkLhaLXSb4ORu61iJ6+Dfds5KI0bSoaTP1KGznmGsP1jjEH6A8kQUVOwnkTbt43tOtSOWxVgu4iFELye+VZZ2wEkOB5Zl7nAUv+qfYiv3/H7U2jNViihO/s3YKk8iRQ3Fc5o+/HxoqiJaMtAKLooLuFPhQ5ghw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781056174; c=relaxed/simple; bh=JL+aiJchgdIg8nAkWjUrYb6XYpFsJdhaDCX84owCZxg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uVVV2VHh39JxS1ek49TlbyQ2YMHfk3tRc4qkLtJ5xCJsfObyu2c4B6OwJkKIUZg9NOJ2AZyQJkiLGZrkjfvDXDbiNLZhmmMW7LoLt+Q5tX4uNKBBN4vuHGWaQj9EEcBL22OoH8vDfweHwLrTqcS5bZyYrkJ1AlPfyaWLE7es9FQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cwBiiMcs; 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="cwBiiMcs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 166121F00893; Wed, 10 Jun 2026 01:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781056170; bh=JL+aiJchgdIg8nAkWjUrYb6XYpFsJdhaDCX84owCZxg=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=cwBiiMcshU0TTbLMsbROAOxC2Khr5/fu420cfU0g8MSD9mHzA3EACZiL0P2tkPa/t tawwk3jPQnkJOttdMC6CsNYkYd2OfeKFTPhUCpd/gB+L6gVuHu/oywxhA675nZmMTy C9DRy5N5LAe8NhAKUQbkuDoVfWw2+0e00YZimoDTOgmHR0i0/mVD13wE456tul9XSq hcNybVn8CM0Szb0Oz3Atvq+BrBJZSAVtvtcOuIiVS9v0o/Wv+S0P04zlIQrp435WfD mKm96qUO7q8rEqRdl8hn1e28qQzkV0Mxnk5jMBzpS/X+xelJCnheHuIDbbm5TSzahB z+Tbw4TRJoKBQ== Message-ID: <380dc696-7184-4ce8-8650-e5f49127390c@kernel.org> Date: Wed, 10 Jun 2026 10:49:26 +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 v2] mm/slub: allocate sheaves on local memory nodes To: "Vlastimil Babka (SUSE)" , 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> Content-Language: en-US From: Harry Yoo In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------FQgYqomLYg05asoeYG6ZVKTi" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------FQgYqomLYg05asoeYG6ZVKTi Content-Type: multipart/mixed; boundary="------------MjhyjoL4GC6C5Y7MLIZrfc0B"; protected-headers="v1" From: Harry Yoo To: "Vlastimil Babka (SUSE)" , 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 Message-ID: <380dc696-7184-4ce8-8650-e5f49127390c@kernel.org> Subject: Re: [PATCH v2] mm/slub: allocate sheaves on local memory nodes References: <20260601095706.106551-1-hao.li@linux.dev> <33506b25-ab2f-4f31-a380-7c0fe65567a3@kernel.org> <5d8abe93-edd1-4b18-9ea4-7731dc831223@kernel.org> In-Reply-To: --------------MjhyjoL4GC6C5Y7MLIZrfc0B Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 6/9/26 7:14 PM, Vlastimil Babka (SUSE) wrote: > 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 st= ructs >>>>> are already allocated from their local NUMA node, this patch aims t= o >>>>> 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() iterat= e >>>>> 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 em= pty >>>> sheaves back to barn and freeing them if the node id doesn't match a= nd >>>> 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 allocati= on >>>> could fall back to other nodes and then SLUB could keep reusing thos= e >>>> sheaves from remote nodes even after memory is reclaimed. >>> >>> This is a good catch. In addition to the fallback mechanism, task mig= ration >>> between CPUs in __pcs_replace_empty_main() and __pcs_replace_full_mai= n() can >>> also mix up sheaf structs across different barns. So yeah, changing a= llocation >>> 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 w= ill >>>> eventually be freed, while covering the other case too? >>> >>> freeing the empty sheaf if the NUMA node mismatches instead of puttin= g 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 noti= ceable >>> degradation either. :-( >> >> Hmm... the idea still makes sense to me, but yeah, it's not late to fi= x >> it when we have data to back up. >=20 > I think if that approach doesn't complicate things unreasonably, it mak= es > sense to do it even if there are no clear wins (as long as there are no= > regressions). I'm fine with that unless it introduces regressions or the implementation complicates things too much :) What do you say, Hao? --=20 Cheers, Harry / Hyeonggon --------------MjhyjoL4GC6C5Y7MLIZrfc0B-- --------------FQgYqomLYg05asoeYG6ZVKTi Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCaijCpwAKCRCGXBN6rc5S 1lrnAQC8qFy0nKaORHaxlLr7JrCzlxrVpOzix7cLrqXv9E6cbQD9F3os0Qz+ZcRS tVlJywFJr22v9fMUzykAvlhm3vJJFQg= =SSeE -----END PGP SIGNATURE----- --------------FQgYqomLYg05asoeYG6ZVKTi--