Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: consolidate {nr,free}_cached_objects args in shrink_control

We are going to make FS shrinkers memcg-aware. To achieve that, we will
have to pass the memcg to scan to the nr_cached_objects and
free_cached_objects VFS methods, which currently take only the NUMA node
to scan. Since the shrink_control structure already holds the node, and
the memcg to scan will be added to it when we introduce memcg-aware
vmscan, let us consolidate the methods' arguments in this structure to
keep things clean.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Suggested-by: Dave Chinner <david@fromorbit.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Greg Thelen <gthelen@google.com>
Cc: Glauber Costa <glommer@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Vladimir Davydov and committed by
Linus Torvalds
4101b624 503c358c

+13 -12
+6 -6
fs/super.c
··· 75 75 return SHRINK_STOP; 76 76 77 77 if (sb->s_op->nr_cached_objects) 78 - fs_objects = sb->s_op->nr_cached_objects(sb, sc->nid); 78 + fs_objects = sb->s_op->nr_cached_objects(sb, sc); 79 79 80 80 inodes = list_lru_shrink_count(&sb->s_inode_lru, sc); 81 81 dentries = list_lru_shrink_count(&sb->s_dentry_lru, sc); ··· 97 97 sc->nr_to_scan = inodes; 98 98 freed += prune_icache_sb(sb, sc); 99 99 100 - if (fs_objects) 101 - freed += sb->s_op->free_cached_objects(sb, fs_objects, 102 - sc->nid); 100 + if (fs_objects) { 101 + sc->nr_to_scan = fs_objects; 102 + freed += sb->s_op->free_cached_objects(sb, sc); 103 + } 103 104 104 105 drop_super(sb); 105 106 return freed; ··· 123 122 * s_op->nr_cached_objects(). 124 123 */ 125 124 if (sb->s_op && sb->s_op->nr_cached_objects) 126 - total_objects = sb->s_op->nr_cached_objects(sb, 127 - sc->nid); 125 + total_objects = sb->s_op->nr_cached_objects(sb, sc); 128 126 129 127 total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc); 130 128 total_objects += list_lru_shrink_count(&sb->s_inode_lru, sc);
+3 -4
fs/xfs/xfs_super.c
··· 1537 1537 static long 1538 1538 xfs_fs_nr_cached_objects( 1539 1539 struct super_block *sb, 1540 - int nid) 1540 + struct shrink_control *sc) 1541 1541 { 1542 1542 return xfs_reclaim_inodes_count(XFS_M(sb)); 1543 1543 } ··· 1545 1545 static long 1546 1546 xfs_fs_free_cached_objects( 1547 1547 struct super_block *sb, 1548 - long nr_to_scan, 1549 - int nid) 1548 + struct shrink_control *sc) 1550 1549 { 1551 - return xfs_reclaim_inodes_nr(XFS_M(sb), nr_to_scan); 1550 + return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan); 1552 1551 } 1553 1552 1554 1553 static const struct super_operations xfs_super_operations = {
+4 -2
include/linux/fs.h
··· 1635 1635 struct dquot **(*get_dquots)(struct inode *); 1636 1636 #endif 1637 1637 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1638 - long (*nr_cached_objects)(struct super_block *, int); 1639 - long (*free_cached_objects)(struct super_block *, long, int); 1638 + long (*nr_cached_objects)(struct super_block *, 1639 + struct shrink_control *); 1640 + long (*free_cached_objects)(struct super_block *, 1641 + struct shrink_control *); 1640 1642 }; 1641 1643 1642 1644 /*