lkml.org 
[lkml]   [2018]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: Use special value SHRINKER_REGISTERING instead list_empty() check
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@virtuozzo.com> 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.

\
 
 \ /
  Last update: 2018-08-04 01:04    [W:0.118 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site