linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	vdavydov.dev@gmail.com, mhocko@suse.com, aryabinin@virtuozzo.com,
	ying.huang@intel.com, penguin-kernel@I-love.SAKURA.ne.jp,
	shakeelb@google.com, jbacik@fb.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: Use special value SHRINKER_REGISTERING instead list_empty() check
Date: Mon, 6 Aug 2018 11:55:26 +0300	[thread overview]
Message-ID: <0e7f6e2b-621c-dda0-ebd8-c9b4e7e7f04b@virtuozzo.com> (raw)
In-Reply-To: <20180805125004.GD3183@bombadil.infradead.org>

On 05.08.2018 15:50, Matthew Wilcox wrote:
> On Sun, Aug 05, 2018 at 08:30:43AM +0300, Kirill Tkhai wrote:
>> On 05.08.2018 03:03, Matthew Wilcox wrote:
>>> On Sat, Aug 04, 2018 at 09:42:05PM +0300, Kirill Tkhai wrote:
>>>> This is exactly the thing the patch makes. Instead of inserting a shrinker pointer
>>>> to idr, it inserts a fake value SHRINKER_REGISTERING there. The patch makes impossible
>>>> to dereference a shrinker unless it's completely registered. 
>>>
>>> -       id = idr_alloc(&shrinker_idr, shrinker, 0, 0, GFP_KERNEL);
>>> +       id = idr_alloc(&shrinker_idr, SHRINKER_REGISTERING, 0, 0, GFP_KERNEL);
>>>
>>> Instead:
>>>
>>> +       id = idr_alloc(&shrinker_idr, NULL, 0, 0, GFP_KERNEL);
>>>
>>> ... and the rest of your patch becomes even simpler.
>>
>> The patch, we are discussing at the moment, does *exactly* this:
>>
>> https://lkml.org/lkml/2018/8/3/588
>>
>> It looks like you missed this hunk in the patch.
> 
> No, it does this:
> 
> +       id = idr_alloc(&shrinker_idr, SHRINKER_REGISTERING, 0, 0, GFP_KERNEL);
> 
> I'm saying do this:
> 
> +       id = idr_alloc(&shrinker_idr, NULL, 0, 0, GFP_KERNEL);

No, this won't work at all. The patch introduces special value SHRINKER_REGISTERING,
because shrink_slab_memcg() needs to differ the cases, when 1)shrinker is registering
and 2)shrinker is unregistered. In case of shrinker is registering we do not clear
the bit in shrink_slab_memcg(), while in the other case we must do that. This introduce
a generic solution for all type of shrinkers, and this allows to not impose restrictions
on specific shrinker registering code. A user of shrinker may add a first element to its
LRU list before register_shrinker_prepared() is called, and the corresponding bit won't
be cleared. This gives flexibility for users, it's just the same flexibility they have now.

Before the patch, list_empty() was used like such the indicator, and this is the difference
the patch makes.

      reply	other threads:[~2018-08-06  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 15:36 Kirill Tkhai
2018-08-03 22:51 ` Andrew Morton
2018-08-03 23:03   ` Matthew Wilcox
2018-08-04 18:42   ` Kirill Tkhai
2018-08-05  0:03     ` Matthew Wilcox
2018-08-05  5:30       ` Kirill Tkhai
2018-08-05 12:50         ` Matthew Wilcox
2018-08-06  8:55           ` Kirill Tkhai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e7f6e2b-621c-dda0-ebd8-c9b4e7e7f04b@virtuozzo.com \
    --to=ktkhai@virtuozzo.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=jbacik@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.com \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox