Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163033AbbKTPDf (ORCPT ); Fri, 20 Nov 2015 10:03:35 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:45535 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935176AbbKTPDG (ORCPT ); Fri, 20 Nov 2015 10:03:06 -0500 X-IronPort-AV: E=Sophos;i="5.20,323,1444694400"; d="scan'208";a="319592399" From: Stefano Stabellini To: CC: , , Stefano Stabellini , Mark Rutland , , , Subject: [PATCH] xen/time: use READ_ONCE Date: Fri, 20 Nov 2015 15:02:44 +0000 Message-ID: <1448031764-23669-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1684 Lines: 65 Use READ_ONCE through the code, rather than explicit barriers. Suggested-by: Mark Rutland Signed-off-by: Stefano Stabellini CC: Mark Rutland 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/