Re: slab quirks in DEBUG, ctor, and initialization
From: Pekka Enberg
Date: Mon Dec 17 2007 - 15:13:43 EST
Hi John,
On Dec 17, 2007 5:47 PM, John Reiser <jreiser@xxxxxxxxxxxx> wrote:
> In mm/slab.c, the DEBUG variant of cache_alloc_debugcheck_after
> might call cachep->ctor(objp, cachep, 0); but the non-DEBUG
> variant does absolutely nothing. idr_pre_get is a routine
> which notices the difference.
How does ipr_pre_get notice this?
On Dec 17, 2007 5:47 PM, John Reiser <jreiser@xxxxxxxxxxxx> wrote:
> Even when cache_alloc_debugcheck_after does invoke the ctor,
> then it is conditional upon cachep->flags & SLAB_POISON. This
> assumes that the only two states are poisoned and all-zero
> (from .bss static, or via a cleared new page frame.)
> So if SLAB_POISON is not specified, then a ctor which
> does anything other than memset(,0,) is out of luck.
> Instead: if a ctor is specified then it should be called
> for each successful allocation.
Sorry, I don't understand at all what's the problem is here. For the
common (non-poison) case, we initialize all objects *once* whenever a
cache is grown (see cache_grow calling cache_init_objs) which is the
whole point of having constructors. When poisoning is enabled, we
obviously cannot do this which is why we call the constructor for
every allocation.
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/