[PATCH v2 1/2] mm, slab: restore NUMA policy support for large kmalloc

Vlastimil Babka posted 2 patches 6 months, 2 weeks ago
[PATCH v2 1/2] mm, slab: restore NUMA policy support for large kmalloc
Posted by Vlastimil Babka 6 months, 2 weeks ago
The slab allocator observes the task's NUMA policy in various places
such as allocating slab pages. Large kmalloc() allocations used to do
that too, until an unintended change by c4cab557521a ("mm/slab_common:
cleanup kmalloc_large()") resulted in ignoring mempolicy and just
preferring the local node. Restore the NUMA policy support.

Fixes: c4cab557521a ("mm/slab_common: cleanup kmalloc_large()")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 mm/slub.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/slub.c b/mm/slub.c
index dc9e729e1d269b5d362cb5bc44f824640ffd00f3..11356c701f9f857a2e8cf40bf963ac3abdb5e010 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4282,7 +4282,12 @@ static void *___kmalloc_large_node(size_t size, gfp_t flags, int node)
 		flags = kmalloc_fix_flags(flags);
 
 	flags |= __GFP_COMP;
-	folio = (struct folio *)alloc_pages_node_noprof(node, flags, order);
+
+	if (node == NUMA_NO_NODE)
+		folio = (struct folio *)alloc_pages_noprof(flags, order);
+	else
+		folio = (struct folio *)__alloc_pages_noprof(flags, order, node, NULL);
+
 	if (folio) {
 		ptr = folio_address(folio);
 		lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B,

-- 
2.49.0
Re: [PATCH v2 1/2] mm, slab: restore NUMA policy support for large kmalloc
Posted by Harry Yoo 6 months, 2 weeks ago
On Mon, Jun 02, 2025 at 01:02:12PM +0200, Vlastimil Babka wrote:
> The slab allocator observes the task's NUMA policy in various places
> such as allocating slab pages. Large kmalloc() allocations used to do
> that too, until an unintended change by c4cab557521a ("mm/slab_common:
> cleanup kmalloc_large()") resulted in ignoring mempolicy and just
> preferring the local node. Restore the NUMA policy support.
> 
> Fixes: c4cab557521a ("mm/slab_common: cleanup kmalloc_large()")

Oops, I broke it unintentionally :(

> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---

Reviewed-by: Harry Yoo <harry.yoo@oracle.com>

Thanks for fixing!

-- 
Cheers,
Harry / Hyeonggon

>  mm/slub.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index dc9e729e1d269b5d362cb5bc44f824640ffd00f3..11356c701f9f857a2e8cf40bf963ac3abdb5e010 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -4282,7 +4282,12 @@ static void *___kmalloc_large_node(size_t size, gfp_t flags, int node)
>  		flags = kmalloc_fix_flags(flags);
>  
>  	flags |= __GFP_COMP;
> -	folio = (struct folio *)alloc_pages_node_noprof(node, flags, order);
> +
> +	if (node == NUMA_NO_NODE)
> +		folio = (struct folio *)alloc_pages_noprof(flags, order);
> +	else
> +		folio = (struct folio *)__alloc_pages_noprof(flags, order, node, NULL);
> +
>  	if (folio) {
>  		ptr = folio_address(folio);
>  		lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B,
> 
> -- 
> 2.49.0
Re: [PATCH v2 1/2] mm, slab: restore NUMA policy support for large kmalloc
Posted by Roman Gushchin 6 months, 2 weeks ago
Vlastimil Babka <vbabka@suse.cz> writes:

> The slab allocator observes the task's NUMA policy in various places
> such as allocating slab pages. Large kmalloc() allocations used to do
> that too, until an unintended change by c4cab557521a ("mm/slab_common:
> cleanup kmalloc_large()") resulted in ignoring mempolicy and just
> preferring the local node. Restore the NUMA policy support.
>
> Fixes: c4cab557521a ("mm/slab_common: cleanup kmalloc_large()")
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

Acked-by: Roman Gushchin <roman.gushchin@linux.dev>

Thanks!
Re: [PATCH v2 1/2] mm, slab: restore NUMA policy support for large kmalloc
Posted by Christoph Lameter (Ampere) 6 months, 2 weeks ago
On Mon, 2 Jun 2025, Vlastimil Babka wrote:

> The slab allocator observes the task's NUMA policy in various places
> such as allocating slab pages. Large kmalloc() allocations used to do
> that too, until an unintended change by c4cab557521a ("mm/slab_common:
> cleanup kmalloc_large()") resulted in ignoring mempolicy and just
> preferring the local node. Restore the NUMA policy support.

Acked-by: Christoph Lameter (Ampere) <cl@gentwo.org>