Re: slab quirks in DEBUG, ctor, and initialization
From: Pekka J Enberg
Date: Mon Dec 17 2007 - 16:55:33 EST
Hi John,
On Mon, 17 Dec 2007, John Reiser wrote:
> idr_pre_get calls kmem_cache_alloc, which constructs 'struct idr_layer'
> via the cachep->ctor() call from cache_alloc_debugcheck_after to
> idr_cache_ctor, and not via cache_init_objs. So if DEBUG is off,
> then idr_cache_ctor does not get its chance to call memset,
> which could leave the struct idr_layer potentially undefined.
No, init_cache_objs() will call the constructor, if the cache has one when
DEBUG is not set so the struct idr_layer can never be undefined. However,
struct idr_layer can contain non-zero elements if someone does a
kmem_cache_free() on an object that hasn't been zeroed. If that matters
here, idr_pre_get should call kmem_cache_zalloc() and drop the
constructor.
Pekka
--
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/