public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <dgc@sgi.com>
To: Steve Lord <lord@xfs.org>
Cc: linux-kernel@vger.kernel.org, linux-xfs@oss.sgi.com
Subject: Re: Major XFS problems...
Date: Thu, 9 Sep 2004 16:52:55 +1000	[thread overview]
Message-ID: <20040909165255.C2738@melbourne.sgi.com> (raw)
In-Reply-To: <413F823F.3020507@xfs.org>; from lord@xfs.org on Wed, Sep 08, 2004 at 05:05:51PM -0500

[cc'ing back to lkml]

On Wed, Sep 08, 2004 at 05:05:51PM -0500, Steve Lord wrote:
> 
> I wonder what the effect of /proc/sys/vm/swappiness
> and /proc/sys/vm/vfs_cache_pressure is on these situations.

Hi Steve.

I very much doubt vm_swappiness will have any effect on this - it
just determines whether to throw away page cache pages or swap out
mapped pages - it won't affect the dentry cache size. The best
it can do is allow us to swap out more pages so the dentry cache
can grow larger....

Looking at vfs_cache_pressure (documented in Documentation/
filesystems/proc.txt), it is used to make the number of unused
inodes and dentries used by the system appear to be smaller or
larger to the slab shrinker function:

661 static int shrink_dcache_memory(int nr, unsigned int gfp_mask)
662 {
663         if (nr) {
664                 if (!(gfp_mask & __GFP_FS))
665                         return -1;
666                 prune_dcache(nr);
667         }
668         return (dentry_stat.nr_unused / 100) * sysctl_vfs_cache_pressure;
669 }

and hence the shrinker will tend to remove more or less dentries or
inodes when the cache is asked to be shrunk.  It will have no real
effect if the unused dentry list is small (i.e. we're actively
growing the dentry cache) which seems to be the case here.

FWIW, it appears to me that the real problem is that shrink_dcache_memory()
does not shrink the active dentry cache down - I think it needs to do more
than just free up unused dentries. I'm not saying this is an easy thing
to do (I don't know if it's even possible), but IMO if we allow the dentry
cache to grow without bound or without a method to shrink the active
tree we will hit this problem a lot more often as filesystems grow larger.

For those that know this code well, it looks like there's a bug
in the above code - the shrinker calls into this function first with
nr = 0 to determine how much it can reclaim from the slab.

If the dentry_stat.nr_unused is less than 100, then we'll return 0
due to integer division (99/100 = 0), and the shrinker calculations
will see this as a slab that does not need shrinking because:

185         list_for_each_entry(shrinker, &shrinker_list, list) {
186                 unsigned long long delta;
187 
188                 delta = (4 * scanned) / shrinker->seeks;
189                 delta *= (*shrinker->shrinker)(0, gfp_mask);
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190                 do_div(delta, lru_pages + 1);
191                 shrinker->nr += delta;
192                 if (shrinker->nr < 0)
193                         shrinker->nr = LONG_MAX;        /* It wrapped! */
194 
195                 if (shrinker->nr <= SHRINK_BATCH)
196                         continue;

because we returned zero and therefore delta becomes zero and
shrinker->nr never gets larger than SHRINK_BATCH.

Hence in low memory conditions when you've already reaped most of
the unused dentries, you can't free up the last 99 unused dentries.
Maybe this is intentional (anyone?) because there isn't very much to
free up in this case, but some memory freed is better than none when
you have nothing at all left.

Cheers,

Dave.
-- 
Dave Chinner
R&D Software Engineer
SGI Australian Software Group

       reply	other threads:[~2004-09-09  6:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040908133954.GB390@unthought.net>
     [not found] ` <20040909074533.B3958243@wobbly.melbourne.sgi.com>
     [not found]   ` <413F823F.3020507@xfs.org>
2004-09-09  6:52     ` Dave Chinner [this message]
2004-09-09  8:10       ` Major XFS problems Andrew Morton
     [not found] <2Ca3I-2kY-7@gated-at.bofh.it>
     [not found] ` <2Cdl9-4Pc-65@gated-at.bofh.it>
2004-09-11  9:21   ` ADH
2004-09-08 15:24 Piszcz, Justin Michael
  -- strict thread matches above, loose matches on Subject: below --
2004-09-08 13:07 Piszcz, Justin Michael
2004-09-08 13:26 ` Jakob Oestergaard
2004-09-08 12:35 Jakob Oestergaard
2004-09-08 15:04 ` Anando Bhattacharya
2004-09-08 15:44   ` Jakob Oestergaard
2004-09-08 16:36     ` Greg Banks
2004-09-08 17:30       ` Jakob Oestergaard
2004-09-09  2:42         ` Greg Banks
2004-09-08 19:06       ` Bill Davidsen
2004-09-09  3:23         ` Greg Banks
2004-09-09 14:00       ` Jakob Oestergaard
2004-09-10  2:40         ` Greg Banks
2004-09-10  3:04           ` Kyle Moffett
2004-09-10  3:24             ` Greg Banks
2004-09-13  7:29         ` Jakob Oestergaard
2004-09-08 16:16 ` Jan-Frode Myklebust
2004-09-08 21:40 ` Nathan Scott
2004-09-08 23:22   ` Jakob Oestergaard
2004-09-08 23:42     ` Nathan Scott
2004-09-09 12:11       ` Jakob Oestergaard
2004-09-09 18:09         ` Chris Wedgwood
2004-09-11 11:39 ` Grzegorz Piotr Jaskiewicz
2004-09-11 13:03   ` Bjoern Brauel
2004-09-11 13:38   ` Anton Blanchard
2004-09-11 14:54     ` Miquel van Smoorenburg
2004-09-11 18:20     ` Grzegorz Piotr Jaskiewicz
2004-09-11 13:58 ` Clemens Schwaighofer

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=20040909165255.C2738@melbourne.sgi.com \
    --to=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@oss.sgi.com \
    --cc=lord@xfs.org \
    /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