From: Andrew Morton <akpm@linux-foundation.org>
To: Vladimir Davydov <vdavydov@parallels.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
devel@openvz.org, Mel Gorman <mgorman@suse.de>,
Michal Hocko <mhocko@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>,
Rik van Riel <riel@redhat.com>,
Dave Chinner <dchinner@redhat.com>,
Glauber Costa <glommer@gmail.com>
Subject: Re: [PATCH 2/3] mm: vmscan: get rid of DEFAULT_SEEKS and document shrink_slab logic
Date: Tue, 4 Feb 2014 13:58:36 -0800 [thread overview]
Message-ID: <20140204135836.05c09c765073513e62edd174@linux-foundation.org> (raw)
In-Reply-To: <e204471853100447541ce36b198c0d45bf06379c.1389982079.git.vdavydov@parallels.com>
On Fri, 17 Jan 2014 23:25:30 +0400 Vladimir Davydov <vdavydov@parallels.com> wrote:
> Each shrinker must define the number of seeks it takes to recreate a
> shrinkable cache object. It is used to balance slab reclaim vs page
> reclaim: assuming it costs one seek to replace an LRU page, we age equal
> percentages of the LRU and ageable caches. So far, everything sounds
> clear, but the code implementing this behavior is rather confusing.
>
> First, there is the DEFAULT_SEEKS constant, which equals 2 for some
> reason:
>
> #define DEFAULT_SEEKS 2 /* A good number if you don't know better. */
>
> Most shrinkers define `seeks' to be equal to DEFAULT_SEEKS, some use
> DEFAULT_SEEKS*N, and there are a few that totally ignore it. What is
> peculiar, dcache and icache shrinkers have seeks=DEFAULT_SEEKS although
> recreating an inode typically requires one seek. Does this mean that we
> scan twice more inodes than we should?
>
> Actually, no. The point is that vmscan handles DEFAULT_SEEKS as if it
> were 1 (`delta' is the number of objects we are going to scan):
>
> shrink_slab_node():
> delta = (4 * nr_pages_scanned) / shrinker->seeks;
> delta *= freeable;
> do_div(delta, lru_pages + 1);
>
> i.e.
>
> 2 * nr_pages_scanned DEFAULT_SEEKS
> delta = -------------------- * --------------- * freeable;
> lru_pages shrinker->seeks
>
> Here we double the number of pages scanned in order to take into account
> moves of on-LRU pages from the inactive list to the active list, which
> we do not count in nr_pages_scanned.
>
> That said, shrinker->seeks=DEFAULT_SEEKS*N is equivalent to N seeks, so
> why on the hell do we need it?
>
> IMO, the existence of the DEFAULT_SEEKS constant only causes confusion
> for both users of the shrinker interface and those trying to understand
> how slab shrinking works. The meaning of the `seeks' is perfectly
> explained by the comment to it and there is no need in any obscure
> constants for using it.
>
> That's why I'm sending this patch which completely removes DEFAULT_SEEKS
> and makes all shrinkers use N instead of N*DEFAULT_SEEKS, documenting
> the idea lying behind shrink_slab() in the meanwhile.
>
> Unfortunately, there are a few shrinkers that define seeks=1, which is
> impossible to transfer to the new interface intact, namely:
>
> nfsd_reply_cache_shrinker
> ttm_pool_manager::mm_shrink
> ttm_pool_manager::mm_shrink
> dm_bufio_client::shrinker
>
> It seems to me their authors were simply deceived by this mysterious
> DEFAULT_SEEKS constant, because I've found no documentation why these
> particular caches should be scanned more aggressively than the page and
> other slab caches. For them, this patch leaves seeks=1. Thus, it DOES
> introduce a functional change: the shrinkers enumerated above will be
> scanned twice less intensively than they are now. I do not think that
> this will cause any problems though.
>
um, yes. DEFAULT_SEEKS is supposed to be "the number of seeks if you
don't know any better". Using DEFAULT_SEEKS*n is just daft.
So why did I originally make DEFAULT_SEEKS=2? Because I figured that to
recreate (say) an inode would require a seek to the inode data then a
seek back. Is it legitimate to include the
seek-back-to-what-you-were-doing-before seek in the cost of an inode
reclaim? I guess so...
If a filesystem were to require a seek to the superblock for every
inode read (ok, bad example) then the cost of reestablishing that inode
would be 3.
All that being said, why did you go through and halve everything? The
cost of reestablishing an ext2 inode should be "2 seeks", but the patch
makes it "1".
--
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>
next prev parent reply other threads:[~2014-02-04 21:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 19:25 [PATCH 1/3] mm: vmscan: shrink_slab: rename max_pass -> freeable Vladimir Davydov
2014-01-17 19:25 ` [PATCH 2/3] mm: vmscan: get rid of DEFAULT_SEEKS and document shrink_slab logic Vladimir Davydov
2014-02-04 21:58 ` Andrew Morton [this message]
2014-02-05 7:16 ` Vladimir Davydov
2014-02-05 20:52 ` Andrew Morton
2014-02-06 18:51 ` Vladimir Davydov
2014-01-17 19:25 ` [PATCH 3/3] mm: vmscan: shrink_slab: do not skip caches with < batch_size objects Vladimir Davydov
2014-01-21 22:22 ` [PATCH 1/3] mm: vmscan: shrink_slab: rename max_pass -> freeable David Rientjes
2014-01-22 6:11 ` Vladimir Davydov
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=20140204135836.05c09c765073513e62edd174@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dchinner@redhat.com \
--cc=devel@openvz.org \
--cc=glommer@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=riel@redhat.com \
--cc=vdavydov@parallels.com \
/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