From: David Howells <dhowells@redhat.com>
To: Will Deacon <will@kernel.org>
Cc: dhowells@redhat.com, torvalds@linuxfoundation.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
peterz@infradead.org
Subject: Re: [RFC][PATCH] pipe: Convert ring to head/tail
Date: Tue, 17 Sep 2019 14:51:35 +0100 [thread overview]
Message-ID: <28447.1568728295@warthog.procyon.org.uk> (raw)
In-Reply-To: <20190915145905.hd5xkc7uzulqhtzr@willie-the-truck>
Will Deacon <will@kernel.org> wrote:
> > + /* Barrier: head belongs to the write side, so order reading
> > + * the data after reading the head pointer.
> > + */
> > + unsigned int head = READ_ONCE(pipe->head);
>
> Hmm, I don't understand this. Since READ_ONCE() doesn't imply a barrier,
> how are you enforcing the read-read ordering in the CPU?
It does imply a barrier: smp_read_barrier_depends(). I believe that's
> What is the purpose of saying "This may need to insert a barrier"? Can this
> function be overridden or something?
I mean it's arch-dependent whether READ_ONCE() inserts a barrier or not.
> Saying that "This inserts a barrier" feels misleading, because READ_ONCE()
> doesn't do that.
Yes it does - on the Alpha:
[arch/alpha/include/asm/barrier.h]
#define read_barrier_depends() __asm__ __volatile__("mb": : :"memory")
[include/asm-generic/barrier.h]
#ifndef __smp_read_barrier_depends
#define __smp_read_barrier_depends() read_barrier_depends()
#endif
...
#ifndef smp_read_barrier_depends
#define smp_read_barrier_depends() __smp_read_barrier_depends()
#endif
[include/linux/compiler.h]
#define __READ_ONCE(x, check) \
({ \
union { typeof(x) __val; char __c[1]; } __u; \
if (check) \
__read_once_size(&(x), __u.__c, sizeof(x)); \
else \
__read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \
__u.__val; \
})
#define READ_ONCE(x) __READ_ONCE(x, 1)
See:
commit 76ebbe78f7390aee075a7f3768af197ded1bdfbb
Author: Will Deacon <will.deacon@arm.com>
Date: Tue Oct 24 11:22:47 2017 +0100
locking/barriers: Add implicit smp_read_barrier_depends() to READ_ONCE()
David
next prev parent reply other threads:[~2019-09-17 13:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 13:00 [RFC][PATCH] pipe: Convert ring to head/tail David Howells
2019-09-13 13:06 ` My just-shovel-data-through-for-X-amount-of-time test David Howells
2019-09-15 14:59 ` [RFC][PATCH] pipe: Convert ring to head/tail Will Deacon
2019-09-17 13:51 ` David Howells [this message]
2019-09-17 17:07 ` Will Deacon
2019-09-18 15:43 ` Do we need to correct barriering in circular-buffers.rst? David Howells
2019-09-18 16:48 ` Linus Torvalds
2019-09-19 13:59 ` David Howells
2019-09-19 15:59 ` Linus Torvalds
2019-09-23 14:49 ` Peter Zijlstra
2019-09-27 9:51 ` Andrea Parri
2019-09-27 12:49 ` Peter Zijlstra
2019-09-27 15:57 ` Peter Zijlstra
2019-09-27 20:43 ` Nick Desaulniers
2019-09-27 21:58 ` Nick Desaulniers
2019-09-30 9:33 ` Peter Zijlstra
2019-09-30 11:54 ` Peter Zijlstra
2019-09-30 12:02 ` Peter Zijlstra
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=28447.1568728295@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linuxfoundation.org \
--cc=will@kernel.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.