[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f8d924e7-8faf-438d-4d2f-5f806ef88a49@bytedance.com>
Date: Fri, 23 Jun 2023 21:24:25 +0800
From: Qi Zheng <zhengqi.arch@...edance.com>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: akpm@...ux-foundation.org, david@...morbit.com, tkhai@...ru,
vbabka@...e.cz, roman.gushchin@...ux.dev, djwong@...nel.org,
brauner@...nel.org, paulmck@...nel.org, tytso@....edu,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-arm-msm@...r.kernel.org, dm-devel@...hat.com,
linux-raid@...r.kernel.org, linux-bcache@...r.kernel.org,
virtualization@...ts.linux-foundation.org,
linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
linux-nfs@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-btrfs@...r.kernel.org
Subject: Re: [PATCH 29/29] mm: shrinker: move shrinker-related code into a
separate file
Hi Sergey,
On 2023/6/23 13:25, Sergey Senozhatsky wrote:
> On (23/06/22 16:53), Qi Zheng wrote:
>> +/*
>> + * Remove one
>> + */
>> +void unregister_shrinker(struct shrinker *shrinker)
>> +{
>> + struct dentry *debugfs_entry;
>> + int debugfs_id;
>> +
>> + if (!(shrinker->flags & SHRINKER_REGISTERED))
>> + return;
>> +
>> + shrinker_put(shrinker);
>> + wait_for_completion(&shrinker->completion_wait);
>> +
>> + mutex_lock(&shrinker_mutex);
>> + list_del_rcu(&shrinker->list);
>
> Should this function wait for RCU grace period(s) before it goes
> touching shrinker fields?
Why? We will free this shrinker instance by rcu after executing
unregister_shrinker(). So it is safe to touch shrinker fields here.
>
>> + shrinker->flags &= ~SHRINKER_REGISTERED;
>> + if (shrinker->flags & SHRINKER_MEMCG_AWARE)
>> + unregister_memcg_shrinker(shrinker);
>> + debugfs_entry = shrinker_debugfs_detach(shrinker, &debugfs_id);
>> + mutex_unlock(&shrinker_mutex);
>> +
>> + shrinker_debugfs_remove(debugfs_entry, debugfs_id);
>> +
>> + kfree(shrinker->nr_deferred);
>> + shrinker->nr_deferred = NULL;
>> +}
>> +EXPORT_SYMBOL(unregister_shrinker);
>
> [..]
>
>> +void shrinker_free(struct shrinker *shrinker)
>> +{
>> + kfree(shrinker);
>> +}
>> +EXPORT_SYMBOL(shrinker_free);
>> +
>> +void unregister_and_free_shrinker(struct shrinker *shrinker)
>> +{
>> + unregister_shrinker(shrinker);
>> + kfree_rcu(shrinker, rcu);
>> +}
>
> Seems like this
>
> unregister_shrinker();
> shrinker_free();
>
> is not exact equivalent of this
>
> unregister_and_free_shrinker();
Yes, my original intention is that shrinker_free() is only used to
handle the case where register_shrinker() returns failure.
I will implement the method suggested by Dave in 02/29. Those APIs are
more concise and will bring more benefits. :)
Thanks,
Qi
Powered by blists - more mailing lists