From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: <xen-devel@lists.xensource.com>
Cc: <linux-kernel@vger.kernel.org>,
<Stefano.Stabellini@eu.citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Mark Rutland <mark.rutland@arm.com>, <konrad.wilk@oracle.com>,
<david.vrabel@citrix.com>, <boris.ostrovsky@oracle.com>
Subject: [PATCH] xen/time: use READ_ONCE
Date: Fri, 20 Nov 2015 15:02:44 +0000 [thread overview]
Message-ID: <1448031764-23669-1-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
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
next reply other threads:[~2015-11-20 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 15:02 Stefano Stabellini [this message]
2015-11-26 17:45 ` [Xen-devel] [PATCH] xen/time: use READ_ONCE David Vrabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448031764-23669-1-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox