linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: async_pf: drop kvm_arch_async_page_present wrappers
@ 2020-01-21 13:48 Paolo Bonzini
  2020-01-21 18:42 ` Christian Borntraeger
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2020-01-21 13:48 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Andy Lutomirski, Christian Borntraeger

The wrappers make it less clear that the position of the call
to kvm_arch_async_page_present depends on the architecture, and
that only one of the two call sites will actually be active.
Remove them.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 virt/kvm/async_pf.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index d8ef708a2ef6..15e5b037f92d 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -17,21 +17,6 @@
 #include "async_pf.h"
 #include <trace/events/kvm.h>
 
-static inline void kvm_async_page_present_sync(struct kvm_vcpu *vcpu,
-					       struct kvm_async_pf *work)
-{
-#ifdef CONFIG_KVM_ASYNC_PF_SYNC
-	kvm_arch_async_page_present(vcpu, work);
-#endif
-}
-static inline void kvm_async_page_present_async(struct kvm_vcpu *vcpu,
-						struct kvm_async_pf *work)
-{
-#ifndef CONFIG_KVM_ASYNC_PF_SYNC
-	kvm_arch_async_page_present(vcpu, work);
-#endif
-}
-
 static struct kmem_cache *async_pf_cache;
 
 int kvm_async_pf_init(void)
@@ -80,7 +65,8 @@ static void async_pf_execute(struct work_struct *work)
 	if (locked)
 		up_read(&mm->mmap_sem);
 
-	kvm_async_page_present_sync(vcpu, apf);
+	if (IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
+		kvm_arch_async_page_present(vcpu, apf);
 
 	spin_lock(&vcpu->async_pf.lock);
 	list_add_tail(&apf->link, &vcpu->async_pf.done);
@@ -157,7 +143,8 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu)
 		spin_unlock(&vcpu->async_pf.lock);
 
 		kvm_arch_async_page_ready(vcpu, work);
-		kvm_async_page_present_async(vcpu, work);
+		if (!IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
+			kvm_arch_async_page_present(vcpu, work);
 
 		list_del(&work->queue);
 		vcpu->async_pf.queued--;
-- 
1.8.3.1


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

* Re: [PATCH] KVM: async_pf: drop kvm_arch_async_page_present wrappers
  2020-01-21 13:48 [PATCH] KVM: async_pf: drop kvm_arch_async_page_present wrappers Paolo Bonzini
@ 2020-01-21 18:42 ` Christian Borntraeger
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2020-01-21 18:42 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel, kvm; +Cc: Andy Lutomirski



On 21.01.20 14:48, Paolo Bonzini wrote:
> The wrappers make it less clear that the position of the call
> to kvm_arch_async_page_present depends on the architecture, and
> that only one of the two call sites will actually be active.
> Remove them.
> 
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

looks sane. The binary code also looks identical.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>


> ---
>  virt/kvm/async_pf.c | 21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
> index d8ef708a2ef6..15e5b037f92d 100644
> --- a/virt/kvm/async_pf.c
> +++ b/virt/kvm/async_pf.c
> @@ -17,21 +17,6 @@
>  #include "async_pf.h"
>  #include <trace/events/kvm.h>
>  
> -static inline void kvm_async_page_present_sync(struct kvm_vcpu *vcpu,
> -					       struct kvm_async_pf *work)
> -{
> -#ifdef CONFIG_KVM_ASYNC_PF_SYNC
> -	kvm_arch_async_page_present(vcpu, work);
> -#endif
> -}
> -static inline void kvm_async_page_present_async(struct kvm_vcpu *vcpu,
> -						struct kvm_async_pf *work)
> -{
> -#ifndef CONFIG_KVM_ASYNC_PF_SYNC
> -	kvm_arch_async_page_present(vcpu, work);
> -#endif
> -}
> -
>  static struct kmem_cache *async_pf_cache;
>  
>  int kvm_async_pf_init(void)
> @@ -80,7 +65,8 @@ static void async_pf_execute(struct work_struct *work)
>  	if (locked)
>  		up_read(&mm->mmap_sem);
>  
> -	kvm_async_page_present_sync(vcpu, apf);
> +	if (IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
> +		kvm_arch_async_page_present(vcpu, apf);
>  
>  	spin_lock(&vcpu->async_pf.lock);
>  	list_add_tail(&apf->link, &vcpu->async_pf.done);
> @@ -157,7 +143,8 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu)
>  		spin_unlock(&vcpu->async_pf.lock);
>  
>  		kvm_arch_async_page_ready(vcpu, work);
> -		kvm_async_page_present_async(vcpu, work);
> +		if (!IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
> +			kvm_arch_async_page_present(vcpu, work);
>  
>  		list_del(&work->queue);
>  		vcpu->async_pf.queued--;
> 


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

* Re: [PATCH] KVM: async_pf: drop kvm_arch_async_page_present wrappers
@ 2020-01-22  2:19 linmiaohe
  0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-01-22  2:19 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Andy Lutomirski, Christian Borntraeger, linux-kernel, kvm

Hi:
Paolo Bonzini <pbonzini@redhat.com> wrote:
>The wrappers make it less clear that the position of the call to kvm_arch_async_page_present depends on the architecture, and that only one of the two call sites will actually be active.
>Remove them.
>
>Cc: Andy Lutomirski <luto@kernel.org>
>Cc: Christian Borntraeger <borntraeger@de.ibm.com>
>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>---
> virt/kvm/async_pf.c | 21 ++++-----------------
> 1 file changed, 4 insertions(+), 17 deletions(-)
>
>-static inline void kvm_async_page_present_sync(struct kvm_vcpu *vcpu,
>-					       struct kvm_async_pf *work)
>-{
>-#ifdef CONFIG_KVM_ASYNC_PF_SYNC
>-	kvm_arch_async_page_present(vcpu, work);
>-#endif
>-}
>-static inline void kvm_async_page_present_async(struct kvm_vcpu *vcpu,
>-						struct kvm_async_pf *work)
>-{
>-#ifndef CONFIG_KVM_ASYNC_PF_SYNC
>-	kvm_arch_async_page_present(vcpu, work);
>-#endif
>-}
>-

Actually, these two functions took me some minutes to note the difference between them.
I thought they do the same thing and really confused me ... :)

> static struct kmem_cache *async_pf_cache;
> 
> int kvm_async_pf_init(void)
>@@ -80,7 +65,8 @@ static void async_pf_execute(struct work_struct *work)
> 	if (locked)
> 		up_read(&mm->mmap_sem);
> 
>-	kvm_async_page_present_sync(vcpu, apf);
>+	if (IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
>+		kvm_arch_async_page_present(vcpu, apf);
> 
> 	spin_lock(&vcpu->async_pf.lock);
> 	list_add_tail(&apf->link, &vcpu->async_pf.done); @@ -157,7 +143,8 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu)
> 		spin_unlock(&vcpu->async_pf.lock);
> 
> 		kvm_arch_async_page_ready(vcpu, work);
>-		kvm_async_page_present_async(vcpu, work);
>+		if (!IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
>+			kvm_arch_async_page_present(vcpu, work);
> 
> 		list_del(&work->queue);
> 		vcpu->async_pf.queued--;
>--
>1.8.3.1

This patch really helps. Thanks!

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>


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

end of thread, other threads:[~2020-01-22  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-21 13:48 [PATCH] KVM: async_pf: drop kvm_arch_async_page_present wrappers Paolo Bonzini
2020-01-21 18:42 ` Christian Borntraeger
2020-01-22  2:19 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).