Re: [RFC] [PATCH] kmem_alloc (generic wrapper for kmalloc andvmalloc)

From: Roland Dreier
Date: Wed Nov 10 2004 - 12:18:15 EST

Carl-Daniel> OK, so how should I allocate memory for 512 struct
Carl-Daniel> loop_device's? Because of its odd size (304 bytes)
Carl-Daniel> it seems that if I use kmalloc seperately for each
Carl-Daniel> struct, I'd waste 208 bytes per allocation. 68%
Carl-Daniel> overhead would be a step backwards. Or am I missing
Carl-Daniel> something here?

Would creating your own slab cache with kmem_cache_create() and
allocating with kmem_cache_alloc() work? You can fit 13 304 byte
objects in a 4K page, which wastes 4096 - 13*304 = 144 bytes per page
or about 11 bytes per object. Less than 4% overhead seems OK to me.

- R.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at