From: Theodore Ts'o <tytso@mit.edu>
To: Zheng Liu <gnehzuil.liu@gmail.com>
Cc: linux-ext4@vger.kernel.org, Jan kara <jack@suse.cz>,
Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH 7/7 v2] ext4: reclaim extents from extent status tree
Date: Fri, 18 Jan 2013 00:19:21 -0500 [thread overview]
Message-ID: <20130118051921.GC13785@thunk.org> (raw)
In-Reply-To: <1357901627-3068-8-git-send-email-wenqing.lz@taobao.com>
On Fri, Jan 11, 2013 at 06:53:47PM +0800, Zheng Liu wrote:
> +
> +static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
> +{
> + struct ext4_es_shrinker *es_shrinker = container_of(shrink,
> + struct ext4_es_shrinker, es_shrinker);
> + struct ext4_inode_info *ei;
> + int nr_to_scan = sc->nr_to_scan;
> + int ret, shrunk_nr = 0;
> +
> + if (!nr_to_scan)
> + return shrunk_nr;
This doesn't look right. To quote from include/linux/shrinker.h:
/*
* A callback you can register to apply pressure to ageable caches.
*
* 'sc' is passed shrink_control which includes a count 'nr_to_scan'
* and a 'gfpmask'. It should look through the least-recently-used
* 'nr_to_scan' entries and attempt to free them up. It should return
* the number of objects which remain in the cache. If it returns -1, it means
* it cannot do any scanning at this time (eg. there is a risk of deadlock).
*
* ...
*
* Note that 'shrink' will be passed nr_to_scan == 0 when the VM is
* querying the cache size, so a fastpath for that case is appropriate.
*/
The first thing the shrink_slab() function will do is call the
shrinker with nr_to_scan set to zero. Since the shrinker function is
currently returning the number of items that were discarded, instead
of the number of objects that were deleted, when nr_to_scan is zero,
the function returns zero. This will cause shrink_slab() to bail out,
which means the shrinker code isn't actually going to release any
objects. (i.e., at the moment it is a no-op).
It might also be a good idea to add a trace point so we can debug what
is going on with the shrinker, so we can known when its called, and
how much progress it has made in releasing objcts when the system is
under memory pressure.
Also, one of the things that we need to think about is making sure we
have the right balance. We don't want to be too aggressive in
shrinking the extent status tree cache, but we want to be a good
citizen as well. I'm a bit concerned we might be too aggressive,
because there are two ways that items can be freed from the
extent_status tree. One is if the inode is not used at all, and when
we release the inode, we'll drop all of the entries in the
extent_status_tree for that inode. The second way is via the shrinker
which we've registered.
So I am a bit concerned that we may end up giving twice. There's also
a place where we can register a fs-specific shrinker via
sb->s_op->nr_cached_objects() and sb->s_op->free_cached_objects().
That might be better since it will allow us to balance across file
systems a bit more fairly.
Anyway, we're going to have to do some testing to make sure we're
doing something sane in low memory situations. Not doing any
shrinking is clearly bad, but I'm a bit worried that we could end up
doing too much shrinking, and our performance in memory constrained
scenarios might suffer as a result.
- Ted
next prev parent reply other threads:[~2013-01-18 5:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 10:53 [PATCH 0/7 v2] ext4: extent status tree (step2) Zheng Liu
2013-01-11 10:53 ` [PATCH 1/7 v2] ext4: refine extent status tree Zheng Liu
2013-01-23 4:20 ` Theodore Ts'o
2013-01-11 10:53 ` [PATCH 2/7 v2] ext4: remove EXT4_MAP_FROM_CLUSTER flag Zheng Liu
2013-01-11 10:53 ` [PATCH 3/7 v2] ext4: add physical block and status member into extent status tree Zheng Liu
2013-01-17 4:42 ` Theodore Ts'o
2013-01-18 9:49 ` Zheng Liu
2013-01-11 10:53 ` [PATCH 4/7 v2] ext4: adjust interfaces of " Zheng Liu
2013-01-11 10:53 ` [PATCH 5/7 v2] ext4: track all extent status in " Zheng Liu
2013-01-23 4:31 ` Theodore Ts'o
2013-01-11 10:53 ` [PATCH 6/7 v2] ext4: lookup block mapping " Zheng Liu
2013-01-18 4:00 ` Theodore Ts'o
2013-01-18 9:52 ` Zheng Liu
2013-01-11 10:53 ` [PATCH 7/7 v2] ext4: reclaim extents from " Zheng Liu
2013-01-18 5:19 ` Theodore Ts'o [this message]
2013-01-18 5:39 ` Theodore Ts'o
2013-01-21 7:24 ` Zheng Liu
2013-01-21 15:00 ` Theodore Ts'o
2013-01-21 17:09 ` Zheng Liu
2013-01-23 6:06 ` [PATCH] fs: allow for fs-specific objects to be pruned as part of pruning inodes Theodore Ts'o
2013-01-23 10:52 ` Jan Kara
2013-01-23 13:06 ` Carlos Maiolino
2013-01-23 13:32 ` Dave Chinner
2013-01-23 16:34 ` Theodore Ts'o
2013-01-23 23:35 ` Dave Chinner
2013-01-24 8:58 ` Andrew Morton
2013-01-24 20:03 ` Dave Chinner
2013-01-21 14:43 ` [PATCH 7/7 v2] ext4: reclaim extents from extent status tree Jan Kara
2013-01-21 15:12 ` Zheng Liu
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=20130118051921.GC13785@thunk.org \
--to=tytso@mit.edu \
--cc=gnehzuil.liu@gmail.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=wenqing.lz@taobao.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;
as well as URLs for NNTP newsgroup(s).