linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Chris Wilson <chris@chris-wilson.co.uk>,
	linux-mm@kvack.org, intel-gfx@lists.freedesktop.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Hillf Danton <hillf.zj@alibaba-inc.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	Shaohua Li <shli@fb.com>
Subject: Re: [PATCH 1/2] mm: Track actual nr_scanned during shrink_slab()
Date: Mon, 28 Aug 2017 17:09:25 +0900	[thread overview]
Message-ID: <20170828080925.GB6309@blaptop> (raw)
In-Reply-To: <29aae2cd-85a8-f3c4-66e2-4d4f5a2732c1@suse.cz>

Hi Vlastimil,

On Thu, Aug 24, 2017 at 10:00:49AM +0200, Vlastimil Babka wrote:
> On 08/24/2017 07:11 AM, Minchan Kim wrote:
> > Hello Chris,
> > 
> > On Tue, Aug 22, 2017 at 02:53:24PM +0100, Chris Wilson wrote:
> >> Some shrinkers may only be able to free a bunch of objects at a time, and
> >> so free more than the requested nr_to_scan in one pass.
> 
> Can such shrinkers reflect that in their shrinker->batch value? Or is it
> unpredictable for each scan?
> 
> >> Whilst other
> >> shrinkers may find themselves even unable to scan as many objects as
> >> they counted, and so underreport. Account for the extra freed/scanned
> >> objects against the total number of objects we intend to scan, otherwise
> >> we may end up penalising the slab far more than intended. Similarly,
> >> we want to add the underperforming scan to the deferred pass so that we
> >> try harder and harder in future passes.
> >>
> >> v2: Andrew's shrinkctl->nr_scanned
> >>
> >> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> >> Cc: Andrew Morton <akpm@linux-foundation.org>
> >> Cc: Michal Hocko <mhocko@suse.com>
> >> Cc: Johannes Weiner <hannes@cmpxchg.org>
> >> Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
> >> Cc: Minchan Kim <minchan@kernel.org>
> >> Cc: Vlastimil Babka <vbabka@suse.cz>
> >> Cc: Mel Gorman <mgorman@techsingularity.net>
> >> Cc: Shaohua Li <shli@fb.com>
> >> Cc: linux-mm@kvack.org
> >> ---
> >>  include/linux/shrinker.h | 7 +++++++
> >>  mm/vmscan.c              | 7 ++++---
> >>  2 files changed, 11 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
> >> index 4fcacd915d45..51d189615bda 100644
> >> --- a/include/linux/shrinker.h
> >> +++ b/include/linux/shrinker.h
> >> @@ -18,6 +18,13 @@ struct shrink_control {
> >>  	 */
> >>  	unsigned long nr_to_scan;
> >>  
> >> +	/*
> >> +	 * How many objects did scan_objects process?
> >> +	 * This defaults to nr_to_scan before every call, but the callee
> >> +	 * should track its actual progress.
> > 
> > So, if shrinker scans object more than requested, it shoud add up
> > top nr_scanned?
> 
> That sounds fair.
> 
> > opposite case, if shrinker scans less than requested, it should reduce
> > nr_scanned to the value scanned real?
> 
> Unsure. If they can't scan more, the following attempt in the next
> iteration should fail and thus result in SHRINK_STOP?

What should I do if I don't scan anything for some reasons on this iteration
but don't want to stop by SHRINK_STOP because I expect I will scan them
on next iteration? Return 1 on shrinker side? It doesn't make sense.
nr_scanned represents for realy scan value so if shrinker doesn't scan
anything but want to continue the scanning, it can return 0 and VM
should take care of it to prevent infinite loop because shrinker's
expectation can be wrong so it can make the system live-lock.

> 
> > To track the progress is burden for the shrinker users.
> 
> You mean shrinker authors, not users? AFAICS this nr_scanned is opt-in,
> if they don't want to touch it, the default remains nr_to_scan.

I meant shrinker authors which is user for VM shrinker. :-D

Anyway, my point is that shrinker are already racy. IOW, the amount of
objects in a shrinker can be changed between count_object and
scan_object and I'm not sure such micro object tracking based on stale
value will help a lot in every cases.

That means it could be broken interface without guarantee helping
the system as expected.

However, with v1 from Chris, it's low hanging fruit to get without pain
so that's why I wanted to merge v1 rather than v2.

> 
> > Even if a
> > shrinker has a mistake, VM will have big trouble like infinite loop.
> 
> We could fake 0 as 1 or something, at least.

Yes, I think we need it if we want to go this way.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      parent reply	other threads:[~2017-08-28  8:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-12 11:34 [PATCH] mm: Reward slab shrinkers that reclaim more than they were asked Chris Wilson
2017-08-15 22:30 ` Andrew Morton
2017-08-15 22:53   ` Chris Wilson
2017-08-22 13:53   ` [PATCH 1/2] mm: Track actual nr_scanned during shrink_slab() Chris Wilson
2017-08-22 13:53     ` [PATCH 2/2] drm/i915: Wire up shrinkctl->nr_scanned Chris Wilson
2017-08-22 22:45       ` Andrew Morton
2017-08-23 14:20         ` Chris Wilson
2017-08-24  5:11     ` [PATCH 1/2] mm: Track actual nr_scanned during shrink_slab() Minchan Kim
2017-08-24  8:00       ` Vlastimil Babka
2017-08-25 21:41         ` Andrew Morton
2017-08-28  8:09         ` Minchan Kim [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=20170828080925.GB6309@blaptop \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=hannes@cmpxchg.org \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=shli@fb.com \
    --cc=vbabka@suse.cz \
    /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).