Slub Allocator: Why get_order(size * MAX_OBJS_PER_PAGE) - 1 infunction slab_order()?

From: zhihua che
Date: Tue Nov 22 2011 - 15:40:37 EST


Hi, everyone,
I'm reading the kernel codes about slub allocator and I come
across a confusion. Precisely, I'm reading the initialization of the
slub allocator, kmem_cache_init(), and I find it needs call
calculate_sizes() to determine the order of a kmem_cache, given the
size of the object. In turn, it calls the get_order() to get a
possible order. The problem is, in the start of this function, why it
looks like this:

if (order_objects(min_order, size, reserved) > MAX_OBJS_PER_PAGE)
return get_order(size * MAX_OBJS_PER_PAGE) - 1;

I don't know why it subtracts one from the order returned by
get_order().
because as far as I know, get_order() returns the order the
slab requires to reserve size * MAX_OBJS_PER_PAGE memory. If it
subtracts 1 from the order returned by get_order(), the slab can't
store MAX_OBJS_PER_PAGE objects at all, instead it can only store half
of the MAX_OBJS_PER_PAGE objects.
Could you correct me if I think in a wrong way.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/