Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch kvm-arm64/memory-accounting into kvmarm-master/next

* kvm-arm64/memory-accounting:
: .
: Sprinkle a bunch of GFP_KERNEL_ACCOUNT all over the code base
: to better track memory allocation made on behalf of a VM.
: .
KVM: arm64: Add memcg accounting to KVM allocations
KVM: arm64: vgic: Add memcg accounting to vgic allocations

Signed-off-by: Marc Zyngier <maz@kernel.org>

+19 -17
+5 -3
arch/arm64/kvm/arm.c
··· 291 291 292 292 struct kvm *kvm_arch_alloc_vm(void) 293 293 { 294 - if (!has_vhe()) 295 - return kzalloc(sizeof(struct kvm), GFP_KERNEL); 294 + size_t sz = sizeof(struct kvm); 296 295 297 - return vzalloc(sizeof(struct kvm)); 296 + if (!has_vhe()) 297 + return kzalloc(sz, GFP_KERNEL_ACCOUNT); 298 + 299 + return __vmalloc(sz, GFP_KERNEL_ACCOUNT | __GFP_HIGHMEM | __GFP_ZERO); 298 300 } 299 301 300 302 void kvm_arch_free_vm(struct kvm *kvm)
+1 -1
arch/arm64/kvm/mmu.c
··· 512 512 return -EINVAL; 513 513 } 514 514 515 - pgt = kzalloc(sizeof(*pgt), GFP_KERNEL); 515 + pgt = kzalloc(sizeof(*pgt), GFP_KERNEL_ACCOUNT); 516 516 if (!pgt) 517 517 return -ENOMEM; 518 518
+1 -1
arch/arm64/kvm/pmu-emul.c
··· 978 978 mutex_lock(&vcpu->kvm->lock); 979 979 980 980 if (!vcpu->kvm->arch.pmu_filter) { 981 - vcpu->kvm->arch.pmu_filter = bitmap_alloc(nr_events, GFP_KERNEL); 981 + vcpu->kvm->arch.pmu_filter = bitmap_alloc(nr_events, GFP_KERNEL_ACCOUNT); 982 982 if (!vcpu->kvm->arch.pmu_filter) { 983 983 mutex_unlock(&vcpu->kvm->lock); 984 984 return -ENOMEM;
+1 -1
arch/arm64/kvm/reset.c
··· 106 106 vl > SVE_VL_ARCH_MAX)) 107 107 return -EIO; 108 108 109 - buf = kzalloc(SVE_SIG_REGS_SIZE(sve_vq_from_vl(vl)), GFP_KERNEL); 109 + buf = kzalloc(SVE_SIG_REGS_SIZE(sve_vq_from_vl(vl)), GFP_KERNEL_ACCOUNT); 110 110 if (!buf) 111 111 return -ENOMEM; 112 112
+1 -1
arch/arm64/kvm/vgic/vgic-init.c
··· 134 134 struct kvm_vcpu *vcpu0 = kvm_get_vcpu(kvm, 0); 135 135 int i; 136 136 137 - dist->spis = kcalloc(nr_spis, sizeof(struct vgic_irq), GFP_KERNEL); 137 + dist->spis = kcalloc(nr_spis, sizeof(struct vgic_irq), GFP_KERNEL_ACCOUNT); 138 138 if (!dist->spis) 139 139 return -ENOMEM; 140 140
+1 -1
arch/arm64/kvm/vgic/vgic-irqfd.c
··· 139 139 u32 nr = dist->nr_spis; 140 140 int i, ret; 141 141 142 - entries = kcalloc(nr, sizeof(*entries), GFP_KERNEL); 142 + entries = kcalloc(nr, sizeof(*entries), GFP_KERNEL_ACCOUNT); 143 143 if (!entries) 144 144 return -ENOMEM; 145 145
+7 -7
arch/arm64/kvm/vgic/vgic-its.c
··· 48 48 if (irq) 49 49 return irq; 50 50 51 - irq = kzalloc(sizeof(struct vgic_irq), GFP_KERNEL); 51 + irq = kzalloc(sizeof(struct vgic_irq), GFP_KERNEL_ACCOUNT); 52 52 if (!irq) 53 53 return ERR_PTR(-ENOMEM); 54 54 ··· 332 332 * we must be careful not to overrun the array. 333 333 */ 334 334 irq_count = READ_ONCE(dist->lpi_list_count); 335 - intids = kmalloc_array(irq_count, sizeof(intids[0]), GFP_KERNEL); 335 + intids = kmalloc_array(irq_count, sizeof(intids[0]), GFP_KERNEL_ACCOUNT); 336 336 if (!intids) 337 337 return -ENOMEM; 338 338 ··· 985 985 if (!vgic_its_check_id(its, its->baser_coll_table, coll_id, NULL)) 986 986 return E_ITS_MAPC_COLLECTION_OOR; 987 987 988 - collection = kzalloc(sizeof(*collection), GFP_KERNEL); 988 + collection = kzalloc(sizeof(*collection), GFP_KERNEL_ACCOUNT); 989 989 if (!collection) 990 990 return -ENOMEM; 991 991 ··· 1029 1029 { 1030 1030 struct its_ite *ite; 1031 1031 1032 - ite = kzalloc(sizeof(*ite), GFP_KERNEL); 1032 + ite = kzalloc(sizeof(*ite), GFP_KERNEL_ACCOUNT); 1033 1033 if (!ite) 1034 1034 return ERR_PTR(-ENOMEM); 1035 1035 ··· 1150 1150 { 1151 1151 struct its_device *device; 1152 1152 1153 - device = kzalloc(sizeof(*device), GFP_KERNEL); 1153 + device = kzalloc(sizeof(*device), GFP_KERNEL_ACCOUNT); 1154 1154 if (!device) 1155 1155 return ERR_PTR(-ENOMEM); 1156 1156 ··· 1847 1847 struct vgic_translation_cache_entry *cte; 1848 1848 1849 1849 /* An allocation failure is not fatal */ 1850 - cte = kzalloc(sizeof(*cte), GFP_KERNEL); 1850 + cte = kzalloc(sizeof(*cte), GFP_KERNEL_ACCOUNT); 1851 1851 if (WARN_ON(!cte)) 1852 1852 break; 1853 1853 ··· 1888 1888 if (type != KVM_DEV_TYPE_ARM_VGIC_ITS) 1889 1889 return -ENODEV; 1890 1890 1891 - its = kzalloc(sizeof(struct vgic_its), GFP_KERNEL); 1891 + its = kzalloc(sizeof(struct vgic_its), GFP_KERNEL_ACCOUNT); 1892 1892 if (!its) 1893 1893 return -ENOMEM; 1894 1894
+1 -1
arch/arm64/kvm/vgic/vgic-mmio-v3.c
··· 836 836 if (vgic_v3_rdist_overlap(kvm, base, size)) 837 837 return -EINVAL; 838 838 839 - rdreg = kzalloc(sizeof(*rdreg), GFP_KERNEL); 839 + rdreg = kzalloc(sizeof(*rdreg), GFP_KERNEL_ACCOUNT); 840 840 if (!rdreg) 841 841 return -ENOMEM; 842 842
+1 -1
arch/arm64/kvm/vgic/vgic-v4.c
··· 246 246 nr_vcpus = atomic_read(&kvm->online_vcpus); 247 247 248 248 dist->its_vm.vpes = kcalloc(nr_vcpus, sizeof(*dist->its_vm.vpes), 249 - GFP_KERNEL); 249 + GFP_KERNEL_ACCOUNT); 250 250 if (!dist->its_vm.vpes) 251 251 return -ENOMEM; 252 252