From c959b736fc5f0a1aa590205b6f87f255cbeae9b4 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 15 Feb 2008 15:22:22 -0800 Subject: [PATCH] slub: Adjust order boundaries and minimum objects per slab. Since there is now less worry about higher order allocs we can now adjust the order and the number of objects per slab in a more flexible way. The mininum objects per slab is calculated based on the number of processors that may come online. This is f.e. effective in avoiding hackbench thrashing on free(). Processors min_objects --------------------------- 1 4 2 8 4 12 8 16 16 20 32 24 64 28 1024 44 4096 52 The maximum order is set to PAGE_ALLOC_ORDER_COSTLY. The more processors exist in a system the more larger order allocations are used in order to guarantee that the required number of objects can be allocated from a cpu slab. For small systems with a single processor the orders barely change since 4 was the mininum object number for linux version prior to 2.6.25. This generates small orders for small systems. 2k and 4k slabs will most easily increase in order. That is important because 4k slabs are important to avoid the use of the slow page allocator for 4k allocs. Both 2k and 4k slabs important performance wise for the networking stack. The 2k and 4k slabs will have similar order as on 2.6.25 with the kmalloc fallback logic. The drawback is that more stress is placed on the reclaim logic and the antifragmentation measures of the page allocator. If linear memory is not available then reclaim may be more frequently triggered and if reclaim fails then SLUB will have to fallback to smaller orders. Signed-off-by: Christoph Lameter --- mm/slub.c | 27 +++++---------------------- 1 files changed, 5 insertions(+), 22 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index c718253..c0f5760 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5,7 +5,7 @@ * The allocator synchronizes using per slab locks and only * uses a centralized lock to manage a pool of partial slabs. * - * (C) 2007 SGI, Christoph Lameter + * (C) 2007, 2008 SGI, Christoph Lameter */ #include @@ -149,25 +149,6 @@ static inline void ClearSlabDebug(struct page *page) /* Enable to test recovery from slab corruption on boot */ #undef SLUB_RESILIENCY_TEST -#if PAGE_SHIFT <= 12 - -/* - * Small page size. Make sure that we do not fragment memory - */ -#define DEFAULT_MAX_ORDER 1 -#define DEFAULT_MIN_OBJECTS 4 - -#else - -/* - * Large page machines are customarily able to handle larger - * page orders. - */ -#define DEFAULT_MAX_ORDER 2 -#define DEFAULT_MIN_OBJECTS 8 - -#endif - /* * Mininum number of partial slabs. These will be left on the partial * lists even if they are empty. kmem_cache_shrink may reclaim them. @@ -1791,8 +1772,8 @@ static struct page *get_object_page(const void *x) * take the list_lock. */ static int slub_min_order; -static int slub_max_order = DEFAULT_MAX_ORDER; -static int slub_min_objects = DEFAULT_MIN_OBJECTS; +static int slub_max_order = PAGE_ALLOC_COSTLY_ORDER; +static int slub_min_objects = 0; /* * Merge control. If this is set then no merging of slab caches will occur. @@ -1869,6 +1850,8 @@ static inline int calculate_order(int size) * we reduce the minimum objects required in a slab. */ min_objects = slub_min_objects; + if (!min_objects) + min_objects = 4 * fls(nr_cpu_ids); while (min_objects > 1) { fraction = 8; while (fraction >= 4) { -- 1.5.4.4