Re: [RFC PATCH 09/10] mm/swapfile: implement swap_ghost_extend_max() for dynamic growth
From: Nhat Pham
Date: Thu Jul 09 2026 - 21:11:58 EST
On Thu, Jul 9, 2026 at 7:53 AM Baoquan He <baoquan.he@xxxxxxxxx> wrote:
>
> On 07/07/26 at 03:36pm, Nhat Pham wrote:
>
> Yes, it is grow-only for now. The metadata overhead of an extended
> ghost device is very small: cluster_info[] costs ~32 MB per TB of
> capacity. For a 64 GB machine, 1 TB of ghost swap space costs about
> 0.05% of RAM in metadata. This is not a resource that needs urgent
> reclamation after a spike subsides.
>
> If it does need to be reclaimed — for instance, after a one-time spike
> pushed capacity far beyond normal needs — ghost swap supports swapoff.
> The admin can swapoff the ghost device and swapon a new one at a
> smaller size. No swap type in the kernel today supports online
> shrinking (not block devices, not swapfiles, not zram), so this is the
> standard mechanism.
Except for my virtual swap design, which does support dynamic growth
AND shrinking of capacity on demand ;)
If it cannot grow (and furthermore, if it requires userspace operation
to trigger swapfile growth), why do we need this at all? Might as well
create a new swapfile with swapon? That was my point.