From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v11 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c
Date: Thu, 5 Nov 2015 16:48:20 +0000 [thread overview]
Message-ID: <20151105164820.GF32247@leverpostej> (raw)
In-Reply-To: <1446737696-9749-1-git-send-email-stefano.stabellini@eu.citrix.com>
Hi,
> +static u64 get64(const u64 *p)
> +{
> + u64 ret;
> +
> + if (BITS_PER_LONG < 64) {
> + u32 *p32 = (u32 *)p;
> + u32 h, l;
> +
> + /*
> + * Read high then low, and then make sure high is
> + * still the same; this will only loop if low wraps
> + * and carries into high.
> + * XXX some clean way to make this endian-proof?
> + */
> + do {
> + h = p32[1];
> + barrier();
> + l = p32[0];
> + barrier();
> + } while (p32[1] != h);
I realise this is simply a move of existing code, but it may be better
to instead have:
do {
h = READ_ONCE(p32[1]);
l = READ_ONCE(p32[0]);
} while (READ_ONCE(p32[1] != h);
Which ensures that each load is a single access (though it almost
certainly would be anyway), and prevents the compiler from having to
reload any other memory locations (which the current barrier() usage
forces).
> +
> + ret = (((u64)h) << 32) | l;
> + } else
> + ret = *p;
Likewise, this would be better as READ_ONCE(*p), to force a single
access.
> +
> + return ret;
> +}
> + do {
> + state_time = get64(&state->state_entry_time);
> + barrier();
> + *res = *state;
> + barrier();
You can also have:
*res = READ_ONCE(*state);
That will which will handle the barriers implicitly.
Thanks,
Mark.
> + } while (get64(&state->state_entry_time) != state_time);
> +}
WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, linux@arm.linux.org.uk,
Ian Campbell <ian.campbell@citrix.com>,
arnd@arndb.de, marc.zyngier@arm.com, catalin.marinas@arm.com,
konrad.wilk@oracle.com, will.deacon@arm.com,
linux-kernel@vger.kernel.org, olof@lixom.net,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v11 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c
Date: Thu, 5 Nov 2015 16:48:20 +0000 [thread overview]
Message-ID: <20151105164820.GF32247@leverpostej> (raw)
In-Reply-To: <1446737696-9749-1-git-send-email-stefano.stabellini@eu.citrix.com>
Hi,
> +static u64 get64(const u64 *p)
> +{
> + u64 ret;
> +
> + if (BITS_PER_LONG < 64) {
> + u32 *p32 = (u32 *)p;
> + u32 h, l;
> +
> + /*
> + * Read high then low, and then make sure high is
> + * still the same; this will only loop if low wraps
> + * and carries into high.
> + * XXX some clean way to make this endian-proof?
> + */
> + do {
> + h = p32[1];
> + barrier();
> + l = p32[0];
> + barrier();
> + } while (p32[1] != h);
I realise this is simply a move of existing code, but it may be better
to instead have:
do {
h = READ_ONCE(p32[1]);
l = READ_ONCE(p32[0]);
} while (READ_ONCE(p32[1] != h);
Which ensures that each load is a single access (though it almost
certainly would be anyway), and prevents the compiler from having to
reload any other memory locations (which the current barrier() usage
forces).
> +
> + ret = (((u64)h) << 32) | l;
> + } else
> + ret = *p;
Likewise, this would be better as READ_ONCE(*p), to force a single
access.
> +
> + return ret;
> +}
> + do {
> + state_time = get64(&state->state_entry_time);
> + barrier();
> + *res = *state;
> + barrier();
You can also have:
*res = READ_ONCE(*state);
That will which will handle the barriers implicitly.
Thanks,
Mark.
> + } while (get64(&state->state_entry_time) != state_time);
> +}
next prev parent reply other threads:[~2015-11-05 16:48 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 15:33 [PATCH v11 0/5] xen/arm/arm64: CONFIG_PARAVIRT and stolen ticks accounting Stefano Stabellini
2015-11-05 15:33 ` Stefano Stabellini
2015-11-05 15:34 ` [PATCH v11 1/5] xen: move xen_setup_runstate_info and get_runstate_snapshot to drivers/xen/time.c Stefano Stabellini
2015-11-05 15:34 ` Stefano Stabellini
2015-11-05 16:48 ` Mark Rutland [this message]
2015-11-05 16:48 ` Mark Rutland
2015-11-06 11:11 ` Stefano Stabellini
2015-11-06 11:11 ` Stefano Stabellini
2015-11-06 12:00 ` Mark Rutland
2015-11-06 12:00 ` Mark Rutland
2015-11-05 15:34 ` [PATCH v11 2/5] missing include asm/paravirt.h in cputime.c Stefano Stabellini
2015-11-05 15:34 ` Stefano Stabellini
2015-11-05 16:40 ` Peter Zijlstra
2015-11-05 16:40 ` Peter Zijlstra
2015-11-05 17:30 ` Stefano Stabellini
2015-11-05 17:30 ` Stefano Stabellini
2015-11-09 17:36 ` Peter Zijlstra
2015-11-09 17:36 ` Peter Zijlstra
2015-11-10 11:27 ` Stefano Stabellini
2015-11-10 11:27 ` Stefano Stabellini
2015-11-10 11:27 ` Stefano Stabellini
2015-11-10 12:19 ` Peter Zijlstra
2015-11-10 12:19 ` Peter Zijlstra
2015-11-05 15:34 ` [PATCH v11 3/5] arm: introduce CONFIG_PARAVIRT, PARAVIRT_TIME_ACCOUNTING and pv_time_ops Stefano Stabellini
2015-11-05 15:34 ` Stefano Stabellini
2015-11-10 14:12 ` Stefano Stabellini
2015-11-10 14:12 ` Stefano Stabellini
2015-11-10 14:12 ` Stefano Stabellini
2015-11-20 14:31 ` Stefano Stabellini
2015-11-20 14:31 ` Stefano Stabellini
2015-11-20 14:31 ` Stefano Stabellini
2015-11-20 14:36 ` Christopher Covington
2015-11-20 14:36 ` Christopher Covington
2015-11-20 14:40 ` Stefano Stabellini
2015-11-20 14:40 ` Stefano Stabellini
2015-11-20 14:40 ` Stefano Stabellini
2015-11-20 16:47 ` Russell King - ARM Linux
2015-11-20 16:47 ` Russell King - ARM Linux
2015-11-20 17:16 ` Stefano Stabellini
2015-11-20 17:16 ` Stefano Stabellini
2015-11-20 17:16 ` Stefano Stabellini
2015-11-05 15:34 ` [PATCH v11 4/5] arm64: " Stefano Stabellini
2015-11-05 15:34 ` Stefano Stabellini
2015-11-10 14:11 ` Stefano Stabellini
2015-11-10 14:11 ` Stefano Stabellini
2015-11-10 14:11 ` Stefano Stabellini
2015-11-17 17:29 ` Will Deacon
2015-11-17 17:29 ` Will Deacon
2015-11-17 17:34 ` Marc Zyngier
2015-11-17 17:34 ` Marc Zyngier
2015-11-17 17:35 ` Will Deacon
2015-11-17 17:35 ` Will Deacon
2015-11-20 12:19 ` Stefano Stabellini
2015-11-20 12:19 ` Stefano Stabellini
2015-11-20 12:19 ` Stefano Stabellini
2015-11-05 15:34 ` [PATCH v11 5/5] xen/arm: account for stolen ticks Stefano Stabellini
2015-11-05 15:34 ` Stefano Stabellini
2015-11-05 16:57 ` Mark Rutland
2015-11-05 16:57 ` Mark Rutland
2015-11-06 11:39 ` Stefano Stabellini
2015-11-06 11:39 ` Stefano Stabellini
2015-11-06 11:41 ` David Vrabel
2015-11-06 11:41 ` David Vrabel
2015-11-06 11:59 ` Mark Rutland
2015-11-06 11:59 ` Mark Rutland
2015-11-06 13:25 ` Vitaly Kuznetsov
2015-11-06 13:25 ` Vitaly Kuznetsov
2015-11-06 13:19 ` Vitaly Kuznetsov
2015-11-06 13:19 ` Vitaly Kuznetsov
2015-11-06 13:19 ` Vitaly Kuznetsov
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=20151105164820.GF32247@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 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.