On Tue, May 08, 2007 at 07:24:07PM -0700, Christoph Lameter wrote:
> On Tue, 8 May 2007, Matt Mackall wrote:
> 
> > > > Yes. It can in fact put 512 8-byte objects in a 4k page. More
> > > 
> > > So can SLUB.
> > 
> > Not without at least a bit per-object of overhead. So you can either
> > fit 512 objects in 4160 bytes or 504 objects in 4k.
> 
> Slub uses a linked list pointer in the page struct which is NULL if all 
> objects are allocated. There is no bit per object overhead.

Ahh, I'd forgotten about that feature.

> > For the kmalloc case, we do have an 8-byte header, which works out to
> > be about 1/8th of the slop that mainline kmalloc over SLAB has on
> 
> Exactly. That overhead does not exist in SLUB. Thus SLOB is less efficient 
> than SLUB.

What size object does kmalloc(80) return? In SLAB, the answer is 128
bytes with 48 bytes of slack space. In SLOB, the answer is 88 for 8
bytes of slack space. Looks like SLUB is in the same camp as SLAB
here:

+/*
+ * We keep the general caches in an array of slab caches that are used for
+ * 2^x bytes of allocations.
+ */
+extern struct kmem_cache kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
...
+       if (size <=        128) return 7;

As I pointed out in our private thread, according to these
measurements:

http://lwn.net/Articles/124374/

total bytes allocated: 47118848   
slack bytes allocated:  8717262
number of allocs:        132796

...the average kmalloc allocation with SLAB is 355 bytes with an
average slack of 66 bytes. As SLUB uses the same kmalloc cache size
strategy, I expect the same there.

SLOB's kmalloc overhead is 8 bytes, always. That's 1/8th the average
SLAB kmalloc overhead.
 
-- 
Mathematics is the supreme nostalgia of our time.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to