Re: [PATCH v3 02/14] mm, swap: add CONFIG_XSWAP and xswap fields to swap_info_struct
From: Chris Li
Date: Sun Sep 27 2026 - 21:18:32 EST
On Wed, Sep 16, 2026 at 12:19 AM Baoquan He <hebaoquan@xxxxxxxxxx> wrote:
>
> Add CONFIG_XSWAP Kconfig option for extendable swap device support.
> It depends on SWAP && 64BIT && ZSWAP, since xswap devices are backed by
> zswap, and on SYSFS, which is currently the only way to create one.
>
> Add three fields to struct swap_info_struct under CONFIG_XSWAP:
> - cluster_vm: the VM_SPARSE vm_struct backing the cluster_info array
> - nr_clusters_max: total number of clusters in the xswap address space
> - nr_clusters_mapped: number of clusters currently mapped (lazy grow)
> These fields enable lazy vmalloc-based dynamic cluster management.
>
> Signed-off-by: Baoquan He <hebaoquan@xxxxxxxxxx>
Can you fold this with the following patch? At least the struct
members should go with the next patch.
It seems nobody use those data structures in this patch anyway. So
this patch alone has no visible value add, other than adding the
config file.
Chris
> ---
> include/linux/swap.h | 5 +++++
> mm/Kconfig | 9 +++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index b4331ca4759a..b7882aac1eab 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -242,6 +242,11 @@ struct swap_info_struct {
> signed char type; /* strange name for an index */
> unsigned int max; /* size of this swap device */
> struct swap_cluster_info *cluster_info; /* array, one entry per cluster */
> +#ifdef CONFIG_XSWAP
> + struct vm_struct *cluster_vm; /* VM_SPARSE area for cluster_info */
> + unsigned long nr_clusters_max;/* total clusters in the xswap address space */
> + unsigned long nr_clusters_mapped; /* currently mapped cluster count */
> +#endif
> struct list_head free_clusters; /* free clusters list */
> struct list_head full_clusters; /* full clusters list */
> struct list_head nonfull_clusters[SWAP_NR_ORDERS];
> diff --git a/mm/Kconfig b/mm/Kconfig
> index c180d40cd671..5d6c7845c422 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -122,6 +122,15 @@ config ZSWAP_COMPRESSOR_DEFAULT
> default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD
> default ""
>
> +config XSWAP
> + bool "Extendable (virtual) swap device"
> + depends on SWAP && 64BIT && ZSWAP && SYSFS
> + help
> + Adds support for extendable swap devices (xswap) that decouple
> + PTE swap entries from physical backing storage. The cluster_info
> + array is backed by a sparse vmalloc area that grows and shrinks
> + on demand, avoiding static pre-allocation overhead.
> +
> config ZSMALLOC
> tristate
>
> --
> 2.54.0
>