KVM: X86: Remove unnecessary GFP_KERNEL_ACCOUNT for temporary variables
PATCH 1/1 KVM: X86: Remove unnecessary GFP_KERNEL_ACCOUNT for temporary variables
From: Peng Hao <[email protected]>
Some variables allocated in kvm_arch_vcpu_ioctl are released when the function exits, so there is no need to set GFP_KERNEL_ACCOUNT.
--- arch/x86/kvm/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kvm/x86.c +4 -4
@@ -5880,7 +5880,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,if (!lapic_in_kernel (vcpu)) goto out; u.lapic =kzalloc (sizeof (struct kvm_lapic_state ), -GFP_KERNEL_ACCOUNT ); +GFP_KERNEL ); r = -ENOMEM ;if (!u.lapic)
@@ -6073,7 +6073,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,if (vcpu->arch.guest_fpu.uabi_size >sizeof (struct kvm_xsave ))break ; - u.xsave =kzalloc (sizeof (struct kvm_xsave ),GFP_KERNEL_ACCOUNT ); + u.xsave =kzalloc (sizeof (struct kvm_xsave ),GFP_KERNEL ); r = -ENOMEM ;if (!u.xsave)break ;
@@ -6104,7 +6104,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,case KVM_GET_XSAVE2 : {int size = vcpu->arch.guest_fpu.uabi_size; - u.xsave =kzalloc (size,GFP_KERNEL_ACCOUNT ); + u.xsave =kzalloc (size,GFP_KERNEL ); r = -ENOMEM ;if (!u.xsave)break ;
@@ -6122,7 +6122,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, }case KVM_GET_XCRS : { - u.xcrs =kzalloc (sizeof (struct kvm_xcrs ),GFP_KERNEL_ACCOUNT ); + u.xcrs =kzalloc (sizeof (struct kvm_xcrs ),GFP_KERNEL ); r = -ENOMEM ;if (!u.xcrs)break ;
Signature · 1 line
2.27.0
Quoted 2 lines · On Mon, 24 Jun 2024 09:20:16 +0800, [email protected] wrote:
Some variables allocated in
kvm_arch_vcpu_ioctlare released when the function exits, so there is no need to setGFP_KERNEL_ACCOUNT.
Applied to kvm-x86 misc, thanks!
[1/1] KVM: X86: Remove unnecessary GFP_KERNEL_ACCOUNT for temporary variables
https://github.com/kvm-x86/linux/commit/dd103407ca31
Quoted 4 lines · Sean Christopherson
Quoted 2 lines · On Mon, 24 Jun 2024 09:20:16 +0800, [email protected] wrote:
Some variables allocated in
kvm_arch_vcpu_ioctlare released when the function exits, so there is no need to setGFP_KERNEL_ACCOUNT.
Quoted 8 lines
Applied to kvm-x86 misc, thanks!
[1/1] KVM: X86: Remove unnecessary
GFP_KERNEL_ACCOUNTfor temporary variableshttps://github.com/kvm-x86/linux/commit/dd103407ca31
Hi Sean,
I thought we should use _ACCOUNT even for temporary variables.
Should I send a patch to do below? :-)
arch/x86/kvm/vmx/sgx.c +1 -1
@@ -274,7 +274,7 @@ static int handle_encls_ecreate(struct kvm_vcpu *vcpu)* simultaneously set SGX_ATTR_PROVISIONKEY to bypass the check to * enforce restriction of access to the PROVISIONKEY. */ - contents = (struct sgx_secs *)__get_free_page (GFP_KERNEL_ACCOUNT ); + contents = (struct sgx_secs *)__get_free_page (GFP_KERNEL );if (!contents)return -ENOMEM ;
Sean Christopherson
maintainerQuoted 7 lines · Kai Huang
Quoted 6 lines · Sean Christopherson
Quoted 2 lines · On Mon, 24 Jun 2024 09:20:16 +0800, [email protected] wrote:
Some variables allocated in
kvm_arch_vcpu_ioctlare released when the function exits, so there is no need to setGFP_KERNEL_ACCOUNT.Applied to kvm-x86 misc, thanks!
Quoted 8 lines
Quoted 6 lines
[1/1] KVM: X86: Remove unnecessary
GFP_KERNEL_ACCOUNTfor temporary variableshttps://github.com/kvm-x86/linux/commit/dd103407ca31Hi Sean,
Sorry, lost this at the bottom of my inbox.
Quoted 1 line
I thought we should use
_ACCOUNTeven for temporary variables.
Heh, that's what I thought too.
[*] https://lore.kernel.org/all/c0122f66-f428-417e-a360-b25fc0f154a0@p183
Quoted 11 lines · Sean Christopherson
Quoted 10 lines · Kai Huang
Quoted 9 lines · Sean Christopherson
Quoted 2 lines · On Mon, 24 Jun 2024 09:20:16 +0800, [email protected] wrote:
Some variables allocated in
kvm_arch_vcpu_ioctlare released when the function exits, so there is no need to setGFP_KERNEL_ACCOUNT.Applied to kvm-x86 misc, thanks!
[1/1] KVM: X86: Remove unnecessary
GFP_KERNEL_ACCOUNTfor temporary variableshttps://github.com/kvm-x86/linux/commit/dd103407ca31
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Hi Sean,
Sorry, lost this at the bottom of my inbox.
Thanks for getting back to this. :-)
Quoted 7 lines
Quoted 2 lines
I thought we should use
_ACCOUNTeven for temporary variables.Heh, that's what I thought too.
[*] https://lore.kernel.org/all/c0122f66-f428-417e-a360-b25fc0f154a0@p183
Thanks for the info.
Looking at Paolo's reply and by applying this patch, it seems we agreed we can just use GFP_KERNEL (e.g., GFP_USER isn't needed too)?
Anyway I've sent a patch to change handle_encls_ecreate():