Introduce SLAB_SMP_ALIGN, for allocations where false sharing must be minimised on SMP systems. Signed-off-by: Nick Piggin <npiggin@suse.de> --- Index: linux-2.6/include/linux/slab.h =================================================================== --- linux-2.6.orig/include/linux/slab.h +++ linux-2.6/include/linux/slab.h @@ -22,7 +22,8 @@ #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */ #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */ #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */ -#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ +#define SLAB_SMP_ALIGN 0x00004000UL /* Align on cachelines for SMP*/ +#define SLAB_CACHE_DMA 0x00008000UL /* Use GFP_DMA memory */ #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ #define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ Index: linux-2.6/mm/slab.c =================================================================== --- linux-2.6.orig/mm/slab.c +++ linux-2.6/mm/slab.c @@ -174,13 +174,13 @@ /* Legal flag mask for kmem_cache_create(). */ #if DEBUG # define CREATE_MASK (SLAB_RED_ZONE | \ - SLAB_POISON | SLAB_HWCACHE_ALIGN | \ + SLAB_POISON | SLAB_HWCACHE_ALIGN | SLAB_SMP_ALIGN | \ SLAB_CACHE_DMA | \ SLAB_STORE_USER | \ SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD) #else -# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \ +# define CREATE_MASK (SLAB_HWCACHE_ALIGN | SLAB_SMP_ALIGN | \ SLAB_CACHE_DMA | \ SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD) @@ -2245,6 +2245,9 @@ kmem_cache_create (const char *name, siz ralign = BYTES_PER_WORD; } + if ((flags & SLAB_SMP_ALIGN) && num_possible_cpus() > 1) + ralign = max_t(unsigned long, ralign, cache_line_size()); + /* * Redzoning and user store require word alignment or possibly larger. * Note this will be overridden by architecture or caller mandated Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c +++ linux-2.6/mm/slub.c @@ -1903,6 +1903,9 @@ static unsigned long calculate_alignment align = max(align, ralign); } + if ((flags & SLAB_SMP_ALIGN) && num_possible_cpus() > 1) + align = max_t(unsigned long, align, cache_line_size()); + if (align < ARCH_SLAB_MINALIGN) align = ARCH_SLAB_MINALIGN; --
| Peter Zijlstra | Re: [15/17] SLUB: Support virtual fallback via SLAB_VFALLBACK |
| Christoph Lameter | Re: crash in kmem_cache_init |
| Greg Kroah-Hartman | [PATCH 017/196] aoechr: Convert from class_device to device |
| David Miller | Re: [patch 0/7] [RFC] SLUB: Improve allocpercpu to reduce per cpu access overhead |
git: | |
| Raimund Bauer | [wishlist] graphical diff |
| Johannes Schindelin | Re: A tour of git: the basics (and notes on some unfriendly messages) |
| Pazu | qgit on Mac OS X |
| pradeep singh rautela | Re: Why does git track directory listed in .gitignore/".git/info/exclude"? |
| Stephen Pierce | SLS |
| Theodore Ts'o | Re: demand paging: proposal |
| Dong Liu | Re: CXterm for LINUX |
| Marc G Fournier | Re: Reducing traffic on c.o.l.; splitting c.o.l |
| Markus Wernig | host to host ipsec link |
| Beavis | mutiple pptp pass-through PF |
| Todd Pytel | IDE or SCSI virtual disks for VMWare image? |
| Sam Fourman Jr. | Asus Striker Extreme does not support 4GB memory |
| magical mounts | 13 hours ago | Linux kernel |
| Problem in scim in Fedora 9 | 14 hours ago | Linux general |
| The new Western Digital power saving drives | 14 hours ago | Hardware |
| Battery Maximizer Software | 1 day ago | Linux kernel |
| windows folder creation surprise | 1 day ago | Windows |
| Firewall | 2 days ago | OpenBSD |
| IP layer send packet | 2 days ago | Linux kernel |
| dtrace for linux available | 3 days ago | Linux kernel |
| Unable to mount ramdisk image using UBoot while upgrading to 2.6.15 kernel for a MPC8540 based target | 3 days ago | Linux kernel |
| RealTek RTL8169 - can't connect | 3 days ago | NetBSD |
