All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers
@ 2017-04-11  9:49 Wanpeng Li
  2017-04-11 14:20 ` Paolo Bonzini
  2017-04-12 19:04 ` Radim Krčmář
  0 siblings, 2 replies; 3+ messages in thread
From: Wanpeng Li @ 2017-04-11  9:49 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Paolo Bonzini, Radim Krčmář, Wanpeng Li

From: Wanpeng Li <wanpeng.li@hotmail.com>

virt_xxx memory barriers are implemented trivially using the low-level 
__smp_xxx macros, __smp_xxx is equal to a compiler barrier for strong 
TSO memory model, however, mandatory barriers will unconditional add 
memory barriers, this patch replaces the rmb() in kvm_steal_clock() by 
virt_rmb().

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
 arch/x86/kernel/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 14f65a5..da5c097 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -396,9 +396,9 @@ static u64 kvm_steal_clock(int cpu)
 	src = &per_cpu(steal_time, cpu);
 	do {
 		version = src->version;
-		rmb();
+		virt_rmb();
 		steal = src->steal;
-		rmb();
+		virt_rmb();
 	} while ((version & 1) || (version != src->version));
 
 	return steal;
-- 
2.7.4

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

* Re: [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers
  2017-04-11  9:49 [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers Wanpeng Li
@ 2017-04-11 14:20 ` Paolo Bonzini
  2017-04-12 19:04 ` Radim Krčmář
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2017-04-11 14:20 UTC (permalink / raw)
  To: Wanpeng Li; +Cc: linux-kernel, kvm, Radim Krčmář, Wanpeng Li



----- Original Message -----
> From: "Wanpeng Li" <kernellwp@gmail.com>
> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
> Cc: "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com>, "Wanpeng Li" <wanpeng.li@hotmail.com>
> Sent: Tuesday, April 11, 2017 5:49:21 PM
> Subject: [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers
> 
> From: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> virt_xxx memory barriers are implemented trivially using the low-level
> __smp_xxx macros, __smp_xxx is equal to a compiler barrier for strong
> TSO memory model, however, mandatory barriers will unconditional add
> memory barriers, this patch replaces the rmb() in kvm_steal_clock() by
> virt_rmb().
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
>  arch/x86/kernel/kvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 14f65a5..da5c097 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -396,9 +396,9 @@ static u64 kvm_steal_clock(int cpu)
>  	src = &per_cpu(steal_time, cpu);
>  	do {
>  		version = src->version;
> -		rmb();
> +		virt_rmb();
>  		steal = src->steal;
> -		rmb();
> +		virt_rmb();
>  	} while ((version & 1) || (version != src->version));
>  
>  	return steal;
> --
> 2.7.4

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

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

* Re: [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers
  2017-04-11  9:49 [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers Wanpeng Li
  2017-04-11 14:20 ` Paolo Bonzini
@ 2017-04-12 19:04 ` Radim Krčmář
  1 sibling, 0 replies; 3+ messages in thread
From: Radim Krčmář @ 2017-04-12 19:04 UTC (permalink / raw)
  To: Wanpeng Li; +Cc: linux-kernel, kvm, Paolo Bonzini, Wanpeng Li

2017-04-11 02:49-0700, Wanpeng Li:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> virt_xxx memory barriers are implemented trivially using the low-level 
> __smp_xxx macros, __smp_xxx is equal to a compiler barrier for strong 
> TSO memory model, however, mandatory barriers will unconditional add 
> memory barriers, this patch replaces the rmb() in kvm_steal_clock() by 
> virt_rmb().
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---

Applied to kvm/queue, thanks.

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

end of thread, other threads:[~2017-04-12 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11  9:49 [PATCH] x86/kvm: virt_xxx memory barriers instead of mandatory barriers Wanpeng Li
2017-04-11 14:20 ` Paolo Bonzini
2017-04-12 19:04 ` Radim Krčmář

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.