All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov@parallels.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.cz>,
	Alexander Viro <viro@zeniv.linux.org.uk>, <linux-mm@kvack.org>,
	<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] fs: shrinker: always scan at least one object of each type
Date: Wed, 14 Jan 2015 10:36:08 +0300	[thread overview]
Message-ID: <20150114073608.GC11264@esperanza> (raw)
In-Reply-To: <20150113155639.53e48aad4b0cfe870ccffac4@linux-foundation.org>

On Tue, Jan 13, 2015 at 03:56:39PM -0800, Andrew Morton wrote:
> On Mon, 12 Jan 2015 13:20:46 +0300 Vladimir Davydov <vdavydov@parallels.com> wrote:
> 
> > In super_cache_scan() we divide the number of objects of particular type
> > by the total number of objects in order to distribute pressure among
> > different types of fs objects (inodes, dentries, fs-private objects).
> > As a result, in some corner cases we can get nr_to_scan=0 even if there
> > are some objects to reclaim, e.g. dentries=1, inodes=1, fs_objects=1,
> > nr_to_scan=1/3=0.
> > 
> > This is unacceptable for per memcg kmem accounting, because this means
> > that some objects may never get reclaimed after memcg death, preventing
> > it from being freed.
> > 
> > This patch therefore assures that super_cache_scan() will scan at least
> > one object of each type if any.
> > 
> > --- a/fs/super.c
> > +++ b/fs/super.c
> > @@ -92,13 +92,13 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
> >  	 * prune the dcache first as the icache is pinned by it, then
> >  	 * prune the icache, followed by the filesystem specific caches
> >  	 */
> > -	sc->nr_to_scan = dentries;
> > +	sc->nr_to_scan = dentries + 1;
> >  	freed = prune_dcache_sb(sb, sc);
> > -	sc->nr_to_scan = inodes;
> > +	sc->nr_to_scan = inodes + 1;
> >  	freed += prune_icache_sb(sb, sc);
> >  
> >  	if (fs_objects) {
> > -		sc->nr_to_scan = fs_objects;
> > +		sc->nr_to_scan = fs_objects + 1;
> >  		freed += sb->s_op->free_cached_objects(sb, sc);
> >  	}
> 
> A reader of this code will wonder "why is it adding 1 everywhere". 
> Let's tell them?

Yeah, sounds reasonable. Thank you!

> 
> --- a/fs/super.c~fs-shrinker-always-scan-at-least-one-object-of-each-type-fix
> +++ a/fs/super.c
> @@ -91,6 +91,9 @@ static unsigned long super_cache_scan(st
>  	/*
>  	 * prune the dcache first as the icache is pinned by it, then
>  	 * prune the icache, followed by the filesystem specific caches
> +	 *
> +	 * Ensure that we always scan at least one object - memcg kmem
> +	 * accounting uses this to fully empty the caches.
>  	 */
>  	sc->nr_to_scan = dentries + 1;
>  	freed = prune_dcache_sb(sb, sc);
> _
> 

--
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>

WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Davydov <vdavydov@parallels.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.cz>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH -mm] fs: shrinker: always scan at least one object of each type
Date: Wed, 14 Jan 2015 10:36:08 +0300	[thread overview]
Message-ID: <20150114073608.GC11264@esperanza> (raw)
In-Reply-To: <20150113155639.53e48aad4b0cfe870ccffac4@linux-foundation.org>

On Tue, Jan 13, 2015 at 03:56:39PM -0800, Andrew Morton wrote:
> On Mon, 12 Jan 2015 13:20:46 +0300 Vladimir Davydov <vdavydov@parallels.com> wrote:
> 
> > In super_cache_scan() we divide the number of objects of particular type
> > by the total number of objects in order to distribute pressure among
> > different types of fs objects (inodes, dentries, fs-private objects).
> > As a result, in some corner cases we can get nr_to_scan=0 even if there
> > are some objects to reclaim, e.g. dentries=1, inodes=1, fs_objects=1,
> > nr_to_scan=1/3=0.
> > 
> > This is unacceptable for per memcg kmem accounting, because this means
> > that some objects may never get reclaimed after memcg death, preventing
> > it from being freed.
> > 
> > This patch therefore assures that super_cache_scan() will scan at least
> > one object of each type if any.
> > 
> > --- a/fs/super.c
> > +++ b/fs/super.c
> > @@ -92,13 +92,13 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
> >  	 * prune the dcache first as the icache is pinned by it, then
> >  	 * prune the icache, followed by the filesystem specific caches
> >  	 */
> > -	sc->nr_to_scan = dentries;
> > +	sc->nr_to_scan = dentries + 1;
> >  	freed = prune_dcache_sb(sb, sc);
> > -	sc->nr_to_scan = inodes;
> > +	sc->nr_to_scan = inodes + 1;
> >  	freed += prune_icache_sb(sb, sc);
> >  
> >  	if (fs_objects) {
> > -		sc->nr_to_scan = fs_objects;
> > +		sc->nr_to_scan = fs_objects + 1;
> >  		freed += sb->s_op->free_cached_objects(sb, sc);
> >  	}
> 
> A reader of this code will wonder "why is it adding 1 everywhere". 
> Let's tell them?

Yeah, sounds reasonable. Thank you!

> 
> --- a/fs/super.c~fs-shrinker-always-scan-at-least-one-object-of-each-type-fix
> +++ a/fs/super.c
> @@ -91,6 +91,9 @@ static unsigned long super_cache_scan(st
>  	/*
>  	 * prune the dcache first as the icache is pinned by it, then
>  	 * prune the icache, followed by the filesystem specific caches
> +	 *
> +	 * Ensure that we always scan at least one object - memcg kmem
> +	 * accounting uses this to fully empty the caches.
>  	 */
>  	sc->nr_to_scan = dentries + 1;
>  	freed = prune_dcache_sb(sb, sc);
> _
> 

--
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>

WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Davydov <vdavydov@parallels.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.cz>,
	Alexander Viro <viro@zeniv.linux.org.uk>, <linux-mm@kvack.org>,
	<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] fs: shrinker: always scan at least one object of each type
Date: Wed, 14 Jan 2015 10:36:08 +0300	[thread overview]
Message-ID: <20150114073608.GC11264@esperanza> (raw)
In-Reply-To: <20150113155639.53e48aad4b0cfe870ccffac4@linux-foundation.org>

On Tue, Jan 13, 2015 at 03:56:39PM -0800, Andrew Morton wrote:
> On Mon, 12 Jan 2015 13:20:46 +0300 Vladimir Davydov <vdavydov@parallels.com> wrote:
> 
> > In super_cache_scan() we divide the number of objects of particular type
> > by the total number of objects in order to distribute pressure among
> > different types of fs objects (inodes, dentries, fs-private objects).
> > As a result, in some corner cases we can get nr_to_scan=0 even if there
> > are some objects to reclaim, e.g. dentries=1, inodes=1, fs_objects=1,
> > nr_to_scan=1/3=0.
> > 
> > This is unacceptable for per memcg kmem accounting, because this means
> > that some objects may never get reclaimed after memcg death, preventing
> > it from being freed.
> > 
> > This patch therefore assures that super_cache_scan() will scan at least
> > one object of each type if any.
> > 
> > --- a/fs/super.c
> > +++ b/fs/super.c
> > @@ -92,13 +92,13 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
> >  	 * prune the dcache first as the icache is pinned by it, then
> >  	 * prune the icache, followed by the filesystem specific caches
> >  	 */
> > -	sc->nr_to_scan = dentries;
> > +	sc->nr_to_scan = dentries + 1;
> >  	freed = prune_dcache_sb(sb, sc);
> > -	sc->nr_to_scan = inodes;
> > +	sc->nr_to_scan = inodes + 1;
> >  	freed += prune_icache_sb(sb, sc);
> >  
> >  	if (fs_objects) {
> > -		sc->nr_to_scan = fs_objects;
> > +		sc->nr_to_scan = fs_objects + 1;
> >  		freed += sb->s_op->free_cached_objects(sb, sc);
> >  	}
> 
> A reader of this code will wonder "why is it adding 1 everywhere". 
> Let's tell them?

Yeah, sounds reasonable. Thank you!

> 
> --- a/fs/super.c~fs-shrinker-always-scan-at-least-one-object-of-each-type-fix
> +++ a/fs/super.c
> @@ -91,6 +91,9 @@ static unsigned long super_cache_scan(st
>  	/*
>  	 * prune the dcache first as the icache is pinned by it, then
>  	 * prune the icache, followed by the filesystem specific caches
> +	 *
> +	 * Ensure that we always scan at least one object - memcg kmem
> +	 * accounting uses this to fully empty the caches.
>  	 */
>  	sc->nr_to_scan = dentries + 1;
>  	freed = prune_dcache_sb(sb, sc);
> _
> 

  reply	other threads:[~2015-01-14  7:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 10:20 [PATCH -mm] fs: shrinker: always scan at least one object of each type Vladimir Davydov
2015-01-12 10:20 ` Vladimir Davydov
2015-01-12 10:20 ` Vladimir Davydov
2015-01-13 23:56 ` Andrew Morton
2015-01-13 23:56   ` Andrew Morton
2015-01-13 23:56   ` Andrew Morton
2015-01-14  7:36   ` Vladimir Davydov [this message]
2015-01-14  7:36     ` Vladimir Davydov
2015-01-14  7:36     ` 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=20150114073608.GC11264@esperanza \
    --to=vdavydov@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.