From: <jiang.biao2@zte.com.cn>
To: minchan@kernel.org
Cc: akpm@linux-foundation.org, mhocko@suse.com, hannes@cmpxchg.org,
hillf.zj@alibaba-inc.com, ying.huang@intel.com,
linux-mm@kvack.org, mgorman@techsingularity.net,
linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn
Subject: Re: [PATCH] mm/vmscan: make do_shrink_slab more robust.
Date: Mon, 27 Nov 2017 14:27:20 +0800 (CST) [thread overview]
Message-ID: <201711271427202879096@zte.com.cn> (raw)
In-Reply-To: <20171127051643.GA27449@bbox>
[-- Attachment #1.1: Type: text/plain, Size: 2048 bytes --]
> On Mon, Nov 27, 2017 at 12:46:27PM +0800, jiang.biao2@zte.com.cn wrote:> > On Mon, Nov 27, 2017 at 09:37:30AM +0800, Jiang Biao wrote:> >
> > > > This patch make do_shrink_slab more robust when
> > > > shrinker->count_objects return negative freeable.
> > >
> > > Shrinker.h says count_objects should return 0 if there are no
> > > freeable objects, not -1.
> > >
> > > So if something returns -1, changing it with returning 0 would
> > be more proper fix.
> > >
> > Hi,
> > Indeed it's not a bug of vmscan, but there are many shrinkers
> > out there, which may return negative value unwillingly(in some
> > rare cases, such as decreasing cocurrently). It's unlikely and
> > should be avioded, but not impossible, this patch may make it
> > more robust and could not hurt :).
>
> Yub, I'm not strong against of your claim. However, let's think
> from different point of view.
>
> API says it should return 0 unless shrinker cannot find freeable
> object any more but with your change, implmentation handles
> although a shrinker return minus value by mistake.
>
> In future, MM guys might want to extend count_objects returning
> -ERR_SOMETHING to propagate error, for example but we cannot.
> Because some of shrinkers already rely on the implementation so
> if we start to support minus value return, some of shrinker might
> be broken.
>
> Yes, it's the imaginary scenario but wanted why such changes
> makes us trouble in future, API PoV.
I agree with your concern. How about we take another way by
adding some warning in such case? such as,
freeable = shrinker->count_objects(shrinker, shrinkctl);
+ if (unlikely(freeable < 0)) {
+ pr_err("shrink_slab: %pF negative objects returned. freeable=%ld\n",
+ shrinker->scan_objects, freeable);
+ freeable = 0; //maybe not needed?
+ }
if (freeable == 0)
return 0;
In this way, we would not break the API, but could alert user exception
with message, and make it more robust in such case.
Thanks.
next prev parent reply other threads:[~2017-11-27 6:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 1:37 [PATCH] mm/vmscan: make do_shrink_slab more robust Jiang Biao
2017-11-27 2:39 ` Minchan Kim
2017-11-27 4:46 ` jiang.biao2
2017-11-27 5:16 ` Minchan Kim
2017-11-27 6:27 ` jiang.biao2 [this message]
2017-11-27 6:38 ` Minchan Kim
2017-11-27 7:26 ` jiang.biao2
2017-11-27 8:27 ` Michal Hocko
2017-11-27 8:41 ` jiang.biao2
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=201711271427202879096@zte.com.cn \
--to=jiang.biao2@zte.com.cn \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hillf.zj@alibaba-inc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=ying.huang@intel.com \
--cc=zhong.weidong@zte.com.cn \
/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;
as well as URLs for NNTP newsgroup(s).