DEFINE_IDR() and the layer cache



Hi all,

while the idr discussion is still hot, there's another thing that caught my
eye recently:

As to my reading of idr.h, I have two choices of initializing a global idr:
a) static struct idr foo; /* ... */ idr_init(&foo);
b) static DEFINE_IDR(foo);

idr_init(), when called for the first time, sets up the layer
cache. idr_get_new() and friends expect the cache to exist. Now, what happens
if the first call to idr_get_new() targets an idr initialized using
DEFINE_IDR() before idr_init() has been called at least once? Could this
happen?

My $0.02,
Joachim


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



Relevant Pages

  • Re: [PATCH] lib/idr.c: Zero memory properly in idr_remove_all
    ... problem is returning them to the idr free list. ... The slab allocator assumes that the objects that are given to kmem_cache_freeare properly constructed. ... No additional constructor is called prior to returning the object from the next kmem_cache_alloccall. ... The memory is organized in caches, one cache for each object type. ...
    (Linux-Kernel)
  • Re: [PATCH] lib/idr.c: Zero memory properly in idr_remove_all
    ... isn't about returning un-zeroed-out objects to the kmem cache, ... problem is returning them to the idr free list. ... The slab allocator assumes that the objects that are given to ... No additional constructor is called prior to returning the object ...
    (Linux-Kernel)
  • Re: [PATCH] lib/idr.c: Zero memory properly in idr_remove_all
    ... isn't about returning un-zeroed-out objects to the kmem cache, ... problem is returning them to the idr free list. ... The slab allocator assumes that the objects that are given to ... No additional constructor is called prior to returning the object ...
    (Linux-Kernel)