[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180803230318.GB23284@bombadil.infradead.org>
Date: Fri, 3 Aug 2018 16:03:18 -0700
From: Matthew Wilcox <willy@...radead.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Kirill Tkhai <ktkhai@...tuozzo.com>, vdavydov.dev@...il.com,
mhocko@...e.com, aryabinin@...tuozzo.com, ying.huang@...el.com,
penguin-kernel@...ove.SAKURA.ne.jp, shakeelb@...gle.com,
jbacik@...com, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [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@...tuozzo.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.
Powered by blists - more mailing lists