lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150113155639.53e48aad4b0cfe870ccffac4@linux-foundation.org>
Date:	Tue, 13 Jan 2015 15:56:39 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Vladimir Davydov <vdavydov@...allels.com>
Cc:	Johannes Weiner <hannes@...xchg.org>,
	Michal Hocko <mhocko@...e.cz>,
	Alexander Viro <viro@...iv.linux.org.uk>, <linux-mm@...ck.org>,
	<linux-fsdevel@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -mm] fs: shrinker: always scan at least one object of
 each type

On Mon, 12 Jan 2015 13:20:46 +0300 Vladimir Davydov <vdavydov@...allels.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?

--- 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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ