All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/time: use READ_ONCE
@ 2015-11-20 15:02 ` Stefano Stabellini
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2015-11-20 15:02 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Stefano.Stabellini, Stefano Stabellini,
	Mark Rutland, konrad.wilk, david.vrabel, boris.ostrovsky

Use READ_ONCE through the code, rather than explicit barriers.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Mark Rutland <mark.rutland@arm.com>
CC: konrad.wilk@oracle.com
CC: david.vrabel@citrix.com
CC: boris.ostrovsky@oracle.com
---
 drivers/xen/time.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 433fe24..7107842 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -25,7 +25,7 @@ static u64 get64(const u64 *p)
 
 	if (BITS_PER_LONG < 64) {
 		u32 *p32 = (u32 *)p;
-		u32 h, l;
+		u32 h, l, h2;
 
 		/*
 		 * Read high then low, and then make sure high is
@@ -34,15 +34,14 @@ static u64 get64(const u64 *p)
 		 * XXX some clean way to make this endian-proof?
 		 */
 		do {
-			h = p32[1];
-			barrier();
-			l = p32[0];
-			barrier();
-		} while (p32[1] != h);
+			h = READ_ONCE(p32[1]);
+			l = READ_ONCE(p32[0]);
+			h2 = READ_ONCE(p32[1]);
+		} while(h2 != h);
 
 		ret = (((u64)h) << 32) | l;
 	} else
-		ret = *p;
+		ret = READ_ONCE(*p);
 
 	return ret;
 }
@@ -66,9 +65,7 @@ void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
 	 */
 	do {
 		state_time = get64(&state->state_entry_time);
-		barrier();
-		*res = *state;
-		barrier();
+		*res = READ_ONCE(*state);
 	} while (get64(&state->state_entry_time) != state_time);
 }
 
-- 
1.7.10.4


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

* [PATCH] xen/time: use READ_ONCE
@ 2015-11-20 15:02 ` Stefano Stabellini
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2015-11-20 15:02 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Stefano.Stabellini, Stefano Stabellini,
	Mark Rutland, konrad.wilk, david.vrabel, boris.ostrovsky

Use READ_ONCE through the code, rather than explicit barriers.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Mark Rutland <mark.rutland@arm.com>
CC: konrad.wilk@oracle.com
CC: david.vrabel@citrix.com
CC: boris.ostrovsky@oracle.com
---
 drivers/xen/time.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 433fe24..7107842 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -25,7 +25,7 @@ static u64 get64(const u64 *p)
 
 	if (BITS_PER_LONG < 64) {
 		u32 *p32 = (u32 *)p;
-		u32 h, l;
+		u32 h, l, h2;
 
 		/*
 		 * Read high then low, and then make sure high is
@@ -34,15 +34,14 @@ static u64 get64(const u64 *p)
 		 * XXX some clean way to make this endian-proof?
 		 */
 		do {
-			h = p32[1];
-			barrier();
-			l = p32[0];
-			barrier();
-		} while (p32[1] != h);
+			h = READ_ONCE(p32[1]);
+			l = READ_ONCE(p32[0]);
+			h2 = READ_ONCE(p32[1]);
+		} while(h2 != h);
 
 		ret = (((u64)h) << 32) | l;
 	} else
-		ret = *p;
+		ret = READ_ONCE(*p);
 
 	return ret;
 }
@@ -66,9 +65,7 @@ void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
 	 */
 	do {
 		state_time = get64(&state->state_entry_time);
-		barrier();
-		*res = *state;
-		barrier();
+		*res = READ_ONCE(*state);
 	} while (get64(&state->state_entry_time) != state_time);
 }
 
-- 
1.7.10.4

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

* Re: [Xen-devel] [PATCH] xen/time: use READ_ONCE
  2015-11-20 15:02 ` Stefano Stabellini
@ 2015-11-26 17:45   ` David Vrabel
  -1 siblings, 0 replies; 4+ messages in thread
From: David Vrabel @ 2015-11-26 17:45 UTC (permalink / raw)
  To: Stefano Stabellini, xen-devel
  Cc: Mark Rutland, linux-kernel, david.vrabel, boris.ostrovsky

On 20/11/15 15:02, Stefano Stabellini wrote:
> Use READ_ONCE through the code, rather than explicit barriers.

Applied to for-linus-4.5, thanks.

David

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

* Re: [PATCH] xen/time: use READ_ONCE
@ 2015-11-26 17:45   ` David Vrabel
  0 siblings, 0 replies; 4+ messages in thread
From: David Vrabel @ 2015-11-26 17:45 UTC (permalink / raw)
  To: Stefano Stabellini, xen-devel
  Cc: Mark Rutland, boris.ostrovsky, linux-kernel, david.vrabel

On 20/11/15 15:02, Stefano Stabellini wrote:
> Use READ_ONCE through the code, rather than explicit barriers.

Applied to for-linus-4.5, thanks.

David

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

end of thread, other threads:[~2015-11-26 17:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-20 15:02 [PATCH] xen/time: use READ_ONCE Stefano Stabellini
2015-11-20 15:02 ` Stefano Stabellini
2015-11-26 17:45 ` [Xen-devel] " David Vrabel
2015-11-26 17:45   ` David Vrabel

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.