All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected
@ 2022-09-22 21:35 Peter Xu
  2022-09-22 21:52 ` Philippe Mathieu-Daudé via
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Xu @ 2022-09-22 21:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: peterx, Marc Zyngier, Gavin Shan, Paolo Bonzini

Following commit 4802bf910eee9, add the other missing barrier when marking
the PFN as collected.  This will also be required just like 4802bf910eee9
on weak ordering architectures like aarch64.

Cc: Marc Zyngier <maz@kernel.org>
Cc: Gavin Shan <gshan@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 accel/kvm/kvm-all.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 136c8eaed3..60a044048e 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -728,7 +728,11 @@ static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
 
 static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
 {
-    gfn->flags = KVM_DIRTY_GFN_F_RESET;
+    /*
+     * Write the flags after reading the entry.  Should pair with another
+     * smp_load_acquire() in KVM when reset dirty rings.
+     */
+    qatomic_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET);
 }
 
 /*
-- 
2.32.0



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

* Re: [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected
  2022-09-22 21:35 [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected Peter Xu
@ 2022-09-22 21:52 ` Philippe Mathieu-Daudé via
  2022-09-22 23:33 ` Gavin Shan
  2022-10-14 16:33 ` Peter Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-09-22 21:52 UTC (permalink / raw)
  To: Peter Xu, qemu-devel; +Cc: Marc Zyngier, Gavin Shan, Paolo Bonzini

On 22/9/22 23:35, Peter Xu wrote:
> Following commit 4802bf910eee9, add the other missing barrier when marking
> the PFN as collected.  This will also be required just like 4802bf910eee9
> on weak ordering architectures like aarch64.
> 
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Gavin Shan <gshan@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>   accel/kvm/kvm-all.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 136c8eaed3..60a044048e 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -728,7 +728,11 @@ static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
>   
>   static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
>   {
> -    gfn->flags = KVM_DIRTY_GFN_F_RESET;
> +    /*
> +     * Write the flags after reading the entry.  Should pair with another
> +     * smp_load_acquire() in KVM when reset dirty rings.
> +     */
> +    qatomic_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET);
>   }
>   
>   /*

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


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

* Re: [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected
  2022-09-22 21:35 [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected Peter Xu
  2022-09-22 21:52 ` Philippe Mathieu-Daudé via
@ 2022-09-22 23:33 ` Gavin Shan
  2022-10-14 16:33 ` Peter Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Gavin Shan @ 2022-09-22 23:33 UTC (permalink / raw)
  To: Peter Xu, qemu-devel; +Cc: Marc Zyngier, Paolo Bonzini

On 9/23/22 7:35 AM, Peter Xu wrote:
> Following commit 4802bf910eee9, add the other missing barrier when marking
> the PFN as collected.  This will also be required just like 4802bf910eee9
> on weak ordering architectures like aarch64.
> 
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Gavin Shan <gshan@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>   accel/kvm/kvm-all.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>

> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 136c8eaed3..60a044048e 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -728,7 +728,11 @@ static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
>   
>   static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
>   {
> -    gfn->flags = KVM_DIRTY_GFN_F_RESET;
> +    /*
> +     * Write the flags after reading the entry.  Should pair with another
> +     * smp_load_acquire() in KVM when reset dirty rings.
> +     */
> +    qatomic_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET);
>   }
>   
>   /*
> 



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

* Re: [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected
  2022-09-22 21:35 [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected Peter Xu
  2022-09-22 21:52 ` Philippe Mathieu-Daudé via
  2022-09-22 23:33 ` Gavin Shan
@ 2022-10-14 16:33 ` Peter Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2022-10-14 16:33 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini; +Cc: Marc Zyngier, Gavin Shan, Paolo Bonzini

Ping?



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

end of thread, other threads:[~2022-10-14 16:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 21:35 [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected Peter Xu
2022-09-22 21:52 ` Philippe Mathieu-Daudé via
2022-09-22 23:33 ` Gavin Shan
2022-10-14 16:33 ` Peter Xu

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.