All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	linux-kernel@vger.kernel.org, dave@stgolabs.net, dbueso@suse.de,
	dvyukov@google.com, jasowang@redhat.com, kvm@vger.kernel.org,
	netdev@vger.kernel.org, paulmck@linux.vnet.ibm.com,
	virtualization@lists.linux-foundation.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE()
Date: Fri, 25 Nov 2016 14:35:39 +0000	[thread overview]
Message-ID: <20161125143538.GC28715@leverpostej> (raw)
In-Reply-To: <20161125124044.GN3092@twins.programming.kicks-ass.net>

On Fri, Nov 25, 2016 at 01:40:44PM +0100, Peter Zijlstra wrote:
> On Fri, Nov 25, 2016 at 12:23:56PM +0000, Mark Rutland wrote:
> > Naming will be problematic; calling them ATOMIC_* makes tham sound like
> > they work on atomic_t. That and I have no idea how to ensure correct
> > usage tree-wide; I'm not sure if/how Coccinelle can help.
> > 
> > Peter, thoughts?
> 
> Something like so perhaps?

> /*
>  * Provide accessors for Single-Copy atomicy.
>  *
>  * That is, ensure that machine word sized loads/stores to naturally
>  * aligned variables are single instructions.

Minor nit: this sounds like we *only* support the machine word size,
whereas (excluding alpha IIRC) we can generally acccess power-of-two
sizes from byte up to that.

So perhaps:

	That is, ensure that loads/stores are made with single
	instructions, where the machine can perform a tear-free access
	of that size.

>  * By reason of not being able to use C11 atomic crud, use our beloved
>  * volatile qualifier. Since volatile tells the compiler the value can
>  * be changed behind its back, it must use Single-Copy atomic loads and
>  * stores to access them, otherwise it runs the risk of load/store
>  * tearing.
>  */
> 
> #define SINGLE_LOAD(x)						\
> {(								\
> 	compiletime_assert_atomic_type(typeof(x));		\
> 	WARN_SINGLE_COPY_ALIGNMENT(&(x));			\
> 	READ_ONCE(x);						\
> })
> 
> #define SINGLE_STORE(x, v)					\
> ({								\
> 	compiletime_assert_atomic_type(typeof(x));		\
> 	WARN_SINGLE_COPY_ALIGNMENT(&(x));			\
> 	WRITE_ONCE(x, v);					\
> })

Modulo your type comment, and mine above, this looks good to me.

Thanks,
Mark.

  parent reply	other threads:[~2016-11-25 14:35 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 10:25 [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE() Mark Rutland
2016-11-24 10:25 ` [PATCH 1/3] tools/virtio: fix READ_ONCE() Mark Rutland
2016-11-24 11:34   ` Cornelia Huck
2016-11-24 11:34     ` Cornelia Huck
2016-11-25  2:38   ` Jason Wang
2016-11-25  2:38     ` Jason Wang
2016-11-24 10:25 ` Mark Rutland
2016-11-24 10:25 ` [PATCH 2/3] vringh: kill off ACCESS_ONCE() Mark Rutland
2016-11-24 10:25 ` Mark Rutland
2016-11-24 11:10   ` Christian Borntraeger
2016-11-24 11:10     ` Christian Borntraeger
2016-11-24 11:35   ` Cornelia Huck
2016-11-24 11:35     ` Cornelia Huck
2016-11-25  2:40   ` Jason Wang
2016-11-25  2:40     ` Jason Wang
2016-11-24 10:25 ` [PATCH 3/3] tools/virtio: use {READ,WRITE}_ONCE() in uaccess.h Mark Rutland
2016-11-24 11:37   ` Cornelia Huck
2016-11-24 11:37     ` Cornelia Huck
2016-11-25  2:40   ` Jason Wang
2016-11-25  2:40     ` Jason Wang
2016-11-24 10:25 ` Mark Rutland
2016-11-24 20:36 ` [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE() Michael S. Tsirkin
2016-11-24 20:36   ` Michael S. Tsirkin
2016-11-25 11:22   ` Mark Rutland
2016-11-25 11:22   ` Mark Rutland
2016-11-25 11:33     ` Christian Borntraeger
2016-11-25 11:33       ` Christian Borntraeger
2016-11-25 12:23       ` Mark Rutland
2016-11-25 12:40         ` Peter Zijlstra
2016-11-25 12:40           ` Peter Zijlstra
2016-11-25 12:44           ` Peter Zijlstra
2016-11-25 12:44             ` Peter Zijlstra
2016-11-25 14:56             ` Boqun Feng
2016-11-25 14:56               ` Boqun Feng
2016-11-25 15:21               ` Dmitry Vyukov via Virtualization
2016-11-25 15:21               ` Dmitry Vyukov
2016-11-25 16:10                 ` Mark Rutland
2016-11-25 16:10                 ` Mark Rutland
2016-11-25 16:17                   ` Peter Zijlstra
2016-11-25 16:17                     ` Peter Zijlstra
2016-11-25 16:32                     ` Mark Rutland
2016-11-25 16:32                     ` Mark Rutland
2016-11-25 16:49                     ` Christian Borntraeger
2016-11-25 16:49                       ` Christian Borntraeger
2016-11-25 17:28                       ` Mark Rutland
2016-11-25 17:42                         ` Peter Zijlstra
2016-11-25 17:42                           ` Peter Zijlstra
2016-11-25 18:46                         ` Christian Borntraeger
2016-11-25 18:46                           ` Christian Borntraeger
2016-11-25 17:28                       ` Mark Rutland
2016-11-25 21:08                       ` Michael S. Tsirkin
2016-11-25 21:08                         ` Michael S. Tsirkin
2016-11-25 21:45                         ` Christian Borntraeger
2016-11-25 21:45                           ` Christian Borntraeger
2016-11-25 17:28                     ` Dmitry Vyukov via Virtualization
2016-11-25 17:28                     ` Dmitry Vyukov
2016-11-25 17:43                       ` Mark Rutland
2016-11-25 17:43                       ` Mark Rutland
2016-11-25 17:52                       ` Linus Torvalds
2016-11-25 17:52                         ` Linus Torvalds
2016-11-25 18:07                         ` Mark Rutland
2016-11-25 18:47                           ` Linus Torvalds
2016-11-25 18:47                             ` Linus Torvalds
2016-11-25 18:07                         ` Mark Rutland
2016-11-25 14:35           ` Mark Rutland [this message]
2016-11-25 14:35           ` Mark Rutland
2016-11-25 12:23       ` Mark Rutland
  -- strict thread matches above, loose matches on Subject: below --
2016-11-24 10:25 Mark Rutland

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=20161125143538.GC28715@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --cc=dvyukov@google.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    --cc=virtualization@lists.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 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.