Re: [PATCH v2 05/12] fs: Propagate shrinker::id to list_lru

From: Vladimir Davydov
Date: Sun Apr 22 2018 - 14:03:51 EST


On Tue, Apr 17, 2018 at 09:53:47PM +0300, Kirill Tkhai wrote:
> The patch adds list_lru::shrinker_id field, and populates
> it by registered shrinker id.
>
> This will be used to set correct bit in memcg shrinkers
> map by lru code in next patches, after there appeared
> the first related to memcg element in list_lru.
>
> Signed-off-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
> ---
> fs/super.c | 4 +++-
> include/linux/list_lru.h | 1 +
> include/linux/shrinker.h | 8 +++++++-
> mm/list_lru.c | 6 ++++++
> mm/vmscan.c | 15 ++++++++++-----
> mm/workingset.c | 3 ++-
> 6 files changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index 5fa9a8d8d865..9bc5698c8c3c 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -518,7 +518,9 @@ struct super_block *sget_userns(struct file_system_type *type,
> hlist_add_head(&s->s_instances, &type->fs_supers);
> spin_unlock(&sb_lock);
> get_filesystem(type);
> - err = register_shrinker(&s->s_shrink);
> + err = register_shrinker_args(&s->s_shrink, 2,
> + &s->s_dentry_lru.shrinker_id,
> + &s->s_inode_lru.shrinker_id);

This looks ugly. May be, we could allocate an id in prealloc_shrinker
then simply pass it to list_lru_init in arguments?