Re: [PATCH] lib/idr.c: Zero memory properly in idr_remove_all

From: Manfred Spraul
Date: Mon Jan 12 2009 - 14:53:47 EST


Kristian Høgsberg wrote:
The problem
isn't about returning un-zeroed-out objects to the kmem cache, the
problem is returning them to the idr free list.
I think this is wrong:
The slab allocator assumes that the objects that are given to kmem_cache_free() are properly constructed.
I.e.: No additional constructor is called prior to returning the object from the next kmem_cache_alloc() call.


Every idr use I've seen could just do the whole thing
under a mutex and not worry about the awkward retry idea.
Unfortunately there are some users that do idr_get_new() within a spinlock.
e.g. from drivers/gpu/drm/drm_gem.c:
if (idr_pre_get(&file_priv->object_idr, GFP_KERNEL) == 0)
return -ENOMEM;

/* do the allocation under our spinlock */
spin_lock(&file_priv->table_lock);
ret = idr_get_new_above(&file_priv->object_idr, obj, 1, handlep);
spin_unlock(&file_priv->table_lock);
:-(

--
Manfred
--
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/