Re: [PATCH v1 1/5] KVM: riscv: Age all G-stage PTEs in a GFN range
From: Anup Patel
Date: Wed Nov 25 2026 - 00:50:01 EST
On Mon, Sep 21, 2026 at 4:44 PM SeungJu Cheon <suunj1331@xxxxxxxxx> wrote:
>
> kvm_age_gfn() and kvm_test_age_gfn() only operate on the G-stage
> leaf covering range->start. They also warn unless the range size is
> exactly 4K, 2M, or 1G.
>
> The MM can pass larger ranges when batching the PTEs of a large folio.
> For example, a 64K mTHP range triggers the warning and only the first
> 4K leaf is aged, leaving the Accessed bits of the remaining leaves
> unchanged.
>
> This can be reproduced on an rv64 host with Svadu by disabling 2M THP,
> enabling 64K mTHP, and running:
>
> access_tracking_perf_test -s anonymous_thp
>
> This results in:
>
> WARNING: arch/riscv/kvm/mmu.c:362 at kvm_age_gfn+0x210/0x370
> ...
> [<ffffffff800c8fc8>] kvm_age_gfn+0x210/0x370
> [<ffffffff80095c90>] kvm_mmu_notifier_clear_young+0x250/0x478
> [<ffffffff80ae532e>] __mmu_notifier_clear_young+0xde/0x1a0
> [<ffffffff80932f76>] walk_pud_range+0x86e/0x1688
> [<ffffffff80a18720>] walk_pgd_range+0x518/0x17b0
> [<ffffffff80a19aa2>] __walk_page_range+0xea/0x580
> [<ffffffff80a1a422>] walk_page_range+0x3a/0x80
> [<ffffffff80931dc0>] try_to_inc_max_seq+0x520/0xe68
> [<ffffffff80939dc0>] lru_gen_seq_write+0xd08/0x1310
>
> Walk all G-stage leaves in the requested range. Advance by the leaf
> size when a mapping is found, or by the size of the non-present region
> at the level where the walk stopped. When testing the age, return as
> soon as a young leaf is found.
>
> Remove the range-size warning since arbitrary GFN ranges are valid.
>
> Fixes: 9955371cc014 ("RISC-V: KVM: Implement MMU notifiers")
> Signed-off-by: SeungJu Cheon <suunj1331@xxxxxxxxx>
LGTM.
Reviewed-by: Anup Patel <anup@xxxxxxxxxxxxxx>
Regards,
Anup