On Fri, Aug 03, 2018 at 03:51:20PM -0700, Andrew Morton wrote: > On Fri, 03 Aug 2018 18:36:14 +0300 Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> wrote: > > The patch introduces a special value SHRINKER_REGISTERING to use instead > > of list_empty() to detect a semi-registered shrinker. > > All this isn't terribly nice. Why can't we avoid installing the > shrinker into the idr until it is fully initialized? I haven't reviewed the current state of the code in question, but the IDR allows you to store a NULL in order to allocate an ID. One should then either call idr_remove() in order to release the ID or idr_replace() once the object has been fully initialised. Another way to potentially accomplish the same thing is to use idr_alloc_u32 which will assign the ID immediately before inserting the pointer into the IDR. This only works if the caller can initialise everything but the ID, and can handle an ENOMEM.