slub: relocate freelist pointer to middle of object
[sfrench/cifs-2.6.git] / mm / slub.c
index bc949e3428c972b798c193299bc4c21e31d224e4..3098e0cf28992a344fc3de08245d0db97dbb3060 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3581,6 +3581,13 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
                 */
                s->offset = size;
                size += sizeof(void *);
+       } else if (size > sizeof(void *)) {
+               /*
+                * Store freelist pointer near middle of object to keep
+                * it away from the edges of the object to avoid small
+                * sized over/underflows from neighboring allocations.
+                */
+               s->offset = ALIGN(size / 2, sizeof(void *));
        }
 
 #ifdef CONFIG_SLUB_DEBUG