提交 e8120ff1 编写于 作者: Z Zhang Yanmin 提交者: Pekka Enberg

SLUB: Fix default slab order for big object sizes

The default order of kmalloc-8192 on 2*4 stoakley is an issue of
calculate_order.

slab_size       order           name
-------------------------------------------------
4096            3               sgpool-128
8192            2               kmalloc-8192
16384           3               kmalloc-16384

kmalloc-8192's default order is smaller than sgpool-128's.

On 4*4 tigerton machine, a similiar issue appears on another kmem_cache.

Function calculate_order uses 'min_objects /= 2;' to shrink. Plus size
calculation/checking in slab_order, sometimes above issue appear.

Below patch against 2.6.29-rc2 fixes it.

I checked the default orders of all kmem_cache and they don't become
smaller than before. So the patch wouldn't hurt performance.

Signed-off-by Zhang Yanmin <yanmin.zhang@linux.intel.com>
Signed-off-by: NPekka Enberg <penberg@cs.helsinki.fi>
上级 51735a7c
...@@ -1844,6 +1844,7 @@ static inline int calculate_order(int size) ...@@ -1844,6 +1844,7 @@ static inline int calculate_order(int size)
int order; int order;
int min_objects; int min_objects;
int fraction; int fraction;
int max_objects;
/* /*
* Attempt to find best configuration for a slab. This * Attempt to find best configuration for a slab. This
...@@ -1856,6 +1857,9 @@ static inline int calculate_order(int size) ...@@ -1856,6 +1857,9 @@ static inline int calculate_order(int size)
min_objects = slub_min_objects; min_objects = slub_min_objects;
if (!min_objects) if (!min_objects)
min_objects = 4 * (fls(nr_cpu_ids) + 1); min_objects = 4 * (fls(nr_cpu_ids) + 1);
max_objects = (PAGE_SIZE << slub_max_order)/size;
min_objects = min(min_objects, max_objects);
while (min_objects > 1) { while (min_objects > 1) {
fraction = 16; fraction = 16;
while (fraction >= 4) { while (fraction >= 4) {
...@@ -1865,7 +1869,7 @@ static inline int calculate_order(int size) ...@@ -1865,7 +1869,7 @@ static inline int calculate_order(int size)
return order; return order;
fraction /= 2; fraction /= 2;
} }
min_objects /= 2; min_objects --;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册