Skip to contentSkip to conversation

KVM: arm64: Mark some VM-scoped allocations as __GFP_ACCOUNT

PATCH Applied Oliver Upton 4 participants 5 messages Feb 7, 2023 – Feb 8, 2023

Subsystems (2)
lore
Share & tools
lore
Reviewed-by on v1 1/1
#1 lore raw
In reply to Oliver Upton
Quoted 39 lines · Oliver Upton

Generally speaking, any memory allocations that can be associated with a particular VM should be charged to the cgroup of its process. Nonetheless, there are a couple spots in KVM/arm64 that aren't currently accounted:

- the ccsidr array containing the virtualized cache hierarchy

- the cpumask of supported cpus, for use of the vPMU on heterogeneous systems

Go ahead and set __GFP_ACCOUNT for these allocations.

---

Applies to github.com/oupton/linux kvm-arm64/virtual-cache-geometry

  arch/arm64/kvm/arm.c      | 2 +-
  arch/arm64/kvm/sys_regs.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/arm.c +1 -1
index 9c5573bc4614..3619f1e472f5 100644
@@ -146,7 +146,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
  	if (ret)
  		goto err_unshare_kvm;
 
-	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL)) {
+	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL_ACCOUNT)) {
  		ret = -ENOMEM;
  		goto err_unshare_kvm;
  	}
arch/arm64/kvm/sys_regs.c +0 -0
index 6a742af8010f..5dc13d02721e 100644

arch/arm64/kvm/sys_regs.c static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val) · line 166

Quoted 8 lines
arch/arm64/kvm/sys_regs.c +1 -1
@@ -160,7 +160,7 @@ static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val)
  		if (val == get_ccsidr(vcpu, csselr))
  			return 0;
 
-		ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL);
+		ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL_ACCOUNT);
  		if (!ccsidr)
  			return -ENOMEM;
 
#0 lore raw

PATCH 1/1 KVM: arm64: Mark some VM-scoped allocations as __GFP_ACCOUNT

Generally speaking, any memory allocations that can be associated with a particular VM should be charged to the cgroup of its process. Nonetheless, there are a couple spots in KVM/arm64 that aren't currently accounted:

- the ccsidr array containing the virtualized cache hierarchy

- the cpumask of supported cpus, for use of the vPMU on heterogeneous systems

Go ahead and set __GFP_ACCOUNT for these allocations.

---

Applies to github.com/oupton/linux kvm-arm64/virtual-cache-geometry

 arch/arm64/kvm/arm.c      | 2 +-
 arch/arm64/kvm/sys_regs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/arm.c +1 -1
index 9c5573bc4614..3619f1e472f5 100644
@@ -146,7 +146,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	if (ret)
 		goto err_unshare_kvm;
 
-	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL)) {
+	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL_ACCOUNT)) {
 		ret = -ENOMEM;
 		goto err_unshare_kvm;
 	}
arch/arm64/kvm/sys_regs.c +1 -1
index 6a742af8010f..5dc13d02721e 100644
@@ -160,7 +160,7 @@ static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val)
 		if (val == get_ccsidr(vcpu, csselr))
 			return 0;
 
-		ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL);
+		ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL_ACCOUNT);
 		if (!ccsidr)
 			return -ENOMEM;
 
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog
Reviewed-by on v1 1/1
#2 lore raw
Quoted 12 lines · Oliver Upton

Generally speaking, any memory allocations that can be associated with a particular VM should be charged to the cgroup of its process. Nonetheless, there are a couple spots in KVM/arm64 that aren't currently accounted:

- the ccsidr array containing the virtualized cache hierarchy

- the cpumask of supported cpus, for use of the vPMU on heterogeneous systems

Go ahead and set __GFP_ACCOUNT for these allocations.

Quoted 9 lines

---

Applies to github.com/oupton/linux kvm-arm64/virtual-cache-geometry

  arch/arm64/kvm/arm.c      | 2 +-
  arch/arm64/kvm/sys_regs.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 27 lines
arch/arm64/kvm/arm.c +1 -1
index 9c5573bc4614..3619f1e472f5 100644
@@ -146,7 +146,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
  	if (ret)
  		goto err_unshare_kvm;
 
-	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL)) {
+	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL_ACCOUNT)) {
  		ret = -ENOMEM;
  		goto err_unshare_kvm;
  	}
arch/arm64/kvm/sys_regs.c +1 -1
index 6a742af8010f..5dc13d02721e 100644
@@ -160,7 +160,7 @@ static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val)
  		if (val == get_ccsidr(vcpu, csselr))
  			return 0;
 
-		ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL);
+		ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL_ACCOUNT);
  		if (!ccsidr)
  			return -ENOMEM;
 
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Oliver Upton
Quoted 6 lines · Oliver Upton

Generally speaking, any memory allocations that can be associated with a particular VM should be charged to the cgroup of its process. Nonetheless, there are a couple spots in KVM/arm64 that aren't currently accounted:

Quoted 8 lines

- the ccsidr array containing the virtualized cache hierarchy

- the cpumask of supported cpus, for use of the vPMU on heterogeneous systems

Go ahead and set __GFP_ACCOUNT for these allocations.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
author Applied
#4 lore raw
In reply to Oliver Upton
Quoted 8 lines · Oliver Upton

Generally speaking, any memory allocations that can be associated with a particular VM should be charged to the cgroup of its process. Nonetheless, there are a couple spots in KVM/arm64 that aren't currently accounted:

- the ccsidr array containing the virtualized cache hierarchy

[...]

Applied to kvmarm/next, thanks!

[1/1] KVM: arm64: Mark some VM-scoped allocations as __GFP_ACCOUNT

      https://git.kernel.org/kvmarm/kvmarm/c/5f623a598d12

--
Best,
Oliver