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 44BC5238150 for ; Tue, 9 Jun 2026 03:41:24 +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=1780976486; cv=none; b=Nv8bo4YAzp9mesSVSk7AKpRtCTbfHEfjkUARLb/VLJsQmumA6wahGxczcrzqbKpxXQIelpsP1F6rxRODN4spDCH3/0JvpGFg0raK9aEI+qwLn3SbdyiIfcrAJm3lW9F+2m+dgmR7/0+HHGrDoLW2nlkBVR2MkSWcm7J0wfnS17w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780976486; c=relaxed/simple; bh=qyQXosIVlm1d2ieq06VqSov3tK1/uj2RCw2AMDVsioc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RbgcSPSlYVthOEnFn7LHPzlxRXs9muPv6kvngVQqb13mKLhbJLkRerHgNhs+1H1x0wGhXRIw3uSNO4dSv2jLTfFWo/7hgKhRPO/7CKKR8gzHHy8XrN7NtqhZDTjCqv/xxs67Er8Fi1idQj6w4lNYgv4xPCL48PGRGwQ/v+2yrf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LY854tlU; 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="LY854tlU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3984E1F00893; Tue, 9 Jun 2026 03:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780976484; bh=qyQXosIVlm1d2ieq06VqSov3tK1/uj2RCw2AMDVsioc=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=LY854tlUWARShj8og/Lt4O7B/KQkrffzr1mcnOnwau0bA8SQwHE4m+rhQJdSqRjow G5dB0CcwUxxKaV+FXI6P8cs3TfXU+lQDWtXs/HZdQiT01DBMNh62p8LWOXfTq4KcPk l2QR25t/3we7HjtMxgAlEKB7XznXfbVLt1ZnV3YFBCJVPWleyQcAiT76iivgcU1Vni q8cJZPEOCNEExzTiKWef9IQU0gzYhCtj6V3YCyZ1K616IFPm8wkkQ5N6ODiaeCh+ij GzDALhlxx/TZFy1ugnHb/2lD/8u9JhfRJLYEXBxqYCrT6HZ70AZx6ZO/yDAYdLa7wE 4rdjsd4msd/hw== Message-ID: <5d8abe93-edd1-4b18-9ea4-7731dc831223@kernel.org> Date: Tue, 9 Jun 2026 12:41:18 +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: Hao Li Cc: vbabka@kernel.org, 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> Content-Language: en-US From: Harry Yoo In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------icvouGHUGgkSuPMt58PwY0t3" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------icvouGHUGgkSuPMt58PwY0t3 Content-Type: multipart/mixed; boundary="------------LsToChgsNI00hjF1rIQcAz1L"; protected-headers="v1" From: Harry Yoo To: Hao Li Cc: vbabka@kernel.org, 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: <5d8abe93-edd1-4b18-9ea4-7731dc831223@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> In-Reply-To: --------------LsToChgsNI00hjF1rIQcAz1L Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 stru= cts >>> 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 t= o >>> 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 empt= y >> 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. >=20 > This is a good catch. In addition to the fallback mechanism, task migra= tion > between CPUs in __pcs_replace_empty_main() and __pcs_replace_full_main(= ) can > also mix up sheaf structs across different barns. So yeah, changing all= ocation > locality is not a silver bullet. >=20 >> If this works well, we probably don't need to handle it in >> init_percpu_sheaves() and bootstrap_cache_sheaves() at all as they wil= l >> eventually be freed, while covering the other case too? >=20 > 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 t= esting > didn't show a clear performance improvement, though there was no notice= able > 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 also did some more testing on my patch too. Under CONFIG_PREEMPT_LAZY= , the > improvement is only about 0.5% (sometimes 1%). And when switching to > CONFIG_PREEMPT, the patch doesn't seem to yield statistically significa= nt > benefits, likely because sheaves get mixed during task migration. > > So, perhaps the performance gain just isn't worth the extra complexity.= It's a > bit frustrating, but maybe we should just abandon this direction and ke= ep > things as they are... :( Ouch. Don't let it get you down, it's completely normal for experiments not to go as planned.... ;) > Thanks for the feedback anyway! No problem! --=20 Cheers, Harry / Hyeonggon --------------LsToChgsNI00hjF1rIQcAz1L-- --------------icvouGHUGgkSuPMt58PwY0t3 Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCaieLXgAKCRCGXBN6rc5S 1qrpAP4gLfwO21CzsCViBt4GtnDpBmQbtO9g3lhYDimYxD6SHAD8Dm3/YTjrRZNF LYUGhDRyGBnaix6vUOKP11K78F4DLg4= =Bx/E -----END PGP SIGNATURE----- --------------icvouGHUGgkSuPMt58PwY0t3--