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 910CA32B126 for ; Fri, 19 Jun 2026 05:50:08 +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=1781848209; cv=none; b=fGpwoX+YK9NJiWgTunUWjkk/SVrKacuS2VgMJtb41CLFWdI5opSEAgW5oKOYZg/ELca+ZfgBNkXIrt0g6rEkrMgCDkdNF8sLHmjpNMDaILsnq9KniOTyUZqbmzlctSNfU2nzDgihFTJWhcYpi/hwJ9dmTU9ZefUKl0s4XRlOxUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781848209; c=relaxed/simple; bh=QgTxH5cyIfUvjS9d+3BwTj4QtYZ9552iX4NXBI/X47k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=J4oTTNdTL+eAcMS1e4FkV2f+vN0BIGQzWrN/gtkqaUFnI89/FZ7KF/Og8IjhbWoBp3Jpx/lfXH4i8WvgCxQGk6GlXN5aELn42d+bBqj6LrKG/m8zwjZAi3zWUm8+R0MTRtHnBhljwUyztYi+TJEhk3B75qCbfq/TvHW9m5e62Bo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b02lh4tx; 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="b02lh4tx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3D8C1F000E9; Fri, 19 Jun 2026 05:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781848208; bh=PK4QkHJNkYDhZsyMlgt+M7qhWBwrUtJtyeI4+tgyFjI=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=b02lh4txiOrZRGqhBhCWjmCfJcvg1E4LB26nikRWtvQ5cBBaivbqIztiZpdjht9pQ 9tVPdb+lUEZh3XXZbfnTYTqJcLAQECJHVtC/il91f1vk6zYB1mN5+zt+o4WdhdK+6k iRZidJZZSEtE5YAwPjBgLI7o2fCxtsqcoCvpNZYmtByMLFhfEgBEGs3Cf9zOzjdpFN GtTGehpcjlxQuAMqLC3sklzTSxJWlIUD9x2jT9BwVf+2nf5Tq2t+rkDp2EGMKBtUM0 xKUnvOJN19qQgv9ZlOShILoPH4tWl63ZH0eiPTKYkoGhSZSsKko44wmjOZzRXeEcqa DuqMVSamam+Sw== Message-ID: Date: Fri, 19 Jun 2026 14:50:04 +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] 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: <20260618100913.346636-1-hao.li@linux.dev> Content-Language: en-US From: Harry Yoo In-Reply-To: <20260618100913.346636-1-hao.li@linux.dev> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------BO0Wqi200DHIqdBI3vB2CLYp" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------BO0Wqi200DHIqdBI3vB2CLYp Content-Type: multipart/mixed; boundary="------------YZjfbF37BrzgPLGJHbJ4IY2V"; 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: Subject: Re: [PATCH] mm/slub: deduplicate NUMA policy calculation in allocation paths References: <20260618100913.346636-1-hao.li@linux.dev> In-Reply-To: <20260618100913.346636-1-hao.li@linux.dev> --------------YZjfbF37BrzgPLGJHbJ4IY2V Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 6/18/26 7:08 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 computations. It uses a static key, so probably just slightly larger code when disabled= =2E By inlining both __slab_alloc_node and alloc_from_pcs(), I assume the compiler would have deduplicated it, but there is a patch in slab/for-next that makes it not inlined anymore :) > Introduce a helper function to resolve the NUMA policy once, eliminatin= g > the duplicated code and reducing execution overhead. Nice! I think there's no reason why we shouldn't do this. > Signed-off-by: Hao Li > --- > mm/slub.c | 72 ++++++++++++++++++++++---------------------------------= > 1 file changed, 29 insertions(+), 43 deletions(-) >=20 > diff --git a/mm/slub.c b/mm/slub.c > index 62e9cd46916f..45e9f379b7da 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4523,32 +4523,36 @@ static void *___slab_alloc(struct kmem_cache *s= , gfp_t gfpflags, int node, > return object; > } > =20 > +static __always_inline int apply_numa_policy(int node) apply_numa_policy() is bit confusing because we usually don't apply mempolicy for each object (unless strict_numa is set), but rather when grabbing new slabs. perhaps apply_strict_numa[_policy]() will be a better name? --=20 Cheers, Harry / Hyeonggon --------------YZjfbF37BrzgPLGJHbJ4IY2V-- --------------BO0Wqi200DHIqdBI3vB2CLYp Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCajTYjQAKCRCGXBN6rc5S 1p/CAP4p+mi3CuM7hskUVs7OamecZ034Y/OC7Nx/tkCChWwUqQEA7qDdgsy2xJSq VbtqJpTJlffPxcUmLPQUxeKmsvl3JwA= =ATmB -----END PGP SIGNATURE----- --------------BO0Wqi200DHIqdBI3vB2CLYp--