Re: [PATCH 5/6] KVM: selftests: dirty-log: Upgrade dirty_gfn_set_collected() to store-release
On Thu, 22 Sep 2022 22:38:58 +0100, Paolo Bonzini wrote: > > On Thu, Sep 22, 2022 at 7:02 PM Marc Zyngier wrote: > > To make sure that all the writes to the log marking the entries > > as being in need of reset are observed in order, use a > > smp_store_release() when updating the log entry flags. > > > > Signed-off-by: Marc Zyngier > > You also need a load-acquire on the load of gfn->flags in > dirty_gfn_is_dirtied. Otherwise reading cur->slot or cur->offset might > see a stale value. Ah, indeed. smp_wmb() is implemented as DMB ISHST, which only orders writes, and not loads against writes. Global barriers are just confusing. /me goes and repaint the stuff... M. -- Without deviation from the norm, progress is not possible. ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 5/6] KVM: selftests: dirty-log: Upgrade dirty_gfn_set_collected() to store-release
On Thu, Sep 22, 2022 at 7:02 PM Marc Zyngier wrote: > To make sure that all the writes to the log marking the entries > as being in need of reset are observed in order, use a > smp_store_release() when updating the log entry flags. > > Signed-off-by: Marc Zyngier You also need a load-acquire on the load of gfn->flags in dirty_gfn_is_dirtied. Otherwise reading cur->slot or cur->offset might see a stale value. Paolo > --- > tools/testing/selftests/kvm/dirty_log_test.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/dirty_log_test.c > b/tools/testing/selftests/kvm/dirty_log_test.c > index 9c883c94d478..3d29f4bf4f9c 100644 > --- a/tools/testing/selftests/kvm/dirty_log_test.c > +++ b/tools/testing/selftests/kvm/dirty_log_test.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > #include "kvm_util.h" > #include "test_util.h" > @@ -284,7 +285,7 @@ static inline bool dirty_gfn_is_dirtied(struct > kvm_dirty_gfn *gfn) > > static inline void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn) > { > - gfn->flags = KVM_DIRTY_GFN_F_RESET; > + smp_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET); > } > > static uint32_t dirty_ring_collect_one(struct kvm_dirty_gfn *dirty_gfns, > -- > 2.34.1 > ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
[PATCH 5/6] KVM: selftests: dirty-log: Upgrade dirty_gfn_set_collected() to store-release
To make sure that all the writes to the log marking the entries as being in need of reset are observed in order, use a smp_store_release() when updating the log entry flags. Signed-off-by: Marc Zyngier --- tools/testing/selftests/kvm/dirty_log_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c index 9c883c94d478..3d29f4bf4f9c 100644 --- a/tools/testing/selftests/kvm/dirty_log_test.c +++ b/tools/testing/selftests/kvm/dirty_log_test.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "kvm_util.h" #include "test_util.h" @@ -284,7 +285,7 @@ static inline bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn) static inline void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn) { - gfn->flags = KVM_DIRTY_GFN_F_RESET; + smp_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET); } static uint32_t dirty_ring_collect_one(struct kvm_dirty_gfn *dirty_gfns, -- 2.34.1 ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm