Re: [PATCH v4 5/8] mm: zswap: Store the folio's node id in the zswap_entry.
From: Nhat Pham
Date: Fri Nov 20 2026 - 17:46:36 EST
On Thu, Nov 19, 2026 at 8:19 PM Kanchana P. Sridhar
<kanchanapsridhar2026@xxxxxxxxx> wrote:
>
> When storing a folio in zswap, save the folio's node id in the zswap
> entry instead of relying on the zswap_entry being allocated on the same
> node. This enables optimizations such as batch allocation of zswap
> entries for large folios using kmem_cache_alloc_bulk() that does not
> support specifying a node id.
>
> Accordingly, replace the SLUB allocation in zswap_entry_cache_alloc() to
> be node-agnostic.
>
> The size of the zswap_entry remains unchanged as 'referenced' is lumped
> in with the 'length' (as it doesn't need a full unsigned int anyway).
> A build time assertion checks for the zswap_entry's 'length' bitfield
> being large enough to represent PAGE_SIZE, which can be 256KB on some
> architectures.
>
> Suggested-by: Nhat Pham <nphamcs@xxxxxxxxx>
> Suggested-by: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>
> Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@xxxxxxxxx>
> Signed-off-by: Kanchana P. Sridhar <kanchanapsridhar2026@xxxxxxxxx>
LGTM for the most part:
Acked-by: Nhat Pham <nphamcs@xxxxxxxxx>
> ---
> + * nid - NUMA node id of the page for which this is the zswap entry.
Maybe "NUMA node id of the original page of this zswap entry"?
> * handle - zsmalloc allocation handle that stores the compressed page data
> * objcg - the obj_cgroup that the compressed memory is charged to
> * lru - handle to the pool's lru used to evict pages.
> */
> struct zswap_entry {
> swp_entry_t swpentry;
> - unsigned int length;
> - bool referenced;
> - u8 pool_idx;
> + struct {
> + unsigned int length:ZSWAP_MAX_COMPR_LENGTH_SHIFT;
I could have sworn we agreed to just inline this macro.
(btw how many bits do we still have here? )