]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
fs: convert inode and dentry shrinking to be node aware
authorDave Chinner <dchinner@redhat.com>
Thu, 27 Jun 2013 23:52:17 +0000 (09:52 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 28 Jun 2013 06:37:59 +0000 (16:37 +1000)
Now that the shrinker is passing a node in the scan control structure, we
can pass this to the the generic LRU list code to isolate reclaim to the
lists on matching nodes.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Glauber Costa <glommer@parallels.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Carlos Maiolino <cmaiolino@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Rientjes <rientjes@google.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: J. Bruce Fields <bfields@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Kent Overstreet <koverstreet@google.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/dcache.c
fs/inode.c
fs/internal.h
fs/super.c
fs/xfs/xfs_super.c
include/linux/fs.h

index 21f36b4d95ccc7cb2ee66d07b605cc0689c49fa8..7489b6f97b422fac422bd51abd90df3aa270134b 100644 (file)
@@ -891,6 +891,7 @@ dentry_lru_isolate(struct list_head *item, spinlock_t *lru_lock, void *arg)
  * prune_dcache_sb - shrink the dcache
  * @sb: superblock
  * @nr_to_scan : number of entries to try to free
+ * @nid: which node to scan for freeable entities
  *
  * Attempt to shrink the superblock dcache LRU by @nr_to_scan entries. This is
  * done when we need more memory an called from the superblock shrinker
@@ -899,13 +900,14 @@ dentry_lru_isolate(struct list_head *item, spinlock_t *lru_lock, void *arg)
  * This function may fail to free any resources if all the dentries are in
  * use.
  */
-long prune_dcache_sb(struct super_block *sb, unsigned long nr_to_scan)
+long prune_dcache_sb(struct super_block *sb, unsigned long nr_to_scan,
+                    int nid)
 {
        LIST_HEAD(dispose);
        long freed;
 
-       freed = list_lru_walk(&sb->s_dentry_lru, dentry_lru_isolate,
-                             &dispose, nr_to_scan);
+       freed = list_lru_walk_node(&sb->s_dentry_lru, nid, dentry_lru_isolate,
+                                      &dispose, &nr_to_scan);
        shrink_dentry_list(&dispose);
        return freed;
 }
index 30b6f55bcaf07a34b6b806eea766bb1a32d2d189..e315c0a9774e90196c329439ff76f5cdb203062a 100644 (file)
@@ -748,13 +748,14 @@ inode_lru_isolate(struct list_head *item, spinlock_t *lru_lock, void *arg)
  * to trim from the LRU. Inodes to be freed are moved to a temporary list and
  * then are freed outside inode_lock by dispose_list().
  */
-long prune_icache_sb(struct super_block *sb, unsigned long nr_to_scan)
+long prune_icache_sb(struct super_block *sb, unsigned long nr_to_scan,
+                    int nid)
 {
        LIST_HEAD(freeable);
        long freed;
 
-       freed = list_lru_walk(&sb->s_inode_lru, inode_lru_isolate,
-                                               &freeable, nr_to_scan);
+       freed = list_lru_walk_node(&sb->s_inode_lru, nid, inode_lru_isolate,
+                                      &freeable, &nr_to_scan);
        dispose_list(&freeable);
        return freed;
 }
index 38879a5c146a61fb7d0cec93abb74299e6fb0211..0b0db701bb779425e48dbd0c9711ea50cddef5b3 100644 (file)
@@ -111,7 +111,8 @@ extern int open_check_o_direct(struct file *f);
  * inode.c
  */
 extern spinlock_t inode_sb_list_lock;
-extern long prune_icache_sb(struct super_block *sb, unsigned long nr_to_scan);
+extern long prune_icache_sb(struct super_block *sb, unsigned long nr_to_scan,
+                           int nid);
 extern void inode_add_lru(struct inode *inode);
 
 /*
@@ -127,7 +128,8 @@ extern int invalidate_inodes(struct super_block *, bool);
  * dcache.c
  */
 extern struct dentry *__d_alloc(struct super_block *, const struct qstr *);
-extern long prune_dcache_sb(struct super_block *sb, unsigned long nr_to_scan);
+extern long prune_dcache_sb(struct super_block *sb, unsigned long nr_to_scan,
+                           int nid);
 
 /*
  * read_write.c
index 21201f91548cbbf431812b740266f51f665ea8e5..ca41919df1de3df355a09bbf3a156fe0b7c6573d 100644 (file)
@@ -76,10 +76,10 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
                return SHRINK_STOP;
 
        if (sb->s_op && sb->s_op->nr_cached_objects)
-               fs_objects = sb->s_op->nr_cached_objects(sb);
+               fs_objects = sb->s_op->nr_cached_objects(sb, sc->nid);
 
-       inodes = list_lru_count(&sb->s_inode_lru);
-       dentries = list_lru_count(&sb->s_dentry_lru);
+       inodes = list_lru_count_node(&sb->s_inode_lru, sc->nid);
+       dentries = list_lru_count_node(&sb->s_dentry_lru, sc->nid);
        total_objects = dentries + inodes + fs_objects + 1;
 
        /* proportion the scan between the caches */
@@ -90,13 +90,14 @@ 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
         */
-       freed = prune_dcache_sb(sb, dentries);
-       freed += prune_icache_sb(sb, inodes);
+       freed = prune_dcache_sb(sb, dentries, sc->nid);
+       freed += prune_icache_sb(sb, inodes, sc->nid);
 
        if (fs_objects) {
                fs_objects = mult_frac(sc->nr_to_scan, fs_objects,
                                                                total_objects);
-               freed += sb->s_op->free_cached_objects(sb, fs_objects);
+               freed += sb->s_op->free_cached_objects(sb, fs_objects,
+                                                      sc->nid);
        }
 
        drop_super(sb);
@@ -115,10 +116,13 @@ static unsigned long super_cache_count(struct shrinker *shrink,
                return 0;
 
        if (sb->s_op && sb->s_op->nr_cached_objects)
-               total_objects = sb->s_op->nr_cached_objects(sb);
+               total_objects = sb->s_op->nr_cached_objects(sb,
+                                                sc->nid);
 
-       total_objects += list_lru_count(&sb->s_dentry_lru);
-       total_objects += list_lru_count(&sb->s_inode_lru);
+       total_objects += list_lru_count_node(&sb->s_dentry_lru,
+                                                sc->nid);
+       total_objects += list_lru_count_node(&sb->s_inode_lru,
+                                                sc->nid);
 
        total_objects = vfs_pressure_ratio(total_objects);
        drop_super(sb);
@@ -234,6 +238,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
                s->s_shrink.scan_objects = super_cache_scan;
                s->s_shrink.count_objects = super_cache_count;
                s->s_shrink.batch = 1024;
+               s->s_shrink.flags = SHRINKER_NUMA_AWARE;
        }
 out:
        return s;
index 60ca338442fadce8727c95402a0a10e7746e0eef..06602645e474a4ea95319c859d372c496b0da3c2 100644 (file)
@@ -1532,7 +1532,8 @@ xfs_fs_mount(
 
 static long
 xfs_fs_nr_cached_objects(
-       struct super_block      *sb)
+       struct super_block      *sb,
+       int                     nid)
 {
        return xfs_reclaim_inodes_count(XFS_M(sb));
 }
@@ -1540,7 +1541,8 @@ xfs_fs_nr_cached_objects(
 static long
 xfs_fs_free_cached_objects(
        struct super_block      *sb,
-       long                    nr_to_scan)
+       long                    nr_to_scan,
+       int                     nid)
 {
        return xfs_reclaim_inodes_nr(XFS_M(sb), nr_to_scan);
 }
index 092f88c3d1ef88710ca1678fd9074c134e4798cd..7ca45197c2845e0872742ee437e4ffbc3f307a4a 100644 (file)
@@ -1620,8 +1620,8 @@ struct super_operations {
        ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
 #endif
        int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
-       long (*nr_cached_objects)(struct super_block *);
-       long (*free_cached_objects)(struct super_block *, long);
+       long (*nr_cached_objects)(struct super_block *, int);
+       long (*free_cached_objects)(struct super_block *, long, int);
 };
 
 /*