Re: [rfc][patch 3/3] use SLAB_ALIGN_SMP



Nick Piggin a écrit :
On Mon, Mar 03, 2008 at 10:53:52AM +0100, Eric Dumazet wrote:
Nick Piggin a écrit :
Use SLAB_SMP_ALIGN in a few places.

I dont understand why you added SLAB_SMP_ALIGN, without removing SLAB_HWCACHE_ALIGN on these places.

Because I thought that in most of the cases, we also want some cacheline
alignment on UP systems as well because we care about the layout of the
structure WRT the cachelines for the mandatory/capacity miss cases, as
well as wanting to avoid false sharing misses on SMP.

Actually I didn't think _too_ hard about them, possibly some could be
removed. But the problem is that these things do require careful
thought so I should not change them unless I have done that ;)

I guess there are some basic guidelines -- if size is a problem (ie if
there can be lots of these structures), then that is going to be a
factor; if the total pool of objects is likely to be fairly densely
resident in cache, then it will start to favour dense packing rather
than good alignment.

Well, if a kmem_cache_create() is used, this is probably because number of objects can be large, so kmalloc() power-of-two granularity could waste lot of ram.

But yes, you are right that SLAB_SMP_ALIGN doesnt imply SLAB_HWCACHE_ALIGN

- SMP_ALIGN is a hint about false sharing (when object contains a refcnt for example), that is a concern only if

num_possible_cpus() > 1

While HWCACHE_ALIGN might be a hint saying :
- The writer carefully designed the structure so that max performance is obtained when all objects starts on a cache line boundary, even on Uniprocessor.

But I suspect some uses of HWCACHE_ALIGN are not a hint but a strong requirement.

Maybe we need to use three flags to separate the meanings ?


SLAB_HINT_SMP_ALIGN
SLAB_HINT_HWCACHE_ALIGN
SLAB_HWCACHE_ALIGN /* strong requirement that two objects dont share a cache line */





--
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/



Relevant Pages

  • Re: [rfc][patch 3/3] use SLAB_ALIGN_SMP
    ... alignment on UP systems as well because we care about the layout of the ... structure WRT the cachelines for the mandatory/capacity miss cases, ... resident in cache, then it will start to favour dense packing rather ... SMP_ALIGN is a hint about false sharing (when object contains a refcnt ...
    (Linux-Kernel)
  • Re: [BUG] slab debug vs. L1 alignement
    ... Perhaps we should remind ourselves what the alignment rules actually are ... No two kmalloc allocations may share cache lines (otherwise data ... architecture. ...
    (Linux-Kernel)
  • Re: Byte alignment
    ... I was told by one client who is using high-end Xeons that even the 32-bit chipsets are now ... optimizing cache hits for regular computations during my system programming course. ... 64-byte alignment. ... and they are very unhappy with their nVidia-based motherboards. ...
    (microsoft.public.vc.mfc)
  • Re: reading a text file into a string
    ... If you are buffering lines and want to avoid unintentional cache ... support specified Alignments that are greater than the maximum Alignment ... This applies to subtypes, ...
    (comp.lang.ada)
  • Re: Multiple of 4? Better performance?
    ... Multiples of 4 can also help with alignment ... performance hit from cache stalls and misses. ... Even attempting to help client code "get aligned" doesn't make much sense: ...
    (microsoft.public.sqlserver.programming)