public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* slab quirks in DEBUG, ctor, and initialization
@ 2007-12-17 15:47 John Reiser
  2007-12-17 19:51 ` Pekka Enberg
  0 siblings, 1 reply; 4+ messages in thread
From: John Reiser @ 2007-12-17 15:47 UTC (permalink / raw)
  To: linux-kernel

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.

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.

Invoking the ctor from within cache_alloc_debugcheck_after makes it
awkward for a dynamic checker of allocations and  initializations.
Valgrind would be happier if allocation and initialization were
invoked at the same subroutine nesting level, such as in __cache_alloc:

        cache_alloc_debugcheck_before(cachep, flags);
        local_irq_save(save_flags);
        objp = __do_cache_alloc(cachep, flags);
	/* checker marks the space as allocated */
        local_irq_restore(save_flags);
        objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
	if (objp && cachep->ctor)
		cachep->ctor(objp, cachep, 0);
	/* checker notes initializations during ctor [above] */

-- 
John Reiser, jreiser@BitWagon.com

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

end of thread, other threads:[~2007-12-17 21:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-17 15:47 slab quirks in DEBUG, ctor, and initialization John Reiser
2007-12-17 19:51 ` Pekka Enberg
2007-12-17 21:19   ` John Reiser
2007-12-17 21:55     ` Pekka J Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox