[PATCH v3 04/17] KVM: arm64: Add a heap allocator for the pKVM hyp

Fuad Tabba tabba at google.com
Thu Jul 23 06:19:00 PDT 2026


Hi Vincent,

On Mon, 20 Jul 2026 at 18:15, Vincent Donnefort <vdonnefort at google.com> wrote:

> +static unsigned long hyp_allocator_reclaimable(struct hyp_allocator *allocator)
> +{
> +       unsigned long reclaimable = 0;
> +       struct chunk_hdr *chunk;
> +
> +       guard(hyp_spinlock)(&allocator->lock);
> +
> +       chunk = allocator->head;
> +       while (chunk) {
> +               reclaimable += hyp_allocator_chunk_reclaimable(allocator, chunk, NULL, NULL);
> +               chunk = chunk_get_next(chunk);
> +       }

Sashiko raised this, again, confusingly in a different patch.
hyp_allocator_reclaimable() counts only the per-chunk reclaimable
pages, but hyp_allocator_reclaim() drains allocator->mc first, so the
memcache pages are reclaimable yet not counted here. When mc holds the
only free pages and there are no reclaimable chunks, this returns 0,
pkvm_shrinker_count() reports SHRINK_EMPTY, and scan() is never called
to free them. Should you add allocator->mc.nr_pages to the total?

Cheers,
/fuad



More information about the linux-arm-kernel mailing list