KVM allocates each vCPU dirty ring with vzalloc(), which uses GFP_KERNEL without __GFP_ACCOUNT. Unlike other long-lived KVM resources, the ring backing pages are therefore not charged to the active memory cgroup. Use __vmalloc() with GFP_KERNEL_ACCOUNT and retain __GFP_ZERO to preserve the ring initialization semantics. This keeps the vmalloc address required by kvm_dirty_ring_get_page() while accounting the backing pages to the active memory cgroup. OpenAI Codex was used for source analysis, reproducer development, and preparation of this patch and changelog. The change was built for arm64 without new diagnostics, passed scripts/checkpatch.pl, and was tested by comparing dirty-ring allocation before and after the change. Fixes: fb04a1eddb1a65b6588a021bdc132270d5ae48bb ("KVM: X86: Implement ring-based dirty memory tracking") Signed-off-by: Shu Takahashi (Velcore Consulting Inc.) --- virt/kvm/dirty_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/dirty_ring.c b/virt/kvm/dirty_ring.c index 572b854edf740..d9949f264013d 100644 --- a/virt/kvm/dirty_ring.c +++ b/virt/kvm/dirty_ring.c @@ -75,7 +75,7 @@ static void kvm_reset_dirty_gfn(struct kvm *kvm, u32 slot, u64 offset, u64 mask) int kvm_dirty_ring_alloc(struct kvm *kvm, struct kvm_dirty_ring *ring, int index, u32 size) { - ring->dirty_gfns = vzalloc(size); + ring->dirty_gfns = __vmalloc(size, GFP_KERNEL_ACCOUNT | __GFP_ZERO); if (!ring->dirty_gfns) return -ENOMEM; -- 2.56.0