Re: [RFC PATCH 1/2] zsmalloc: let callers select NUMA node to store the compressed objects

From: Dan Williams
Date: Mon Mar 31 2025 - 18:18:21 EST


Nhat Pham wrote:
> Curerntly, zsmalloc does not specify any memory policy when it allocates
> memory for the compressed objects.
>
> Let users select the NUMA node for the memory allocation, through the
> zpool-based API. Direct callers (i.e zram) should not observe any
> behavioral change.
>
> Signed-off-by: Nhat Pham <nphamcs@xxxxxxxxx>
> ---
> include/linux/zpool.h | 4 ++--
> mm/zpool.c | 8 +++++---
> mm/zsmalloc.c | 28 +++++++++++++++++++++-------
> mm/zswap.c | 2 +-
> 4 files changed, 29 insertions(+), 13 deletions(-)
>
> diff --git a/include/linux/zpool.h b/include/linux/zpool.h
> index 52f30e526607..0df8722e13d7 100644
> --- a/include/linux/zpool.h
> +++ b/include/linux/zpool.h
> @@ -22,7 +22,7 @@ const char *zpool_get_type(struct zpool *pool);
> void zpool_destroy_pool(struct zpool *pool);
>
> int zpool_malloc(struct zpool *pool, size_t size, gfp_t gfp,
> - unsigned long *handle);
> + unsigned long *handle, int *nid);

I agree with Johannes about the policy knob, so I'll just comment on the
implementation.

Why not just pass a "const int" for @nid, and use "NUMA_NO_NODE" for the
"default" case. alloc_pages_node_noprof() is already prepared for a
NUMA_NO_NODE argument.