From 16d99651b8c1eef9e58ad7c45d845b1e4328f14f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 28 Mar 2003 03:18:18 -0800 Subject: [PATCH] [PATCH] slab: fix off-by-one in size calculation From: Manfred Spraul Brian spotted a stupid bug in the slab initialization: If multiple objects fit into one cacheline, then the allocator ignores SLAB_HWCACHE_ALIGN and squeezes the objects into the same cacheline. The implementation contains an off by one error and thus doesn't work correctly: For Athlon optimized kernels, the 32-byte slab uses 64 byte of memory. --- mm/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slab.c b/mm/slab.c index ee80766d2b8a6..8ed5d1c0e65b6 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1035,7 +1035,7 @@ kmem_cache_create (const char *name, size_t size, size_t offset, if (flags & SLAB_HWCACHE_ALIGN) { /* Need to adjust size so that objs are cache aligned. */ /* Small obj size, can get at least two per cache line. */ - while (size < align/2) + while (size <= align/2) align /= 2; size = (size+align-1)&(~(align-1)); } -- 2.53.0