RE: [PATCH v2 2/2] KVM: arm64: Add memcg accounting to KVM allocations

From: Justin He
Date: Thu Sep 09 2021 - 09:08:55 EST


Hi Oliver, thanks for the review, please my comments below:

> -----Original Message-----
> From: Oliver Upton <oupton@xxxxxxxxxx>
> Sent: Wednesday, September 8, 2021 6:29 AM
> To: Justin He <Justin.He@xxxxxxx>
> Cc: Marc Zyngier <maz@xxxxxxxxxx>; James Morse <James.Morse@xxxxxxx>;
> Alexandru Elisei <Alexandru.Elisei@xxxxxxx>; Suzuki Poulose
> <Suzuki.Poulose@xxxxxxx>; Xiaoming Ni <nixiaoming@xxxxxxxxxx>; Lorenzo
> Pieralisi <Lorenzo.Pieralisi@xxxxxxx>; Kees Cook <keescook@xxxxxxxxxxxx>;
> Catalin Marinas <Catalin.Marinas@xxxxxxx>; Nick Desaulniers
> <ndesaulniers@xxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx; Liu Shixin
> <liushixin2@xxxxxxxxxx>; Sami Tolvanen <samitolvanen@xxxxxxxxxx>; Will
> Deacon <will@xxxxxxxxxx>; kvmarm@xxxxxxxxxxxxxxxxxxxxx; linux-arm-
> kernel@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2 2/2] KVM: arm64: Add memcg accounting to KVM
> allocations
>
> Hi Jia,
>
> On Tue, Sep 7, 2021 at 7:33 AM Jia He <justin.he@xxxxxxx> wrote:
> >
> > Inspired by commit 254272ce6505 ("kvm: x86: Add memcg accounting to KVM
> > allocations"), it would be better to make arm64 KVM consistent with
> > common kvm codes.
> >
> > The memory allocations of VM scope should be charged into VM process
> > cgroup, hence change GFP_KERNEL to GFP_KERNEL_ACCOUNT.
> >
> > There remain a few cases since these allocations are global, not in VM
> > scope.
>
> I believe there are more memory allocations that could be switched to
> GFP_KERNEL_ACCOUNT. For non-pKVM kernels, we probably should charge
> all stage-2 paging structure allocations to the VM process. Your patch
> appears to only change the allocation of the kvm_pgtable structure,
> but not descendent paging structures.
>
Do you mean kvm_hyp_zalloc_page() here?
Seems kvm_hyp_zalloc_page() is in both global and VM scopes.

I will replace GFP_KERNEL with XXX_ACCOUNT in next version if no one
objects that.

--
Cheers,
Justin (Jia He)