Re: [rfc] SLOB memory ordering issue

From: Matt Mackall
Date: Wed Oct 15 2008 - 14:01:23 EST


On Wed, 2008-10-15 at 10:36 -0700, Linus Torvalds wrote:
>
> On Wed, 15 Oct 2008, Linus Torvalds wrote:
> >
> > If you make an allocation visible to other CPU's, you would need to make
> > sure that allocation is stable with a smp_wmb() before you update the
> > pointer to that allocation.
>
> Just to clarify a hopefully obvious issue..
>
> The assumption here is that you don't protect things with locking. Of
> course, if all people accessing the new pointer always have the
> appropriate lock, then memory ordering never matters, since the locks take
> care of it.

Right. This is the 99.9% case and is why we should definitely not put an
additional barrier in the allocator.

Lockless users are already on their own with regard to memory ordering
issues, so it makes sense for them to absorb the (often nil) incremental
cost of ensuring object initialization gets flushed.

I feel like we ought to document this in the SLAB API, but at the same
time, I think we'll scare more people than we'll enlighten.

--
Mathematics is the supreme nostalgia of our time.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/