Re: [RFC PATCH v4 3/3] mm/zswap: reference the pool by index to shrink struct zswap_entry

From: Yosry Ahmed

Date: Mon Aug 31 2026 - 16:46:13 EST


On Sun, Aug 30, 2026 at 4:48 AM Jianyue Wu <wujianyue000@xxxxxxxxx> wrote:
>
> struct zswap_entry is one allocation per stored page, so its size is
> pure overhead. It currently embeds an 8-byte pool pointer, even though
> the live pools now sit in a small fixed array indexed by a u8 slot
> number.
>
> Replace the per-entry pool pointer with that u8 slot index and resolve
> it through the fixed pool array. A live entry holds a reference to its
> pool, so the slot cannot be reused under it. The lookup therefore needs
> no RCU read-side section or zswap_pools_lock.
>
> The u8 fits in the padding after the bool referenced field, shrinking
> the entry from 56 to 48 bytes on x86_64. This raises objs_per_slab from
> 73 to 85 and saves about 2MiB of metadata per 1GiB of data held in
> zswap.
>
> Suggested-by: Chris Li <chrisl@xxxxxxxxxx>
> Signed-off-by: Jianyue Wu <wujianyue000@xxxxxxxxx>

Acked-by: Yosry Ahmed <yosry@xxxxxxxxxx>