Commit 9f835703 authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds

mm/slub: calculate start order with reserved in consideration

In slub_order(), the order starts from max(min_order,
get_order(min_objects * size)).  When (min_objects * size) has different
order from (min_objects * size + reserved), it will skip this order via a
check in the loop.

This patch optimizes this a little by calculating the start order with
`reserved' in consideration and removing the check in loop.
Signed-off-by: default avatarWei Yang <weiyang@linux.vnet.ibm.com>
Acked-by: default avatarChristoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 033fd1bd
...@@ -2912,19 +2912,15 @@ static inline int slab_order(int size, int min_objects, ...@@ -2912,19 +2912,15 @@ static inline int slab_order(int size, int min_objects,
if (order_objects(min_order, size, reserved) > MAX_OBJS_PER_PAGE) if (order_objects(min_order, size, reserved) > MAX_OBJS_PER_PAGE)
return get_order(size * MAX_OBJS_PER_PAGE) - 1; return get_order(size * MAX_OBJS_PER_PAGE) - 1;
for (order = max(min_order, get_order(min_objects * size)); for (order = max(min_order, get_order(min_objects * size + reserved));
order <= max_order; order++) { order <= max_order; order++) {
unsigned long slab_size = PAGE_SIZE << order; unsigned long slab_size = PAGE_SIZE << order;
if (slab_size < min_objects * size + reserved)
continue;
rem = (slab_size - reserved) % size; rem = (slab_size - reserved) % size;
if (rem <= slab_size / fract_leftover) if (rem <= slab_size / fract_leftover)
break; break;
} }
return order; return order;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment