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 5FAC425EF87 for ; Wed, 24 Jun 2026 05:15:01 +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=1782278102; cv=none; b=b4YvC7c6NT/zV0wpuiG4//CXbMa1dTe/vENPv8Tff28KocDKX3JpfLZr9rGm4xojQxw8iAUWCfgwEQkrs6yIU2aO9t836aFAe6T6LqN7IZzsPnrDCND/z3WYi60ruUiI8eOZQSDFJ0XCVcH9j6Iw1x108fKM+YDOLUtAk7C/Jg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782278102; c=relaxed/simple; bh=JAdS3fZ7trUyuiA+bnZvV8qZCCJxMWyoJvrM3GM/bpA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CMf3Mkl44ZN7gxgnwH4vtOe4GN2Qwy5cOtfb0UlQh1xjZi7qw4liDKsXQ6vEptM4IVpswDrBYlXZSllAiGzma5+w7lsFQNeeEHpIsg8qpHumnMLaR6/ZPs8PpPCslaVYljssMmYS3Gb9bsCp26umBy1ANBiUvPCtoNPT939cfsg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mkij4d+Z; 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="mkij4d+Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB1A71F000E9; Wed, 24 Jun 2026 05:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782278101; bh=3FcLlaFTZEEPTlBw3SFS4JJgAFhSBO4Tc1WKaDuAudU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=mkij4d+Zq5+2IUn2GsRASxBwcCppuKuM493YtzPPWtyeITZtX9XW7UkXa0y4j5cry EQK2RBj1/PMUSlEz2hDwOzg1mxv8pfTRGFXP3MM9YRFgWjCtoHYKR6OcF7cPT0Ivuk U/V0xcjHWNw6raUOamfINjiHygeCip8RxhILk4cP5S2xTQ3ubwHh+nvjOmRzLlMcdg Z57bL2Doa3965ANLfi5I8Qw6VyQEuSJB77+wMD/p5ep0BMgATrL3dLuJI11lctkuz9 6OtMDzyXGUJyE7uFj8x5LvU1YL7PXTD8kqL5Ve8+050UyCrAzuSwtPcMnTVAFMig+u ZxgMmXrR54rLQ== Message-ID: <0c69b68d-7c67-4d3a-9f90-86a56bc229e7@kernel.org> Date: Wed, 24 Jun 2026 14:14:55 +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: deduplicate NUMA policy calculation in allocation paths To: Hao Li , vbabka@kernel.org 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: <20260623110952.411041-1-hao.li@linux.dev> Content-Language: en-US From: Harry Yoo In-Reply-To: <20260623110952.411041-1-hao.li@linux.dev> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------qdHVbfu1bcJpbrMsGaKoPU9c" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------qdHVbfu1bcJpbrMsGaKoPU9c Content-Type: multipart/mixed; boundary="------------M9sN5cFnIXP9sHzk0OxtVxgb"; protected-headers="v1" From: Harry Yoo To: Hao Li , vbabka@kernel.org 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: <0c69b68d-7c67-4d3a-9f90-86a56bc229e7@kernel.org> Subject: Re: [PATCH v2] mm/slub: deduplicate NUMA policy calculation in allocation paths References: <20260623110952.411041-1-hao.li@linux.dev> In-Reply-To: <20260623110952.411041-1-hao.li@linux.dev> --------------M9sN5cFnIXP9sHzk0OxtVxgb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 6/23/26 8:04 PM, Hao Li wrote: > Currently, alloc_from_pcs() and __slab_alloc_node() both calculate the > NUMA policy independently. Since they are called consecutively in paths= > like __kmalloc_nolock_noprof() and slab_alloc_node(), this leads to > redundant code snippets. Right. > Introduce a helper function to resolve the NUMA policy once, eliminatin= g > the duplicated code and reducing execution overhead. Nice. > Also remove __slab_alloc_node() function because it is almost empty. Nice! > The callers of __slab_alloc_node now call ___slab_alloc() directly. >=20 > Additional notes: >=20 > Previously, when slab_strict_numa was enabled, alloc_from_pcs() and > __slab_alloc_node() could each resolve the task mempolicy, so > MPOL_INTERLEAVE or MPOL_WEIGHTED_INTERLEAVE could advance the > interleave state twice for a single object allocation attempt. > > With this change, the strict NUMA node is resolved once and reused by= > both alloc_from_pcs() and ___slab_alloc(). Nice catch! > This is a behavior change, but it better matches the intent of > selecting one policy node for one allocation attempt. Right. and I think backporting is unnecessary here. > Signed-off-by: Hao Li > --- > Changes in v2: > * Use a better function name apply_strict_numa_policy() (Thanks Harry= ) > * Remove almost empty function __slab_alloc_node. > * Add a local variable, strict_node, so the retry path in > __kmalloc_nolock_noprof() computes the strict NUMA node from the or= iginal > node parameter instead of a previously resolved node value. What about overriding 'node' before retry label instead? node =3D apply_strict_numa_policy(node); [...] retry: [...] Otherwise LGTM. --=20 Cheers, Harry / Hyeonggon --------------M9sN5cFnIXP9sHzk0OxtVxgb-- --------------qdHVbfu1bcJpbrMsGaKoPU9c Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCajtnzwAKCRCGXBN6rc5S 1hmZAQCpMLa/7jH2nfIjHaVaIp+A/dL3F0oMT71XHDP4cIBelgD/RcmyWcJXXwlv D7cR1bAO7V7rpmLHYB6fToK6qKE9ZAA= =wN5r -----END PGP SIGNATURE----- --------------qdHVbfu1bcJpbrMsGaKoPU9c--