mm, kvm: account kvm_vcpu_mmap to kmemcg
Subsystems (6)
PATCH 1/1 mm, kvm: account kvm_vcpu_mmap to kmemcg
A VCPU of a VM can allocate couple of pages which can be mmap'ed by the user space application. At the moment this memory is not charged to the memcg of the VMM. On a large machine running large number of VMs or small number of VMs having large number of VCPUs, this unaccounted memory can be very significant. So, charge this memory to the memcg of the VMM. Please note that lifetime of these allocations corresponds to the lifetime of the VMM.
---
This patch has dependency on Roman's patch series "mm: allow mapping accounted kernel pages to userspace".
arch/s390/kvm/kvm-s390.c | 2 +- arch/x86/kvm/x86.c | 2 +- virt/kvm/coalesced_mmio.c | 2 +- virt/kvm/kvm_main.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/s390/kvm/kvm-s390.c +1 -1
@@ -3243,7 +3243,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)int rc;BUILD_BUG_ON (sizeof (struct sie_page ) !=4096 ); - sie_page = (struct sie_page *)get_zeroed_page (GFP_KERNEL ); + sie_page = (struct sie_page *)get_zeroed_page (GFP_KERNEL_ACCOUNT );if (!sie_page)return -ENOMEM ;
arch/x86/kvm/x86.c +1 -1
@@ -9829,7 +9829,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) r = -ENOMEM ; - page =alloc_page (GFP_KERNEL | __GFP_ZERO); + page =alloc_page (GFP_KERNEL_ACCOUNT | __GFP_ZERO);if (!page) goto fail_free_lapic; vcpu->arch.pio_data =page_address (page);
virt/kvm/coalesced_mmio.c +1 -1
@@ -111,7 +111,7 @@ int kvm_coalesced_mmio_init(struct kvm *kvm) {struct page *page; - page =alloc_page (GFP_KERNEL | __GFP_ZERO); + page =alloc_page (GFP_KERNEL_ACCOUNT | __GFP_ZERO);if (!page)return -ENOMEM ;
virt/kvm/kvm_main.c +1 -1
@@ -3116,7 +3116,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) }BUILD_BUG_ON (sizeof (struct kvm_run ) >PAGE_SIZE ); - page =alloc_page (GFP_KERNEL | __GFP_ZERO); + page =alloc_page (GFP_KERNEL_ACCOUNT | __GFP_ZERO);if (!page) { r = -ENOMEM ; goto vcpu_free;
Signature · 1 line
2.29.1.341.ge80a0c044ae-goog
Quoted 10 lines · Shakeel Butt
A VCPU of a VM can allocate couple of pages which can be mmap'ed by the user space application. At the moment this memory is not charged to the memcg of the VMM. On a large machine running large number of VMs or small number of VMs having large number of VCPUs, this unaccounted memory can be very significant. So, charge this memory to the memcg of the VMM. Please note that lifetime of these allocations corresponds to the lifetime of the VMM.
Signed-off-by Shakeel Butt <[email protected]>---
Thanks, Shakeel!
Quoted 9 lines · Roman Gushchin
Quoted 8 lines · Shakeel Butt
A VCPU of a VM can allocate couple of pages which can be mmap'ed by the user space application. At the moment this memory is not charged to the memcg of the VMM. On a large machine running large number of VMs or small number of VMs having large number of VCPUs, this unaccounted memory can be very significant. So, charge this memory to the memcg of the VMM. Please note that lifetime of these allocations corresponds to the lifetime of the VMM.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Shakeel Butt <[email protected]>---
Acked-by Roman Gushchin <[email protected]>Thanks, Shakeel!
If this patch is not merged via -mm, please ping me again once its dependency is part of Linus's tree.
Thanks,
Paolo