From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Christoph Lameter <cl@linux.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Andrey Konovalov <andreyknvl@google.com>,
Alexander Potapenko <glider@google.com>
Subject: Re: Store Buffers (was Re: Is it OK to pass non-acquired objects to kfree?)
Date: Wed, 9 Sep 2015 17:08:47 -0700 [thread overview]
Message-ID: <20150910000847.GV4029@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1509091812500.21983@east.gentwo.org>
On Wed, Sep 09, 2015 at 06:23:11PM -0500, Christoph Lameter wrote:
> On Wed, 9 Sep 2015, Paul E. McKenney wrote:
>
> > > > > A processor that can randomly defer writes to cachelines in the face of
> > > > > other processors owning cachelines exclusively does not seem sane to me.
> > > > > In fact its no longer exclusive.
> > > >
> > > > Welcome to the wonderful world of store buffers, which are present even
> > > > on strongly ordered systems such as x86 and the mainframe.
> > >
> > > Store buffers hold complete cachelines that have been written to by a
> > > processor.
> >
> > In many cases, partial cachelines. If the cacheline is not available
> > locally, the processor cannot know the contents of the rest of the cache
> > line, only the contents of the portion that it recently stored into.
>
> For a partial cacheline it would have to read the rest of the cacheline
> before updating. And I would expect the processor to have exclusive access
> to the cacheline that is held in a store buffer. If not then there is
> trouble afoot.
Yep. The store buffer would hold part of the cacheline, gain exclusive
access to that cacheline, then update it.
> > > Hmmm... Guess I need to think more about this. Dont know the
> > > detail here on how they interact with cacheline exclusivity and stuff.
> >
> > A large number of stores to the same variable can happen concurrently,
> > and the system can stitch together the order of these stores after
> > the fact.
>
> Well thats what I know. The exact way the store buffers interact with
> cache coherency is what I do not know.
That would vary among systems and be highly optimized.
> > > > > Sounds like the atomic_read needs more barriers.
> > > >
> > > > We all know that this won't happen.
> > >
> > > Well then welcome to the wonderful world of a broken kernel. Still
> > > wondering what this has to do with slab allocators.
> >
> > The concern I have is that the compiler might be able to reorder the
> > running CPU's last accesses to an object that is to be kfree()ed with
> > kfree()'s accesses. The issue being that the compiler is within its
> > rights to assume pointers to different types don't alias unless one of the
> > types is char * (or some such, Dmitry can correct me if I am confused).
>
> Hmmm... Yeah if one assumes that the object is going to be handled by a
> different processor then that is a valid concern but if its on the same
> processor then the guarantee is that the changes become visible to the
> exeucting thread in program order. That is enough.
The CPU is indeed constrained in this way, but the compiler is not.
In particular, the CPU must do exact alias analysis, while the compiler
is permitted to do approximate alias analysis in some cases. However,
in gcc builds of the Linux kernel, I believe that the -fno-strict-aliasing
gcc command-line argument forces exact alias analysis.
Dmitry, anything that I am missing?
> The transfer to another processor is guarded by locks and I think that
> those are enough to ensure that the cachelines become visible in a
> controlled fashion.
For the kfree()-to-kmalloc() path, I do believe that you are correct.
Dmitry's question was leading up to the kfree().
Thanx, Paul
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-09-10 0:08 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-08 7:51 Is it OK to pass non-acquired objects to kfree? Dmitry Vyukov
2015-09-08 14:13 ` Christoph Lameter
2015-09-08 14:41 ` Dmitry Vyukov
2015-09-08 15:13 ` Christoph Lameter
2015-09-08 15:23 ` Dmitry Vyukov
2015-09-08 15:33 ` Christoph Lameter
2015-09-08 15:37 ` Dmitry Vyukov
2015-09-08 17:09 ` Christoph Lameter
2015-09-08 19:24 ` Dmitry Vyukov
2015-09-09 14:02 ` Christoph Lameter
2015-09-09 14:19 ` Dmitry Vyukov
2015-09-09 14:36 ` Christoph Lameter
2015-09-09 15:30 ` Dmitry Vyukov
2015-09-09 15:44 ` Christoph Lameter
2015-09-09 16:09 ` Dmitry Vyukov
2015-09-09 17:56 ` Christoph Lameter
2015-09-09 18:44 ` Paul E. McKenney
2015-09-09 19:01 ` Christoph Lameter
2015-09-09 20:36 ` Paul E. McKenney
2015-09-09 23:23 ` Store Buffers (was Re: Is it OK to pass non-acquired objects to kfree?) Christoph Lameter
2015-09-10 0:08 ` Paul E. McKenney [this message]
2015-09-10 0:21 ` Christoph Lameter
2015-09-10 1:10 ` Paul E. McKenney
2015-09-10 1:47 ` Christoph Lameter
2015-09-10 7:38 ` Vlastimil Babka
2015-09-10 16:37 ` Christoph Lameter
2015-09-10 7:22 ` Vlastimil Babka
2015-09-10 16:36 ` Christoph Lameter
2015-09-09 23:31 ` Is it OK to pass non-acquired objects to kfree? Christoph Lameter
2015-09-10 9:55 ` Dmitry Vyukov
2015-09-10 10:42 ` Jesper Dangaard Brouer
2015-09-10 12:08 ` Dmitry Vyukov
2015-09-10 13:37 ` Eric Dumazet
2015-09-10 12:47 ` Vlastimil Babka
2015-09-10 13:17 ` Dmitry Vyukov
2015-09-10 17:13 ` Paul E. McKenney
2015-09-10 17:21 ` Paul E. McKenney
2015-09-10 17:26 ` Dmitry Vyukov
2015-09-10 17:44 ` Paul E. McKenney
2015-09-10 18:01 ` Christoph Lameter
2015-09-10 18:11 ` Dmitry Vyukov
2015-09-10 18:13 ` Christoph Lameter
2015-09-10 18:26 ` Dmitry Vyukov
2015-09-10 18:56 ` Paul E. McKenney
2015-09-10 22:00 ` Christoph Lameter
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=20150910000847.GV4029@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=cl@linux.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/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