linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: remove redundant code in kvm_arch_vm_ioctl
@ 2019-10-21  2:52 Miaohe Lin
  2019-10-21  8:16 ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Miaohe Lin @ 2019-10-21  2:52 UTC (permalink / raw)
  To: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
	jmattson, joro, tglx, mingo, bp, hpa
  Cc: x86, kvm, linux-kernel, linmiaohe

If we reach here with r = 0, we will reassign r = 0
unnecesarry, then do the label set_irqchip_out work.
If we reach here with r != 0, then we will do the label
work directly. So this if statement and r = 0 assignment
is redundant.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 arch/x86/kvm/x86.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 661e2bf38526..0b3ebc2afb3d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4916,9 +4916,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
 		if (!irqchip_kernel(kvm))
 			goto set_irqchip_out;
 		r = kvm_vm_ioctl_set_irqchip(kvm, chip);
-		if (r)
-			goto set_irqchip_out;
-		r = 0;
 	set_irqchip_out:
 		kfree(chip);
 		break;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: remove redundant code in kvm_arch_vm_ioctl
  2019-10-21  2:52 [PATCH] KVM: remove redundant code in kvm_arch_vm_ioctl Miaohe Lin
@ 2019-10-21  8:16 ` Thomas Gleixner
  2019-10-21  8:56   ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2019-10-21  8:16 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
	jmattson, joro, mingo, bp, hpa, x86, kvm, linux-kernel

On Mon, 21 Oct 2019, Miaohe Lin wrote:
> If we reach here with r = 0, we will reassign r = 0
> unnecesarry, then do the label set_irqchip_out work.
> If we reach here with r != 0, then we will do the label
> work directly. So this if statement and r = 0 assignment
> is redundant.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  arch/x86/kvm/x86.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 661e2bf38526..0b3ebc2afb3d 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4916,9 +4916,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
>  		if (!irqchip_kernel(kvm))
>  			goto set_irqchip_out;
>  		r = kvm_vm_ioctl_set_irqchip(kvm, chip);
> -		if (r)
> -			goto set_irqchip_out;
> -		r = 0;
>  	set_irqchip_out:
>  		kfree(chip);
>  		break;

Can you please get rid of that odd jump label completely?

  		if (irqchip_kernel(kvm))
			r = kvm_vm_ioctl_set_irqchip(kvm, chip);

Hmm?


Thanks,

	tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: remove redundant code in kvm_arch_vm_ioctl
  2019-10-21  8:16 ` Thomas Gleixner
@ 2019-10-21  8:56   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2019-10-21  8:56 UTC (permalink / raw)
  To: Thomas Gleixner, Miaohe Lin
  Cc: rkrcmar, sean.j.christopherson, vkuznets, wanpengli, jmattson,
	joro, mingo, bp, hpa, x86, kvm, linux-kernel

On 21/10/19 10:16, Thomas Gleixner wrote:
> Can you please get rid of that odd jump label completely?
> 
>   		if (irqchip_kernel(kvm))
> 			r = kvm_vm_ioctl_set_irqchip(kvm, chip);

Keeping the label has the advantage of making the get and set cases a
bit more similar (the get case has to do a copy_to_user after
kvm_vm_ioctl_get_irqchip returns).  Unfortunately struct kvm_irqchip is
quite big (520 bytes) so we don't allocate it on the stack.

So I queued Miaohe's patch.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: remove redundant code in kvm_arch_vm_ioctl
@ 2019-10-21  8:39 linmiaohe
  0 siblings, 0 replies; 4+ messages in thread
From: linmiaohe @ 2019-10-21  8:39 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
	jmattson, joro, mingo, bp, hpa, x86, kvm, linux-kernel


On Mon, 21 Oct 2019, tglx wrote:
>On Mon, 21 Oct 2019, Miaohe Lin wrote:
>> If we reach here with r = 0, we will reassign r = 0 unnecesarry, then 
>> do the label set_irqchip_out work.
>> If we reach here with r != 0, then we will do the label work directly. 
>> So this if statement and r = 0 assignment is redundant.
>
>Can you please get rid of that odd jump label completely?
>
>  		if (irqchip_kernel(kvm))
>			r = kvm_vm_ioctl_set_irqchip(kvm, chip);
>
>Hmm?

Sure, thanks for your reply. I will send patch v2 to complete it.
Thanks again.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-21  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21  2:52 [PATCH] KVM: remove redundant code in kvm_arch_vm_ioctl Miaohe Lin
2019-10-21  8:16 ` Thomas Gleixner
2019-10-21  8:56   ` Paolo Bonzini
2019-10-21  8:39 linmiaohe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).