diff options
author | Christoph Lameter <cl@linux.com> | 2012-11-28 11:23:16 -0500 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2012-12-11 05:14:28 -0500 |
commit | 4590685546a374fb0f60682ce0e3a6fd48911d46 (patch) | |
tree | 1287ce1e1633067f8bf2cf9f93f1d6fe8a1f8908 /mm/slab.c | |
parent | 2f9baa9fcf8d0a204ca129a671d6086cc100faab (diff) |
mm/sl[aou]b: Common alignment code
Extract the code to do object alignment from the allocators.
Do the alignment calculations in slab_common so that the
__kmem_cache_create functions of the allocators do not have
to deal with alignment.
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 20 |
1 files changed, 0 insertions, 20 deletions
@@ -2337,22 +2337,6 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) | |||
2337 | size &= ~(BYTES_PER_WORD - 1); | 2337 | size &= ~(BYTES_PER_WORD - 1); |
2338 | } | 2338 | } |
2339 | 2339 | ||
2340 | /* calculate the final buffer alignment: */ | ||
2341 | |||
2342 | /* 1) arch recommendation: can be overridden for debug */ | ||
2343 | if (flags & SLAB_HWCACHE_ALIGN) { | ||
2344 | /* | ||
2345 | * Default alignment: as specified by the arch code. Except if | ||
2346 | * an object is really small, then squeeze multiple objects into | ||
2347 | * one cacheline. | ||
2348 | */ | ||
2349 | ralign = cache_line_size(); | ||
2350 | while (size <= ralign / 2) | ||
2351 | ralign /= 2; | ||
2352 | } else { | ||
2353 | ralign = BYTES_PER_WORD; | ||
2354 | } | ||
2355 | |||
2356 | /* | 2340 | /* |
2357 | * Redzoning and user store require word alignment or possibly larger. | 2341 | * Redzoning and user store require word alignment or possibly larger. |
2358 | * Note this will be overridden by architecture or caller mandated | 2342 | * Note this will be overridden by architecture or caller mandated |
@@ -2369,10 +2353,6 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) | |||
2369 | size &= ~(REDZONE_ALIGN - 1); | 2353 | size &= ~(REDZONE_ALIGN - 1); |
2370 | } | 2354 | } |
2371 | 2355 | ||
2372 | /* 2) arch mandated alignment */ | ||
2373 | if (ralign < ARCH_SLAB_MINALIGN) { | ||
2374 | ralign = ARCH_SLAB_MINALIGN; | ||
2375 | } | ||
2376 | /* 3) caller mandated alignment */ | 2356 | /* 3) caller mandated alignment */ |
2377 | if (ralign < cachep->align) { | 2357 | if (ralign < cachep->align) { |
2378 | ralign = cachep->align; | 2358 | ralign = cachep->align; |