From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
torvalds@linux-foundation.org
Subject: Re: [PATCH 9/9] kernel: tighten rules for ACCESS ONCE
Date: Wed, 3 Dec 2014 16:16:21 -0800 [thread overview]
Message-ID: <20141204001621.GF25340@linux.vnet.ibm.com> (raw)
In-Reply-To: <1417645821-54731-10-git-send-email-borntraeger@de.ibm.com>
On Wed, Dec 03, 2014 at 11:30:21PM +0100, Christian Borntraeger wrote:
> Now that all non-scalar users of ACCESS_ONCE have been converted
> to READ_ONCE or ASSIGN once, lets tighten ACCESS_ONCE to only
> work on scalar types.
> This variant was proposed by Alexei Starovoitov.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
With or without the updated comment:
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> include/linux/compiler.h | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index 947710e..5ba91de 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -441,8 +441,16 @@ static __always_inline void __assign_once_size(volatile void *p, void *res, int
> * merging, or refetching absolutely anything at any time. Its main intended
> * use is to mediate communication between process-level code and irq/NMI
> * handlers, all running on the same CPU.
This comment is obsolete in the same way as that of READ_ONCE() and
ASSIGN_ONCE(), but probably more to the point to just get rid of
ACCESS_ONCE(). ;-)
> + *
> + * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE
> + * on a union member will work as long as the size of the member matches the
> + * size of the union and the size is smaller than word size.
> + * If possible READ_ONCE/ASSIGN_ONCE should be used instead.
> */
> -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
> +#define __ACCESS_ONCE(x) ({ \
> + __maybe_unused typeof(x) __var = 0; \
> + (volatile typeof(x) *)&(x); })
> +#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
>
> /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
> #ifdef CONFIG_KPROBES
> --
> 1.9.3
>
next prev parent reply other threads:[~2014-12-04 0:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 22:30 [PATCHv4 0/9] ACCESS_ONCE and non-scalar accesses Christian Borntraeger
2014-12-03 22:30 ` [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE Christian Borntraeger
2014-12-04 0:07 ` Paul E. McKenney
2014-12-04 9:24 ` Christian Borntraeger
2014-12-04 14:41 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 2/9] mm: replace ACCESS_ONCE with READ_ONCE or barriers Christian Borntraeger
2014-12-04 0:09 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 3/9] x86/spinlock: Replace ACCESS_ONCE with READ_ONCE Christian Borntraeger
2014-12-04 0:10 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 4/9] x86/gup: " Christian Borntraeger
2014-12-04 0:10 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 5/9] mips/gup: " Christian Borntraeger
2014-12-04 0:11 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 6/9] arm64/spinlock: Replace ACCESS_ONCE READ_ONCE Christian Borntraeger
2014-12-04 0:11 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 7/9] arm/spinlock: Replace ACCESS_ONCE with READ_ONCE Christian Borntraeger
2014-12-04 0:12 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 8/9] s390/kvm: REPLACE " Christian Borntraeger
2014-12-04 0:12 ` Paul E. McKenney
2014-12-03 22:30 ` [PATCH 9/9] kernel: tighten rules for ACCESS ONCE Christian Borntraeger
2014-12-04 0:16 ` Paul E. McKenney [this message]
2014-12-04 9:28 ` Christian Borntraeger
2014-12-04 14:41 ` Paul E. McKenney
2014-12-04 15:24 ` [PATCHv4 0/9] ACCESS_ONCE and non-scalar accesses Christian Borntraeger
2014-12-04 23:40 ` Linus Torvalds
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=20141204001621.GF25340@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox