linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Slub Allocator: Why get_order(size * MAX_OBJS_PER_PAGE) - 1 in function slab_order()?
@ 2011-11-22 20:40 zhihua che
  2011-11-23  2:53 ` David Rientjes
  0 siblings, 1 reply; 6+ messages in thread
From: zhihua che @ 2011-11-22 20:40 UTC (permalink / raw)
  To: linux-kernel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-24  4:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-22 20:40 Slub Allocator: Why get_order(size * MAX_OBJS_PER_PAGE) - 1 in function slab_order()? zhihua che
2011-11-23  2:53 ` David Rientjes
     [not found]   ` <CABexPfEte8U5pVBJ=LvRKMY5=oW7F2vRjw_d9893Yy8W88hfDg@mail.gmail.com>
2011-11-23  6:59     ` Fwd: " zhihua che
2011-11-23 23:06       ` David Rientjes
     [not found]         ` <CABexPfFFiNf8gj9EHnnWABmcK_wCiRkhxQObUnr0_oY2Dkp+JA@mail.gmail.com>
2011-11-24  4:44           ` zhihua che
2011-11-24  4:55             ` zhihua che

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).