mm/slub: reduce the calculation times of 'MAX_OBJS_PER_PAGE'
Subsystems (2)
PATCH 1/1 mm/slub: reduce the calculation times of 'MAX_OBJS_PER_PAGE'
From: Gou Hao <[email protected]>
when calling calc_slab_order(), 'slub_min_order' and 'size' are fixed values, if the condition of 'MAX_OBJS_PER_PAGE' is true, it will be returned from here every time.
So we can calculate the condition of 'MAX_OBJS_PER_PAGE' before calling calculate_order().
Signed-off-by Gou Hao <[email protected]>
--- mm/slub.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
mm/slub.c +7 -5
@@ -4094,9 +4094,6 @@ static inline unsigned int calc_slab_order(unsigned int size,unsigned int min_order = slub_min_order;unsigned int order; -if (order_objects (min_order, size) >MAX_OBJS_PER_PAGE ) -return get_order (size *MAX_OBJS_PER_PAGE ) -1 ; -for (order =max (min_order, (unsigned int )get_order (min_objects * size)); order <= max_order; order++) {
@@ -4457,9 +4454,14 @@ static int calculate_sizes(struct kmem_cache *s) size =ALIGN (size, s->align); s->size = size; s->reciprocal_size =reciprocal_value (size); - order =calculate_order (size); -if ((int )order <0 ) + +if (order_objects (slub_min_order, size) >MAX_OBJS_PER_PAGE ) + order =get_order (size *MAX_OBJS_PER_PAGE ) -1 ; +else + order =calculate_order (size); + +if ((int )order <0 || order > slub_max_order)return 0 ; s->allocflags =0 ;
Signature · 1 line
2.34.1