[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201711232257.BFA41889.LOVOtFHFQJOSMF@I-love.SAKURA.ne.jp>
Date: Thu, 23 Nov 2017 22:57:06 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: mhocko@...nel.org
Cc: jack@...e.cz, viro@...iv.linux.org.uk, david@...morbit.com,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
akpm@...ux-foundation.org
Subject: Re: [PATCH] fs: handle shrinker registration failure in sget_userns
Michal Hocko wrote:
> > @@ -260,9 +261,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
> > s->s_shrink.count_objects = super_cache_count;
> > s->s_shrink.batch = 1024;
> > s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE;
> > - INIT_LIST_HEAD(&s->s_shrink.list);
> > - return s;
> > -
> > + if (register_shrinker(&s->s_shrink) == 0)
> > + return s;
> > fail:
> > destroy_unused_super(s);
> > return NULL;
>
> But I am not sure this is correct. So what protects shrinker invocation
> while the object is not initialized yet?
Then, what protects shrinker invocation in your patch?
Your patch is calling register_shrinker() immediately after
alloc_super() succeeds. My patch just moved register_shrinker()
into alloc_super().
@@ -503,6 +512,10 @@ struct super_block *sget_userns(struct file_system_type *type,
s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns);
if (!s)
return ERR_PTR(-ENOMEM);
+ if (register_shrinker(&s->s_shrink)) {
+ destroy_unused_super(s);
+ return ERR_PTR(-ENOMEM);
+ }
goto retry;
}
Powered by blists - more mailing lists