From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail190.messagelabs.com (mail190.messagelabs.com [216.82.249.51]) by kanga.kvack.org (Postfix) with ESMTP id 3BDE68D003B for ; Mon, 25 Apr 2011 13:22:52 -0400 (EDT) From: Ying Han Subject: [PATCH V2 0/2] pass the scan_control into shrinkers Date: Mon, 25 Apr 2011 10:22:12 -0700 Message-Id: <1303752134-4856-1-git-send-email-yinghan@google.com> Sender: owner-linux-mm@kvack.org List-ID: To: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai Cc: linux-mm@kvack.org This patch changes the shrink_slab and shrinker APIs by consolidating existing parameters into shrink_control struct. This simplifies any further attempts to pass extra info to the shrinker. Instead of modifying all the shrinker files each time, we just need to extend the shrink_control struct. This patch is based on mmotm-2011-03-31-14-48. Ying Han (2): change the shrink_slab by passing shrink_control change shrinker API by passing shrink_control struct arch/x86/kvm/mmu.c | 3 +- drivers/gpu/drm/i915/i915_gem.c | 5 +-- drivers/gpu/drm/ttm/ttm_page_alloc.c | 4 ++- drivers/staging/zcache/zcache.c | 5 +++- fs/dcache.c | 8 +++++- fs/drop_caches.c | 6 ++++- fs/gfs2/glock.c | 5 +++- fs/inode.c | 6 ++++- fs/mbcache.c | 10 +++++--- fs/nfs/dir.c | 5 +++- fs/nfs/internal.h | 2 +- fs/quota/dquot.c | 5 +++- fs/xfs/linux-2.6/xfs_buf.c | 4 +- fs/xfs/linux-2.6/xfs_sync.c | 5 ++- fs/xfs/quota/xfs_qm.c | 7 +++-- include/linux/mm.h | 28 ++++++++++++++++------ mm/vmscan.c | 41 ++++++++++++++++++++++++---------- net/sunrpc/auth.c | 4 ++- 18 files changed, 107 insertions(+), 46 deletions(-) -- 1.7.3.1 -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with ESMTP id 9388C8D003B for ; Mon, 25 Apr 2011 13:22:54 -0400 (EDT) From: Ying Han Subject: [PATCH V2 1/2] change the shrink_slab by passing shrink_control Date: Mon, 25 Apr 2011 10:22:13 -0700 Message-Id: <1303752134-4856-2-git-send-email-yinghan@google.com> In-Reply-To: <1303752134-4856-1-git-send-email-yinghan@google.com> References: <1303752134-4856-1-git-send-email-yinghan@google.com> Sender: owner-linux-mm@kvack.org List-ID: To: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai Cc: linux-mm@kvack.org This patch consolidates existing parameters to shrink_slab() to a new shrink_control struct. This is needed later to pass the same struct to shrinkers. changelog v2..v1: 1. define a new struct shrink_control and only pass some values down to the shrinker instead of the scan_control. Signed-off-by: Ying Han --- fs/drop_caches.c | 6 +++++- include/linux/mm.h | 13 +++++++++++-- mm/vmscan.c | 30 ++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 816f88e..c671290 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -36,9 +36,13 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) static void drop_slab(void) { int nr_objects; + struct shrink_control shrink = { + .gfp_mask = GFP_KERNEL, + .nr_scanned = 1000, + }; do { - nr_objects = shrink_slab(1000, GFP_KERNEL, 1000); + nr_objects = shrink_slab(&shrink, 1000); } while (nr_objects > 10); } diff --git a/include/linux/mm.h b/include/linux/mm.h index 0716517..7a2f657 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1131,6 +1131,15 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm) #endif /* + * This struct is used to pass information from page reclaim to the shrinkers. + * We consolidate the values for easier extention later. + */ +struct shrink_control { + unsigned long nr_scanned; + gfp_t gfp_mask; +}; + +/* * A callback you can register to apply pressure to ageable caches. * * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should @@ -1601,8 +1610,8 @@ int in_gate_area_no_task(unsigned long addr); int drop_caches_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, - unsigned long lru_pages); +unsigned long shrink_slab(struct shrink_control *shrink, + unsigned long lru_pages); #ifndef CONFIG_MMU #define randomize_va_space 0 diff --git a/mm/vmscan.c b/mm/vmscan.c index 060e4c1..40edf73 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -220,11 +220,13 @@ EXPORT_SYMBOL(unregister_shrinker); * * Returns the number of slab objects which we shrunk. */ -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, - unsigned long lru_pages) +unsigned long shrink_slab(struct shrink_control *shrink, + unsigned long lru_pages) { struct shrinker *shrinker; unsigned long ret = 0; + unsigned long scanned = shrink->nr_scanned; + gfp_t gfp_mask = shrink->gfp_mask; if (scanned == 0) scanned = SWAP_CLUSTER_MAX; @@ -2032,7 +2034,8 @@ static bool all_unreclaimable(struct zonelist *zonelist, * else, the number of pages reclaimed */ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, - struct scan_control *sc) + struct scan_control *sc, + struct shrink_control *shrink) { int priority; unsigned long total_scanned = 0; @@ -2066,7 +2069,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, lru_pages += zone_reclaimable_pages(zone); } - shrink_slab(sc->nr_scanned, sc->gfp_mask, lru_pages); + shrink->nr_scanned = sc->nr_scanned; + shrink_slab(shrink, lru_pages); if (reclaim_state) { sc->nr_reclaimed += reclaim_state->reclaimed_slab; reclaim_state->reclaimed_slab = 0; @@ -2130,12 +2134,15 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .mem_cgroup = NULL, .nodemask = nodemask, }; + struct shrink_control shrink = { + .gfp_mask = sc.gfp_mask, + }; trace_mm_vmscan_direct_reclaim_begin(order, sc.may_writepage, gfp_mask); - nr_reclaimed = do_try_to_free_pages(zonelist, &sc); + nr_reclaimed = do_try_to_free_pages(zonelist, &sc, &shrink); trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); @@ -2333,6 +2340,9 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, .order = order, .mem_cgroup = NULL, }; + struct shrink_control shrink = { + .gfp_mask = sc.gfp_mask, + }; loop_again: total_scanned = 0; sc.nr_reclaimed = 0; @@ -2432,8 +2442,8 @@ loop_again: end_zone, 0)) shrink_zone(priority, zone, &sc); reclaim_state->reclaimed_slab = 0; - nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL, - lru_pages); + shrink.nr_scanned = sc.nr_scanned; + nr_slab = shrink_slab(&shrink, lru_pages); sc.nr_reclaimed += reclaim_state->reclaimed_slab; total_scanned += sc.nr_scanned; @@ -2969,6 +2979,9 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) .swappiness = vm_swappiness, .order = order, }; + struct shrink_control shrink = { + .gfp_mask = sc.gfp_mask, + }; unsigned long nr_slab_pages0, nr_slab_pages1; cond_resched(); @@ -2995,6 +3008,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) } nr_slab_pages0 = zone_page_state(zone, NR_SLAB_RECLAIMABLE); + shrink.nr_scanned = sc.nr_scanned; if (nr_slab_pages0 > zone->min_slab_pages) { /* * shrink_slab() does not currently allow us to determine how @@ -3010,7 +3024,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) unsigned long lru_pages = zone_reclaimable_pages(zone); /* No reclaimable slab or very low memory pressure */ - if (!shrink_slab(sc.nr_scanned, gfp_mask, lru_pages)) + if (!shrink_slab(&shrink, lru_pages)) break; /* Freed enough memory */ -- 1.7.3.1 -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id AAE4A8D0040 for ; Mon, 25 Apr 2011 13:22:56 -0400 (EDT) From: Ying Han Subject: [PATCH V2 2/2] change shrinker API by passing shrink_control struct Date: Mon, 25 Apr 2011 10:22:14 -0700 Message-Id: <1303752134-4856-3-git-send-email-yinghan@google.com> In-Reply-To: <1303752134-4856-1-git-send-email-yinghan@google.com> References: <1303752134-4856-1-git-send-email-yinghan@google.com> Sender: owner-linux-mm@kvack.org List-ID: To: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai Cc: linux-mm@kvack.org The patch changes each shrinkers API by consolidating the existing parameters into shrink_control struct. This will simplify any further features added w/o touching each file of shrinker. changelog v2..v1: 1. replace the scan_control to shrink_control, and only pass the set of values down to the shrinker. Signed-off-by: Ying Han --- arch/x86/kvm/mmu.c | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 5 ++--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 4 +++- drivers/staging/zcache/zcache.c | 5 ++++- fs/dcache.c | 8 ++++++-- fs/gfs2/glock.c | 5 ++++- fs/inode.c | 6 +++++- fs/mbcache.c | 10 ++++++---- fs/nfs/dir.c | 5 ++++- fs/nfs/internal.h | 2 +- fs/quota/dquot.c | 5 ++++- fs/xfs/linux-2.6/xfs_buf.c | 4 ++-- fs/xfs/linux-2.6/xfs_sync.c | 5 +++-- fs/xfs/quota/xfs_qm.c | 7 ++++--- include/linux/mm.h | 15 +++++++++------ mm/vmscan.c | 11 +++++++---- net/sunrpc/auth.c | 4 +++- 17 files changed, 69 insertions(+), 35 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index b6a9963..e194cb6 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3579,10 +3579,11 @@ static int kvm_mmu_remove_some_alloc_mmu_pages(struct kvm *kvm, return kvm_mmu_prepare_zap_page(kvm, page, invalid_list); } -static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask) +static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc) { struct kvm *kvm; struct kvm *kvm_freed = NULL; + int nr_to_scan = sc->nr_slab_to_reclaim; if (nr_to_scan == 0) goto out; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 4aaf6cd..99afb5b 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4105,9 +4105,7 @@ i915_gpu_is_active(struct drm_device *dev) } static int -i915_gem_inactive_shrink(struct shrinker *shrinker, - int nr_to_scan, - gfp_t gfp_mask) +i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc) { struct drm_i915_private *dev_priv = container_of(shrinker, @@ -4115,6 +4113,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, mm.inactive_shrinker); struct drm_device *dev = dev_priv->dev; struct drm_i915_gem_object *obj, *next; + int nr_to_scan = sc->nr_slab_to_reclaim; int cnt; if (!mutex_trylock(&dev->struct_mutex)) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 737a2a2..2f2376b 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -395,12 +395,14 @@ static int ttm_pool_get_num_unused_pages(void) /** * Callback for mm to request pool to reduce number of page held. */ -static int ttm_pool_mm_shrink(struct shrinker *shrink, int shrink_pages, gfp_t gfp_mask) +static int ttm_pool_mm_shrink(struct shrinker *shrink, + struct shrink_control *sc) { static atomic_t start_pool = ATOMIC_INIT(0); unsigned i; unsigned pool_offset = atomic_add_return(1, &start_pool); struct ttm_page_pool *pool; + int shrink_pages = sc->nr_slab_to_reclaim; pool_offset = pool_offset % NUM_POOLS; /* select start pool in round robin fashion */ diff --git a/drivers/staging/zcache/zcache.c b/drivers/staging/zcache/zcache.c index b8a2b30..135851a 100644 --- a/drivers/staging/zcache/zcache.c +++ b/drivers/staging/zcache/zcache.c @@ -1181,9 +1181,12 @@ static bool zcache_freeze; /* * zcache shrinker interface (only useful for ephemeral pages, so zbud only) */ -static int shrink_zcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask) +static int shrink_zcache_memory(struct shrinker *shrink, + struct shrink_control *sc) { int ret = -1; + int nr = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; if (nr >= 0) { if (!(gfp_mask & __GFP_FS)) diff --git a/fs/dcache.c b/fs/dcache.c index 2f65679..47566ab 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1237,7 +1237,7 @@ void shrink_dcache_parent(struct dentry * parent) EXPORT_SYMBOL(shrink_dcache_parent); /* - * Scan `nr' dentries and return the number which remain. + * Scan `sc->nr_slab_to_reclaim' dentries and return the number which remain. * * We need to avoid reentering the filesystem if the caller is performing a * GFP_NOFS allocation attempt. One example deadlock is: @@ -1248,8 +1248,12 @@ EXPORT_SYMBOL(shrink_dcache_parent); * * In this case we return -1 to tell the caller that we baled. */ -static int shrink_dcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask) +static int shrink_dcache_memory(struct shrinker *shrink, + struct shrink_control *sc) { + int nr = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; + if (nr) { if (!(gfp_mask & __GFP_FS)) return -1; diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index bc36aef..e196ece 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1348,11 +1348,14 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret) } -static int gfs2_shrink_glock_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask) +static int gfs2_shrink_glock_memory(struct shrinker *shrink, + struct shrink_control *sc) { struct gfs2_glock *gl; int may_demote; int nr_skipped = 0; + int nr = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; LIST_HEAD(skipped); if (nr == 0) diff --git a/fs/inode.c b/fs/inode.c index f4018ab..e65d00a 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -703,8 +703,12 @@ static void prune_icache(int nr_to_scan) * This function is passed the number of inodes to scan, and it returns the * total number of remaining possibly-reclaimable inodes. */ -static int shrink_icache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask) +static int shrink_icache_memory(struct shrinker *shrink, + struct shrink_control *sc) { + int nr = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; + if (nr) { /* * Nasty deadlock avoidance. We may hold various FS locks, diff --git a/fs/mbcache.c b/fs/mbcache.c index a25444ab..3ba68e4 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c @@ -90,7 +90,8 @@ static DEFINE_SPINLOCK(mb_cache_spinlock); * What the mbcache registers as to get shrunk dynamically. */ -static int mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask); +static int mb_cache_shrink_fn(struct shrinker *shrink, + struct shrink_control *sc); static struct shrinker mb_cache_shrinker = { .shrink = mb_cache_shrink_fn, @@ -156,18 +157,19 @@ forget: * gets low. * * @shrink: (ignored) - * @nr_to_scan: Number of objects to scan - * @gfp_mask: (ignored) + * @sc: shrink_control passed from reclaim * * Returns the number of objects which are present in the cache. */ static int -mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask) +mb_cache_shrink_fn(struct shrinker *shrink, struct shrink_control *sc) { LIST_HEAD(free_list); struct mb_cache *cache; struct mb_cache_entry *entry, *tmp; int count = 0; + int nr_to_scan = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; mb_debug("trying to free %d entries", nr_to_scan); spin_lock(&mb_cache_spinlock); diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 2c3eb33..27aa4a4 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1962,11 +1962,14 @@ static void nfs_access_free_list(struct list_head *head) } } -int nfs_access_cache_shrinker(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask) +int nfs_access_cache_shrinker(struct shrinker *shrink, + struct shrink_control *sc) { LIST_HEAD(head); struct nfs_inode *nfsi, *next; struct nfs_access_entry *cache; + int nr_to_scan = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) return (nr_to_scan == 0) ? 0 : -1; diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index cf9fdbd..fabb489 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -218,7 +218,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync); /* dir.c */ extern int nfs_access_cache_shrinker(struct shrinker *shrink, - int nr_to_scan, gfp_t gfp_mask); + struct shrink_control *sc); /* inode.c */ extern struct workqueue_struct *nfsiod_workqueue; diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index a2a622e..09d8750 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -696,8 +696,11 @@ static void prune_dqcache(int count) * This is called from kswapd when we think we need some * more memory */ -static int shrink_dqcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask) +static int shrink_dqcache_memory(struct shrinker *shrink, + struct shrink_control *sc) { + int nr = sc->nr_slab_to_reclaim; + if (nr) { spin_lock(&dq_list_lock); prune_dqcache(nr); diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 5cb230f..a1d6e62 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c @@ -1542,12 +1542,12 @@ restart: int xfs_buftarg_shrink( struct shrinker *shrink, - int nr_to_scan, - gfp_t mask) + struct shrink_control *sc) { struct xfs_buftarg *btp = container_of(shrink, struct xfs_buftarg, bt_shrinker); struct xfs_buf *bp; + int nr_to_scan = sc->nr_slab_to_reclaim; LIST_HEAD(dispose); if (!nr_to_scan) diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index 6c10f1d..6749bd3 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c @@ -998,13 +998,14 @@ xfs_reclaim_inodes( static int xfs_reclaim_inode_shrink( struct shrinker *shrink, - int nr_to_scan, - gfp_t gfp_mask) + struct shrink_control *sc) { struct xfs_mount *mp; struct xfs_perag *pag; xfs_agnumber_t ag; int reclaimable; + int nr_to_scan = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; mp = container_of(shrink, struct xfs_mount, m_inode_shrink); if (nr_to_scan) { diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 254ee06..8e7991c 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c @@ -60,7 +60,7 @@ STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); STATIC int xfs_qm_init_quotainos(xfs_mount_t *); STATIC int xfs_qm_init_quotainfo(xfs_mount_t *); -STATIC int xfs_qm_shake(struct shrinker *, int, gfp_t); +STATIC int xfs_qm_shake(struct shrinker *, struct shrink_control *); static struct shrinker xfs_qm_shaker = { .shrink = xfs_qm_shake, @@ -2016,10 +2016,11 @@ xfs_qm_shake_freelist( STATIC int xfs_qm_shake( struct shrinker *shrink, - int nr_to_scan, - gfp_t gfp_mask) + struct shrink_control *sc) { int ndqused, nfree, n; + int nr_to_scan = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; if (!kmem_shake_allow(gfp_mask)) return 0; diff --git a/include/linux/mm.h b/include/linux/mm.h index 7a2f657..abc13ea 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1137,16 +1137,19 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm) struct shrink_control { unsigned long nr_scanned; gfp_t gfp_mask; + + /* How many slab objects shrinker() should reclaim */ + unsigned long nr_slab_to_reclaim; }; /* * A callback you can register to apply pressure to ageable caches. * - * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should - * look through the least-recently-used 'nr_to_scan' entries and - * attempt to free them up. It should return the number of objects - * which remain in the cache. If it returns -1, it means it cannot do - * any scanning at this time (eg. there is a risk of deadlock). + * 'sc' is passed shrink_control which includes a count 'nr_slab_to_reclaim' + * and a 'gfpmask'. It should look through the least-recently-us + * 'nr_slab_to_reclaim' entries and attempt to free them up. It should return + * the number of objects which remain in the cache. If it returns -1, it means + * it cannot do any scanning at this time (eg. there is a risk of deadlock). * * The 'gfpmask' refers to the allocation we are currently trying to * fulfil. @@ -1155,7 +1158,7 @@ struct shrink_control { * querying the cache size, so a fastpath for that case is appropriate. */ struct shrinker { - int (*shrink)(struct shrinker *, int nr_to_scan, gfp_t gfp_mask); + int (*shrink)(struct shrinker *, struct shrink_control *sc); int seeks; /* seeks to recreate an obj */ /* These are for internal use */ diff --git a/mm/vmscan.c b/mm/vmscan.c index 40edf73..1241e87 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -239,7 +239,8 @@ unsigned long shrink_slab(struct shrink_control *shrink, unsigned long total_scan; unsigned long max_pass; - max_pass = (*shrinker->shrink)(shrinker, 0, gfp_mask); + shrink->nr_slab_to_reclaim = 0; + max_pass = (*shrinker->shrink)(shrinker, shrink); delta = (4 * scanned) / shrinker->seeks; delta *= max_pass; do_div(delta, lru_pages + 1); @@ -267,9 +268,11 @@ unsigned long shrink_slab(struct shrink_control *shrink, int shrink_ret; int nr_before; - nr_before = (*shrinker->shrink)(shrinker, 0, gfp_mask); - shrink_ret = (*shrinker->shrink)(shrinker, this_scan, - gfp_mask); + shrink->nr_slab_to_reclaim = 0; + nr_before = (*shrinker->shrink)(shrinker, shrink); + shrink->nr_slab_to_reclaim = this_scan; + shrink_ret = (*shrinker->shrink)(shrinker, shrink); + if (shrink_ret == -1) break; if (shrink_ret < nr_before) diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 67e3127..287dd25 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -326,10 +326,12 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) * Run memory cache shrinker. */ static int -rpcauth_cache_shrinker(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask) +rpcauth_cache_shrinker(struct shrinker *shrink, struct shrink_control *sc) { LIST_HEAD(free); int res; + int nr_to_scan = sc->nr_slab_to_reclaim; + gfp_t gfp_mask = sc->gfp_mask; if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) return (nr_to_scan == 0) ? 0 : -1; -- 1.7.3.1 -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with SMTP id 400BF8D003B for ; Mon, 25 Apr 2011 14:35:24 -0400 (EDT) Message-ID: <4DB5BEBC.2090007@redhat.com> Date: Mon, 25 Apr 2011 14:34:36 -0400 From: Rik van Riel MIME-Version: 1.0 Subject: Re: [PATCH V2 1/2] change the shrink_slab by passing shrink_control References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-2-git-send-email-yinghan@google.com> In-Reply-To: <1303752134-4856-2-git-send-email-yinghan@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org On 04/25/2011 01:22 PM, Ying Han wrote: > This patch consolidates existing parameters to shrink_slab() to > a new shrink_control struct. This is needed later to pass the same > struct to shrinkers. > > changelog v2..v1: > 1. define a new struct shrink_control and only pass some values down > to the shrinker instead of the scan_control. > > Signed-off-by: Ying Han Acked-by: Rik van Riel -- All rights reversed -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail202.messagelabs.com (mail202.messagelabs.com [216.82.254.227]) by kanga.kvack.org (Postfix) with SMTP id BD41C8D003B for ; Mon, 25 Apr 2011 14:35:32 -0400 (EDT) Message-ID: <4DB5BED1.7060407@redhat.com> Date: Mon, 25 Apr 2011 14:34:57 -0400 From: Rik van Riel MIME-Version: 1.0 Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-3-git-send-email-yinghan@google.com> In-Reply-To: <1303752134-4856-3-git-send-email-yinghan@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org On 04/25/2011 01:22 PM, Ying Han wrote: > The patch changes each shrinkers API by consolidating the existing > parameters into shrink_control struct. This will simplify any further > features added w/o touching each file of shrinker. > > changelog v2..v1: > 1. replace the scan_control to shrink_control, and only pass the set > of values down to the shrinker. > > Signed-off-by: Ying Han Acked-by: Rik van Riel -- All rights reversed -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail203.messagelabs.com (mail203.messagelabs.com [216.82.254.243]) by kanga.kvack.org (Postfix) with ESMTP id 611538D003B for ; Mon, 25 Apr 2011 14:50:26 -0400 (EDT) Message-ID: <4DB5C191.3090804@parallels.com> Date: Mon, 25 Apr 2011 22:46:41 +0400 From: Pavel Emelyanov MIME-Version: 1.0 Subject: Re: [PATCH V2 1/2] change the shrink_slab by passing shrink_control References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-2-git-send-email-yinghan@google.com> In-Reply-To: <1303752134-4856-2-git-send-email-yinghan@google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , "linux-mm@kvack.org" On 04/25/2011 09:22 PM, Ying Han wrote: > This patch consolidates existing parameters to shrink_slab() to > a new shrink_control struct. This is needed later to pass the same > struct to shrinkers. > > changelog v2..v1: > 1. define a new struct shrink_control and only pass some values down > to the shrinker instead of the scan_control. > > Signed-off-by: Ying Han Acked-by: Pavel Emelyanov -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id 7219B8D003B for ; Mon, 25 Apr 2011 14:50:45 -0400 (EDT) Message-ID: <4DB5C1B0.9050405@parallels.com> Date: Mon, 25 Apr 2011 22:47:12 +0400 From: Pavel Emelyanov MIME-Version: 1.0 Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-3-git-send-email-yinghan@google.com> In-Reply-To: <1303752134-4856-3-git-send-email-yinghan@google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , "linux-mm@kvack.org" On 04/25/2011 09:22 PM, Ying Han wrote: > The patch changes each shrinkers API by consolidating the existing > parameters into shrink_control struct. This will simplify any further > features added w/o touching each file of shrinker. > > changelog v2..v1: > 1. replace the scan_control to shrink_control, and only pass the set > of values down to the shrinker. > > Signed-off-by: Ying Han Acked-by: Pavel Emelyanov -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with ESMTP id D21038D003B for ; Mon, 25 Apr 2011 20:42:35 -0400 (EDT) Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 800363EE0AE for ; Tue, 26 Apr 2011 09:42:33 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 5AABF45DE4E for ; Tue, 26 Apr 2011 09:42:33 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 4014945DE53 for ; Tue, 26 Apr 2011 09:42:33 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 2998DE78002 for ; Tue, 26 Apr 2011 09:42:33 +0900 (JST) Received: from m107.s.css.fujitsu.com (m107.s.css.fujitsu.com [10.240.81.147]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id BB4951DB8045 for ; Tue, 26 Apr 2011 09:42:32 +0900 (JST) From: KOSAKI Motohiro Subject: Re: [PATCH V2 1/2] change the shrink_slab by passing shrink_control In-Reply-To: <1303752134-4856-2-git-send-email-yinghan@google.com> References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-2-git-send-email-yinghan@google.com> Message-Id: <20110426094356.F341.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Tue, 26 Apr 2011 09:42:31 +0900 (JST) Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: kosaki.motohiro@jp.fujitsu.com, Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org > This patch consolidates existing parameters to shrink_slab() to > a new shrink_control struct. This is needed later to pass the same > struct to shrinkers. > > changelog v2..v1: > 1. define a new struct shrink_control and only pass some values down > to the shrinker instead of the scan_control. > > Signed-off-by: Ying Han > --- > fs/drop_caches.c | 6 +++++- > include/linux/mm.h | 13 +++++++++++-- > mm/vmscan.c | 30 ++++++++++++++++++++++-------- > 3 files changed, 38 insertions(+), 11 deletions(-) Reviewed-by: KOSAKI Motohiro -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with ESMTP id A39618D003B for ; Mon, 25 Apr 2011 20:54:03 -0400 (EDT) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 2B7903EE0C2 for ; Tue, 26 Apr 2011 09:54:00 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id EE97645DE97 for ; Tue, 26 Apr 2011 09:53:59 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id D3C0E45DE92 for ; Tue, 26 Apr 2011 09:53:59 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id BE7FEE18007 for ; Tue, 26 Apr 2011 09:53:59 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.240.81.134]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 7E2721DB803E for ; Tue, 26 Apr 2011 09:53:59 +0900 (JST) From: KOSAKI Motohiro Subject: Re: [PATCH V2 1/2] change the shrink_slab by passing shrink_control In-Reply-To: <20110426094356.F341.A69D9226@jp.fujitsu.com> References: <1303752134-4856-2-git-send-email-yinghan@google.com> <20110426094356.F341.A69D9226@jp.fujitsu.com> Message-Id: <20110426095524.F348.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Date: Tue, 26 Apr 2011 09:53:58 +0900 (JST) Sender: owner-linux-mm@kvack.org List-ID: To: KOSAKI Motohiro Cc: Ying Han , Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org > > This patch consolidates existing parameters to shrink_slab() to > > a new shrink_control struct. This is needed later to pass the same > > struct to shrinkers. > >=20 > > changelog v2..v1: > > 1. define a new struct shrink_control and only pass some values down > > to the shrinker instead of the scan_control. > >=20 > > Signed-off-by: Ying Han > > --- > > fs/drop_caches.c | 6 +++++- > > include/linux/mm.h | 13 +++++++++++-- > > mm/vmscan.c | 30 ++++++++++++++++++++++-------- > > 3 files changed, 38 insertions(+), 11 deletions(-) >=20 > Reviewed-by: KOSAKI Motohiro Sigh. No. This patch seems premature. > This patch consolidates existing parameters to shrink_slab() to > a new shrink_control struct. This is needed later to pass the same > struct to shrinkers. >=20 > changelog v2..v1: > 1. define a new struct shrink_control and only pass some values down > to the shrinker instead of the scan_control. >=20 > Signed-off-by: Ying Han > --- > fs/drop_caches.c | 6 +++++- > include/linux/mm.h | 13 +++++++++++-- > mm/vmscan.c | 30 ++++++++++++++++++++++-------- > 3 files changed, 38 insertions(+), 11 deletions(-) >=20 > diff --git a/fs/drop_caches.c b/fs/drop_caches.c > index 816f88e..c671290 100644 > --- a/fs/drop_caches.c > +++ b/fs/drop_caches.c > @@ -36,9 +36,13 @@ static void drop_pagecache_sb(struct super_block *sb, = void *unused) > static void drop_slab(void) > { > int nr_objects; > + struct shrink_control shrink =3D { > + .gfp_mask =3D GFP_KERNEL, > + .nr_scanned =3D 1000, > + }; > =20 > do { > - nr_objects =3D shrink_slab(1000, GFP_KERNEL, 1000); > + nr_objects =3D shrink_slab(&shrink, 1000); > } while (nr_objects > 10); > } > =20 > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 0716517..7a2f657 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1131,6 +1131,15 @@ static inline void sync_mm_rss(struct task_struct = *task, struct mm_struct *mm) > #endif > =20 > /* > + * This struct is used to pass information from page reclaim to the shri= nkers. > + * We consolidate the values for easier extention later. > + */ > +struct shrink_control { > + unsigned long nr_scanned; nr_to_scan is better. sc.nr_scanned mean how much _finished_ scan pages. eg. scan_control { (snip) /* Number of pages freed so far during a call to shrink_zones() */ unsigned long nr_reclaimed; /* How many pages shrink_list() should reclaim */ unsigned long nr_to_reclaim; > + gfp_t gfp_mask; > +}; > + > +/* > * A callback you can register to apply pressure to ageable caches. > * > * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should > @@ -1601,8 +1610,8 @@ int in_gate_area_no_task(unsigned long addr); > =20 > int drop_caches_sysctl_handler(struct ctl_table *, int, > void __user *, size_t *, loff_t *); > -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, > - unsigned long lru_pages); > +unsigned long shrink_slab(struct shrink_control *shrink, > + unsigned long lru_pages); > =20 > #ifndef CONFIG_MMU > #define randomize_va_space 0 > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 060e4c1..40edf73 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -220,11 +220,13 @@ EXPORT_SYMBOL(unregister_shrinker); > * > * Returns the number of slab objects which we shrunk. > */ > -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, > - unsigned long lru_pages) > +unsigned long shrink_slab(struct shrink_control *shrink, > + unsigned long lru_pages) > { > struct shrinker *shrinker; > unsigned long ret =3D 0; > + unsigned long scanned =3D shrink->nr_scanned; > + gfp_t gfp_mask =3D shrink->gfp_mask; > =20 > if (scanned =3D=3D 0) > scanned =3D SWAP_CLUSTER_MAX; > @@ -2032,7 +2034,8 @@ static bool all_unreclaimable(struct zonelist *zone= list, > * else, the number of pages reclaimed > */ > static unsigned long do_try_to_free_pages(struct zonelist *zonelist, > - struct scan_control *sc) > + struct scan_control *sc, > + struct shrink_control *shrink) > { Worthless argument addition. gfpmask can be getting from scan_control and =2Enr_scanned is calculated in this function. > int priority; > unsigned long total_scanned =3D 0; > @@ -2066,7 +2069,8 @@ static unsigned long do_try_to_free_pages(struct zo= nelist *zonelist, > lru_pages +=3D zone_reclaimable_pages(zone); > } > =20 > - shrink_slab(sc->nr_scanned, sc->gfp_mask, lru_pages); > + shrink->nr_scanned =3D sc->nr_scanned; > + shrink_slab(shrink, lru_pages); > if (reclaim_state) { > sc->nr_reclaimed +=3D reclaim_state->reclaimed_slab; > reclaim_state->reclaimed_slab =3D 0; > @@ -2130,12 +2134,15 @@ unsigned long try_to_free_pages(struct zonelist *= zonelist, int order, > .mem_cgroup =3D NULL, > .nodemask =3D nodemask, > }; > + struct shrink_control shrink =3D { > + .gfp_mask =3D sc.gfp_mask, > + }; > =20 > trace_mm_vmscan_direct_reclaim_begin(order, > sc.may_writepage, > gfp_mask); > =20 > - nr_reclaimed =3D do_try_to_free_pages(zonelist, &sc); > + nr_reclaimed =3D do_try_to_free_pages(zonelist, &sc, &shrink); > =20 > trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); > =20 > @@ -2333,6 +2340,9 @@ static unsigned long balance_pgdat(pg_data_t *pgdat= , int order, > .order =3D order, > .mem_cgroup =3D NULL, > }; > + struct shrink_control shrink =3D { > + .gfp_mask =3D sc.gfp_mask, > + }; > loop_again: > total_scanned =3D 0; > sc.nr_reclaimed =3D 0; > @@ -2432,8 +2442,8 @@ loop_again: > end_zone, 0)) > shrink_zone(priority, zone, &sc); > reclaim_state->reclaimed_slab =3D 0; > - nr_slab =3D shrink_slab(sc.nr_scanned, GFP_KERNEL, > - lru_pages); > + shrink.nr_scanned =3D sc.nr_scanned; > + nr_slab =3D shrink_slab(&shrink, lru_pages); > sc.nr_reclaimed +=3D reclaim_state->reclaimed_slab; > total_scanned +=3D sc.nr_scanned; > =20 > @@ -2969,6 +2979,9 @@ static int __zone_reclaim(struct zone *zone, gfp_t = gfp_mask, unsigned int order) > .swappiness =3D vm_swappiness, > .order =3D order, > }; > + struct shrink_control shrink =3D { > + .gfp_mask =3D sc.gfp_mask, > + }; > unsigned long nr_slab_pages0, nr_slab_pages1; > =20 > cond_resched(); > @@ -2995,6 +3008,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t = gfp_mask, unsigned int order) > } > =20 > nr_slab_pages0 =3D zone_page_state(zone, NR_SLAB_RECLAIMABLE); > + shrink.nr_scanned =3D sc.nr_scanned; > if (nr_slab_pages0 > zone->min_slab_pages) { strange. this assignment should be move into this if brace. > /* > * shrink_slab() does not currently allow us to determine how > @@ -3010,7 +3024,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t = gfp_mask, unsigned int order) > unsigned long lru_pages =3D zone_reclaimable_pages(zone); > =20 > /* No reclaimable slab or very low memory pressure */ > - if (!shrink_slab(sc.nr_scanned, gfp_mask, lru_pages)) > + if (!shrink_slab(&shrink, lru_pages)) > break; > =20 > /* Freed enough memory */ > --=20 > 1.7.3.1 >=20 > -- > 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/ . > Fight unfair telecom internet charges in Canada: sign http://stopthemeter.= ca/ > Don't email: email@kvack.org -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with ESMTP id EB9108D003B for ; Mon, 25 Apr 2011 21:15:06 -0400 (EDT) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id C68123EE0C0 for ; Tue, 26 Apr 2011 10:15:03 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id AC08445DE76 for ; Tue, 26 Apr 2011 10:15:03 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 85A7745DE92 for ; Tue, 26 Apr 2011 10:15:03 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 77516E08003 for ; Tue, 26 Apr 2011 10:15:03 +0900 (JST) Received: from m106.s.css.fujitsu.com (m106.s.css.fujitsu.com [10.240.81.146]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 3F7E1E08005 for ; Tue, 26 Apr 2011 10:15:03 +0900 (JST) From: KOSAKI Motohiro Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct In-Reply-To: <1303752134-4856-3-git-send-email-yinghan@google.com> References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-3-git-send-email-yinghan@google.com> Message-Id: <20110426101631.F34C.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Tue, 26 Apr 2011 10:15:02 +0900 (JST) Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: kosaki.motohiro@jp.fujitsu.com, Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 7a2f657..abc13ea 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1137,16 +1137,19 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm) > struct shrink_control { > unsigned long nr_scanned; > gfp_t gfp_mask; > + > + /* How many slab objects shrinker() should reclaim */ > + unsigned long nr_slab_to_reclaim; Wrong name. The original shrinker API is int (*shrink)(struct shrinker *, int nr_to_scan, gfp_t gfp_mask); ie, shrinker get scanning target. not reclaiming target. You should have think folloing diff hunk is strange. > { > struct xfs_mount *mp; > struct xfs_perag *pag; > xfs_agnumber_t ag; > int reclaimable; > + int nr_to_scan = sc->nr_slab_to_reclaim; > + gfp_t gfp_mask = sc->gfp_mask; And, this very near meaning field .nr_scanned and .nr_slab_to_reclaim poped up new question. Why don't we pass more clever slab shrinker target? Why do we need pass similar two argument? > /* > * A callback you can register to apply pressure to ageable caches. > * > - * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should > - * look through the least-recently-used 'nr_to_scan' entries and > - * attempt to free them up. It should return the number of objects > - * which remain in the cache. If it returns -1, it means it cannot do > - * any scanning at this time (eg. there is a risk of deadlock). > + * 'sc' is passed shrink_control which includes a count 'nr_slab_to_reclaim' > + * and a 'gfpmask'. It should look through the least-recently-us us? > + * 'nr_slab_to_reclaim' entries and attempt to free them up. It should return > + * the number of objects which remain in the cache. If it returns -1, it means > + * it cannot do any scanning at this time (eg. there is a risk of deadlock). > * -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id 0700B9000C1 for ; Tue, 26 Apr 2011 20:03:31 -0400 (EDT) Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id p3R03Sth014507 for ; Tue, 26 Apr 2011 17:03:28 -0700 Received: from qyk2 (qyk2.prod.google.com [10.241.83.130]) by wpaz17.hot.corp.google.com with ESMTP id p3R02xhh015806 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 26 Apr 2011 17:03:27 -0700 Received: by qyk2 with SMTP id 2so725337qyk.16 for ; Tue, 26 Apr 2011 17:03:27 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110426095524.F348.A69D9226@jp.fujitsu.com> References: <1303752134-4856-2-git-send-email-yinghan@google.com> <20110426094356.F341.A69D9226@jp.fujitsu.com> <20110426095524.F348.A69D9226@jp.fujitsu.com> Date: Tue, 26 Apr 2011 17:03:26 -0700 Message-ID: Subject: Re: [PATCH V2 1/2] change the shrink_slab by passing shrink_control From: Ying Han Content-Type: multipart/alternative; boundary=0016e64aefda85f0d104a1db2b3c Sender: owner-linux-mm@kvack.org List-ID: To: KOSAKI Motohiro Cc: Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org --0016e64aefda85f0d104a1db2b3c Content-Type: text/plain; charset=ISO-8859-1 On Mon, Apr 25, 2011 at 5:53 PM, KOSAKI Motohiro < kosaki.motohiro@jp.fujitsu.com> wrote: > > > This patch consolidates existing parameters to shrink_slab() to > > > a new shrink_control struct. This is needed later to pass the same > > > struct to shrinkers. > > > > > > changelog v2..v1: > > > 1. define a new struct shrink_control and only pass some values down > > > to the shrinker instead of the scan_control. > > > > > > Signed-off-by: Ying Han > > > --- > > > fs/drop_caches.c | 6 +++++- > > > include/linux/mm.h | 13 +++++++++++-- > > > mm/vmscan.c | 30 ++++++++++++++++++++++-------- > > > 3 files changed, 38 insertions(+), 11 deletions(-) > > > > Reviewed-by: KOSAKI Motohiro > > Sigh. No. This patch seems premature. > > > > This patch consolidates existing parameters to shrink_slab() to > > a new shrink_control struct. This is needed later to pass the same > > struct to shrinkers. > > > > changelog v2..v1: > > 1. define a new struct shrink_control and only pass some values down > > to the shrinker instead of the scan_control. > > > > Signed-off-by: Ying Han > > --- > > fs/drop_caches.c | 6 +++++- > > include/linux/mm.h | 13 +++++++++++-- > > mm/vmscan.c | 30 ++++++++++++++++++++++-------- > > 3 files changed, 38 insertions(+), 11 deletions(-) > > > > diff --git a/fs/drop_caches.c b/fs/drop_caches.c > > index 816f88e..c671290 100644 > > --- a/fs/drop_caches.c > > +++ b/fs/drop_caches.c > > @@ -36,9 +36,13 @@ static void drop_pagecache_sb(struct super_block *sb, > void *unused) > > static void drop_slab(void) > > { > > int nr_objects; > > + struct shrink_control shrink = { > > + .gfp_mask = GFP_KERNEL, > > + .nr_scanned = 1000, > > + }; > > > > do { > > - nr_objects = shrink_slab(1000, GFP_KERNEL, 1000); > > + nr_objects = shrink_slab(&shrink, 1000); > > } while (nr_objects > 10); > > } > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 0716517..7a2f657 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1131,6 +1131,15 @@ static inline void sync_mm_rss(struct task_struct > *task, struct mm_struct *mm) > > #endif > > > > /* > > + * This struct is used to pass information from page reclaim to the > shrinkers. > > + * We consolidate the values for easier extention later. > > + */ > > +struct shrink_control { > > + unsigned long nr_scanned; > > nr_to_scan is better. sc.nr_scanned mean how much _finished_ scan pages. > Ok, the name is changed. > eg. > scan_control { > (snip) > /* Number of pages freed so far during a call to > shrink_zones() */ > unsigned long nr_reclaimed; > > /* How many pages shrink_list() should reclaim */ > unsigned long nr_to_reclaim; > > > > > + gfp_t gfp_mask; > > +}; > > + > > +/* > > * A callback you can register to apply pressure to ageable caches. > > * > > * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should > > @@ -1601,8 +1610,8 @@ int in_gate_area_no_task(unsigned long addr); > > > > int drop_caches_sysctl_handler(struct ctl_table *, int, > > void __user *, size_t *, loff_t *); > > -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, > > - unsigned long lru_pages); > > +unsigned long shrink_slab(struct shrink_control *shrink, > > + unsigned long lru_pages); > > > > #ifndef CONFIG_MMU > > #define randomize_va_space 0 > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 060e4c1..40edf73 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -220,11 +220,13 @@ EXPORT_SYMBOL(unregister_shrinker); > > * > > * Returns the number of slab objects which we shrunk. > > */ > > -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, > > - unsigned long lru_pages) > > +unsigned long shrink_slab(struct shrink_control *shrink, > > + unsigned long lru_pages) > > { > > struct shrinker *shrinker; > > unsigned long ret = 0; > > + unsigned long scanned = shrink->nr_scanned; > > + gfp_t gfp_mask = shrink->gfp_mask; > > > > if (scanned == 0) > > scanned = SWAP_CLUSTER_MAX; > > @@ -2032,7 +2034,8 @@ static bool all_unreclaimable(struct zonelist > *zonelist, > > * else, the number of pages reclaimed > > */ > > static unsigned long do_try_to_free_pages(struct zonelist *zonelist, > > - struct scan_control *sc) > > + struct scan_control *sc, > > + struct shrink_control *shrink) > > { > > Worthless argument addition. gfpmask can be getting from scan_control and > .nr_scanned is calculated in this function. > changed. > > > > > int priority; > > unsigned long total_scanned = 0; > > @@ -2066,7 +2069,8 @@ static unsigned long do_try_to_free_pages(struct > zonelist *zonelist, > > lru_pages += zone_reclaimable_pages(zone); > > } > > > > - shrink_slab(sc->nr_scanned, sc->gfp_mask, > lru_pages); > > + shrink->nr_scanned = sc->nr_scanned; > > + shrink_slab(shrink, lru_pages); > > if (reclaim_state) { > > sc->nr_reclaimed += > reclaim_state->reclaimed_slab; > > reclaim_state->reclaimed_slab = 0; > > @@ -2130,12 +2134,15 @@ unsigned long try_to_free_pages(struct zonelist > *zonelist, int order, > > .mem_cgroup = NULL, > > .nodemask = nodemask, > > }; > > + struct shrink_control shrink = { > > + .gfp_mask = sc.gfp_mask, > > + }; > > > > trace_mm_vmscan_direct_reclaim_begin(order, > > sc.may_writepage, > > gfp_mask); > > > > - nr_reclaimed = do_try_to_free_pages(zonelist, &sc); > > + nr_reclaimed = do_try_to_free_pages(zonelist, &sc, &shrink); > > > > trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); > > > > @@ -2333,6 +2340,9 @@ static unsigned long balance_pgdat(pg_data_t > *pgdat, int order, > > .order = order, > > .mem_cgroup = NULL, > > }; > > + struct shrink_control shrink = { > > + .gfp_mask = sc.gfp_mask, > > + }; > > loop_again: > > total_scanned = 0; > > sc.nr_reclaimed = 0; > > @@ -2432,8 +2442,8 @@ loop_again: > > end_zone, 0)) > > shrink_zone(priority, zone, &sc); > > reclaim_state->reclaimed_slab = 0; > > - nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL, > > - lru_pages); > > + shrink.nr_scanned = sc.nr_scanned; > > + nr_slab = shrink_slab(&shrink, lru_pages); > > sc.nr_reclaimed += reclaim_state->reclaimed_slab; > > total_scanned += sc.nr_scanned; > > > > @@ -2969,6 +2979,9 @@ static int __zone_reclaim(struct zone *zone, gfp_t > gfp_mask, unsigned int order) > > .swappiness = vm_swappiness, > > .order = order, > > }; > > + struct shrink_control shrink = { > > + .gfp_mask = sc.gfp_mask, > > + }; > > unsigned long nr_slab_pages0, nr_slab_pages1; > > > > cond_resched(); > > @@ -2995,6 +3008,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t > gfp_mask, unsigned int order) > > } > > > > nr_slab_pages0 = zone_page_state(zone, NR_SLAB_RECLAIMABLE); > > + shrink.nr_scanned = sc.nr_scanned; > > if (nr_slab_pages0 > zone->min_slab_pages) { > > strange. this assignment should be move into this if brace. > changed. > > > /* > > * shrink_slab() does not currently allow us to determine > how > > @@ -3010,7 +3024,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t > gfp_mask, unsigned int order) > > unsigned long lru_pages = > zone_reclaimable_pages(zone); > > > > /* No reclaimable slab or very low memory pressure > */ > > - if (!shrink_slab(sc.nr_scanned, gfp_mask, > lru_pages)) > > + if (!shrink_slab(&shrink, lru_pages)) > > break; > > > > /* Freed enough memory */ > > -- > > 1.7.3.1 > > > > -- > > 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/ . > > Fight unfair telecom internet charges in Canada: sign > http://stopthemeter.ca/ > > Don't email: email@kvack.org > > > --0016e64aefda85f0d104a1db2b3c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Mon, Apr 25, 2011 at 5:53 PM, KOSAKI = Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> > This patch consolidates existin= g parameters to shrink_slab() to
> > a new shrink_control struct. This is needed later to pass the sam= e
> > struct to shrinkers.
> >
> > changelog v2..v1:
> > 1. define a new struct shrink_control and only pass some values d= own
> > to the shrinker instead of the scan_control.
> >
> > Signed-off-by: Ying Han <yinghan@google.com>
> > ---
> > =A0fs/drop_caches.c =A0 | =A0 =A06 +++++-
> > =A0include/linux/mm.h | =A0 13 +++++++++++--
> > =A0mm/vmscan.c =A0 =A0 =A0 =A0| =A0 30 ++++++++++++++++++++++----= ----
> > =A03 files changed, 38 insertions(+), 11 deletions(-)
>
> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>

Sigh. No. This patch seems premature.


> This patch consolidates existing parameters to shrink_slab() to
> a new shrink_control struct. This is needed later to pass the same
> struct to shrinkers.
>
> changelog v2..v1:
> 1. define a new struct shrink_control and only pass some values down > to the shrinker instead of the scan_control.
>
> Signed-off-by: Ying Han <ying= han@google.com>
> ---
> =A0fs/drop_caches.c =A0 | =A0 =A06 +++++-
> =A0include/linux/mm.h | =A0 13 +++++++++++--
> =A0mm/vmscan.c =A0 =A0 =A0 =A0| =A0 30 ++++++++++++++++++++++--------<= br> > =A03 files changed, 38 insertions(+), 11 deletions(-)
>
> diff --git a/fs/drop_caches.c b/fs/drop_caches.c
> index 816f88e..c671290 100644
> --- a/fs/drop_caches.c
> +++ b/fs/drop_caches.c
> @@ -36,9 +36,13 @@ static void drop_pagecache_sb(struct super_block *s= b, void *unused)
> =A0static void drop_slab(void)
> =A0{
> =A0 =A0 =A0 int nr_objects;
> + =A0 =A0 struct shrink_control shrink =3D {
> + =A0 =A0 =A0 =A0 =A0 =A0 .gfp_mask =3D GFP_KERNEL,
> + =A0 =A0 =A0 =A0 =A0 =A0 .nr_scanned =3D 1000,
> + =A0 =A0 };
>
> =A0 =A0 =A0 do {
> - =A0 =A0 =A0 =A0 =A0 =A0 nr_objects =3D shrink_slab(1000, GFP_KERNEL,= 1000);
> + =A0 =A0 =A0 =A0 =A0 =A0 nr_objects =3D shrink_slab(&shrink, 1000= );
> =A0 =A0 =A0 } while (nr_objects > 10);
> =A0}
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 0716517..7a2f657 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1131,6 +1131,15 @@ static inline void sync_mm_rss(struct task_stru= ct *task, struct mm_struct *mm)
> =A0#endif
>
> =A0/*
> + * This struct is used to pass information from page reclaim to the s= hrinkers.
> + * We consolidate the values for easier extention later.
> + */
> +struct shrink_control {
> + =A0 =A0 unsigned long nr_scanned;

nr_to_scan is better. sc.nr_scanned mean how much _finished_ scan pages.

Ok, the name is changed.
=A0
eg.
=A0 =A0 =A0 =A0scan_control {
=A0 =A0 =A0 =A0(snip)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Number of pages freed so far during a ca= ll to shrink_zones() */
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned long nr_reclaimed;

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* How many pages shrink_list() should recl= aim */
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned long nr_to_reclaim;



> + =A0 =A0 gfp_t gfp_mask;
> +};
> +
> +/*
> =A0 * A callback you can register to apply pressure to ageable caches.=
> =A0 *
> =A0 * 'shrink' is passed a count 'nr_to_scan' and a &#= 39;gfpmask'. =A0It should
> @@ -1601,8 +1610,8 @@ int in_gate_area_no_task(unsigned long addr); >
> =A0int drop_caches_sysctl_handler(struct ctl_table *, int,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 void __user *, size_t *, loff_t *);
> -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long lru_pages); > +unsigned long shrink_slab(struct shrink_control *shrink,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned lon= g lru_pages);
>
> =A0#ifndef CONFIG_MMU
> =A0#define randomize_va_space 0
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 060e4c1..40edf73 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -220,11 +220,13 @@ EXPORT_SYMBOL(unregister_shrinker);
> =A0 *
> =A0 * Returns the number of slab objects which we shrunk.
> =A0 */
> -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long lru_pages)
> +unsigned long shrink_slab(struct shrink_control *shrink,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long lru_pages)=
> =A0{
> =A0 =A0 =A0 struct shrinker *shrinker;
> =A0 =A0 =A0 unsigned long ret =3D 0;
> + =A0 =A0 unsigned long scanned =3D shrink->nr_scanned;
> + =A0 =A0 gfp_t gfp_mask =3D shrink->gfp_mask;
>
> =A0 =A0 =A0 if (scanned =3D=3D 0)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 scanned =3D SWAP_CLUSTER_MAX;
> @@ -2032,7 +2034,8 @@ static bool all_unreclaimable(struct zonelist *z= onelist,
> =A0 * =A0 =A0 =A0 =A0 =A0 else, the number of pages reclaimed
> =A0 */
> =A0static unsigned long do_try_to_free_pages(struct zonelist *zonelist= ,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 struct scan_control *sc)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 struct scan_control *sc,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 struct shrink_control *shrink)
> =A0{

Worthless argument addition. gfpmask can be getting from scan_control and .nr_scanned is calculated in this function.

=
changed.=A0



> =A0 =A0 =A0 int priority;
> =A0 =A0 =A0 unsigned long total_scanned =3D 0;
> @@ -2066,7 +2069,8 @@ static unsigned long do_try_to_free_pages(struct= zonelist *zonelist,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 lru_pages = +=3D zone_reclaimable_pages(zone);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink_slab(sc->nr_scanne= d, sc->gfp_mask, lru_pages);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink->nr_scanned =3D sc= ->nr_scanned;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink_slab(shrink, lru_page= s);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (reclaim_state) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc->nr_= reclaimed +=3D reclaim_state->reclaimed_slab;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reclaim_st= ate->reclaimed_slab =3D 0;
> @@ -2130,12 +2134,15 @@ unsigned long try_to_free_pages(struct zonelis= t *zonelist, int order,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .mem_cgroup =3D NULL,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .nodemask =3D nodemask,
> =A0 =A0 =A0 };
> + =A0 =A0 struct shrink_control shrink =3D {
> + =A0 =A0 =A0 =A0 =A0 =A0 .gfp_mask =3D sc.gfp_mask,
> + =A0 =A0 };
>
> =A0 =A0 =A0 trace_mm_vmscan_direct_reclaim_begin(order,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc.may_wri= tepage,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gfp_mask);=
>
> - =A0 =A0 nr_reclaimed =3D do_try_to_free_pages(zonelist, &sc); > + =A0 =A0 nr_reclaimed =3D do_try_to_free_pages(zonelist, &sc, &am= p;shrink);
>
> =A0 =A0 =A0 trace_mm_vmscan_direct_reclaim_end(nr_reclaimed);
>
> @@ -2333,6 +2340,9 @@ static unsigned long balance_pgdat(pg_data_t *pg= dat, int order,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .order =3D order,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .mem_cgroup =3D NULL,
> =A0 =A0 =A0 };
> + =A0 =A0 struct shrink_control shrink =3D {
> + =A0 =A0 =A0 =A0 =A0 =A0 .gfp_mask =3D sc.gfp_mask,
> + =A0 =A0 };
> =A0loop_again:
> =A0 =A0 =A0 total_scanned =3D 0;
> =A0 =A0 =A0 sc.nr_reclaimed =3D 0;
> @@ -2432,8 +2442,8 @@ loop_again:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 end_zone, 0))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink_zon= e(priority, zone, &sc);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reclaim_state->reclaime= d_slab =3D 0;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_slab =3D shrink_slab(sc.n= r_scanned, GFP_KERNEL,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 lru_pages);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink.nr_scanned =3D sc.nr_= scanned;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_slab =3D shrink_slab(&= ;shrink, lru_pages);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc.nr_reclaimed +=3D recla= im_state->reclaimed_slab;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 total_scanned +=3D sc.nr_s= canned;
>
> @@ -2969,6 +2979,9 @@ static int __zone_reclaim(struct zone *zone, gfp= _t gfp_mask, unsigned int order)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .swappiness =3D vm_swappiness,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .order =3D order,
> =A0 =A0 =A0 };
> + =A0 =A0 struct shrink_control shrink =3D {
> + =A0 =A0 =A0 =A0 =A0 =A0 .gfp_mask =3D sc.gfp_mask,
> + =A0 =A0 };
> =A0 =A0 =A0 unsigned long nr_slab_pages0, nr_slab_pages1;
>
> =A0 =A0 =A0 cond_resched();
> @@ -2995,6 +3008,7 @@ static int __zone_reclaim(struct zone *zone, gfp= _t gfp_mask, unsigned int order)
> =A0 =A0 =A0 }
>
> =A0 =A0 =A0 nr_slab_pages0 =3D zone_page_state(zone, NR_SLAB_RECLAIMAB= LE);
> + =A0 =A0 shrink.nr_scanned =3D sc.nr_scanned;
> =A0 =A0 =A0 if (nr_slab_pages0 > zone->min_slab_pages) {

strange. this assignment should be move into this if brace.
changed.

> =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* shrink_slab() does not currently allo= w us to determine how
> @@ -3010,7 +3024,7 @@ static int __zone_reclaim(struct zone *zone, gfp= _t gfp_mask, unsigned int order)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long lru_pages = =3D zone_reclaimable_pages(zone);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* No reclaimable slab or = very low memory pressure */
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!shrink_slab(sc.nr_scann= ed, gfp_mask, lru_pages))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!shrink_slab(&shrink= , lru_pages))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Freed enough memory */<= br> > --
> 1.7.3.1
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in<= br> > the body to majordomo@kvack.org= . =A0For more info on Linux MM,
> see: http://www= .linux-mm.org/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=3Dmailto:"dont@kvack.org"> emai= l@kvack.org </a>



--0016e64aefda85f0d104a1db2b3c-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail190.messagelabs.com (mail190.messagelabs.com [216.82.249.51]) by kanga.kvack.org (Postfix) with ESMTP id BC3159000C1 for ; Tue, 26 Apr 2011 20:21:11 -0400 (EDT) Received: from kpbe19.cbf.corp.google.com (kpbe19.cbf.corp.google.com [172.25.105.83]) by smtp-out.google.com with ESMTP id p3R0L33F021726 for ; Tue, 26 Apr 2011 17:21:03 -0700 Received: from qyj19 (qyj19.prod.google.com [10.241.83.83]) by kpbe19.cbf.corp.google.com with ESMTP id p3R0KZiE029633 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 26 Apr 2011 17:21:01 -0700 Received: by qyj19 with SMTP id 19so1724194qyj.2 for ; Tue, 26 Apr 2011 17:21:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110426101631.F34C.A69D9226@jp.fujitsu.com> References: <1303752134-4856-1-git-send-email-yinghan@google.com> <1303752134-4856-3-git-send-email-yinghan@google.com> <20110426101631.F34C.A69D9226@jp.fujitsu.com> Date: Tue, 26 Apr 2011 17:21:00 -0700 Message-ID: Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct From: Ying Han Content-Type: multipart/alternative; boundary=0016e64aefda4e32e904a1db6af2 Sender: owner-linux-mm@kvack.org List-ID: To: KOSAKI Motohiro Cc: Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org --0016e64aefda4e32e904a1db6af2 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Apr 25, 2011 at 6:15 PM, KOSAKI Motohiro < kosaki.motohiro@jp.fujitsu.com> wrote: > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 7a2f657..abc13ea 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1137,16 +1137,19 @@ static inline void sync_mm_rss(struct task_struct > *task, struct mm_struct *mm) > > struct shrink_control { > > unsigned long nr_scanned; > > gfp_t gfp_mask; > > + > > + /* How many slab objects shrinker() should reclaim */ > > + unsigned long nr_slab_to_reclaim; > > Wrong name. The original shrinker API is > int (*shrink)(struct shrinker *, int nr_to_scan, gfp_t gfp_mask); > > ie, shrinker get scanning target. not reclaiming target. > You should have think folloing diff hunk is strange. > Ok, changed to "nr_slab_to_shrink" > > > { > > struct xfs_mount *mp; > > struct xfs_perag *pag; > > xfs_agnumber_t ag; > > int reclaimable; > > + int nr_to_scan = sc->nr_slab_to_reclaim; > > + gfp_t gfp_mask = sc->gfp_mask; > > And, this very near meaning field .nr_scanned and .nr_slab_to_reclaim > poped up new question. > Why don't we pass more clever slab shrinker target? Why do we need pass > similar two argument? > I renamed the nr_slab_to_reclaim and nr_scanned in shrink struct. --Ying > > /* > > * A callback you can register to apply pressure to ageable caches. > > * > > - * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should > > - * look through the least-recently-used 'nr_to_scan' entries and > > - * attempt to free them up. It should return the number of objects > > - * which remain in the cache. If it returns -1, it means it cannot do > > - * any scanning at this time (eg. there is a risk of deadlock). > > + * 'sc' is passed shrink_control which includes a count > 'nr_slab_to_reclaim' > > + * and a 'gfpmask'. It should look through the least-recently-us > > us? > > > > + * 'nr_slab_to_reclaim' entries and attempt to free them up. It should > return > > + * the number of objects which remain in the cache. If it returns -1, > it means > > + * it cannot do any scanning at this time (eg. there is a risk of > deadlock). > > * > > > > > --0016e64aefda4e32e904a1db6af2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Mon, Apr 25, 2011 at 6:15 PM, KOSAKI = Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 7a2f657..abc13ea 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1137,16 +1137,19 @@ static inline void sync_mm_rss(struct task_str= uct *task, struct mm_struct *mm)
> =A0struct shrink_control {
> =A0 =A0 =A0 unsigned long nr_scanned;
> =A0 =A0 =A0 gfp_t gfp_mask;
> +
> + =A0 =A0 /* How many slab objects shrinker() should reclaim */
> + =A0 =A0 unsigned long nr_slab_to_reclaim;

Wrong name. The original shrinker API is
=A0 =A0 =A0 =A0int (*shrink)(struct shrinker *, int nr_to_scan, gfp_t gfp_= mask);

ie, shrinker get scanning target. not reclaiming target.
You should have think folloing diff hunk is strange.
<= br>
Ok, changed to "nr_slab_to_shrink"=A0

> =A0{
> =A0 =A0 =A0 struct xfs_mount *mp;
> =A0 =A0 =A0 struct xfs_perag *pag;
> =A0 =A0 =A0 xfs_agnumber_t =A0ag;
> =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 reclaimable;
> + =A0 =A0 int nr_to_scan =3D sc->nr_slab_to_reclaim;
> + =A0 =A0 gfp_t gfp_mask =3D sc->gfp_mask;

And, this very near meaning field .nr_scanned and .nr_slab_to_reclaim
poped up new question.
Why don't we pass more clever slab shrinker target? Why do we need pass=
similar two argument?

I renamed the nr_= slab_to_reclaim and nr_scanned in shrink struct. =A0

--Ying
> =A0/*
> =A0 * A callback you can register to apply pressure to ageable caches.=
> =A0 *
> - * 'shrink' is passed a count 'nr_to_scan' and a '= ;gfpmask'. =A0It should
> - * look through the least-recently-used 'nr_to_scan' entries = and
> - * attempt to free them up. =A0It should return the number of objects=
> - * which remain in the cache. =A0If it returns -1, it means it cannot= do
> - * any scanning at this time (eg. there is a risk of deadlock).
> + * 'sc' is passed shrink_control which includes a count '= nr_slab_to_reclaim'
> + * and a 'gfpmask'. =A0It should look through the least-recen= tly-us

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0us?


> + * 'nr_slab_to_reclaim' entries and attempt to free them up. = =A0It should return
> + * the number of objects which remain in the cache. =A0If it returns = -1, it means
> + * it cannot do any scanning at this time (eg. there is a risk of dea= dlock).
> =A0 *





--0016e64aefda4e32e904a1db6af2-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id C995A9000C1 for ; Tue, 26 Apr 2011 20:47:53 -0400 (EDT) Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id E67D83EE0BC for ; Wed, 27 Apr 2011 09:47:50 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id C486C45DEA3 for ; Wed, 27 Apr 2011 09:47:50 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id AC23F45DEA0 for ; Wed, 27 Apr 2011 09:47:50 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 9BAFDE08002 for ; Wed, 27 Apr 2011 09:47:50 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.240.81.134]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 656181DB803A for ; Wed, 27 Apr 2011 09:47:50 +0900 (JST) From: KOSAKI Motohiro Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct In-Reply-To: References: <20110426101631.F34C.A69D9226@jp.fujitsu.com> Message-Id: <20110427094902.D170.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Wed, 27 Apr 2011 09:47:48 +0900 (JST) Sender: owner-linux-mm@kvack.org List-ID: To: Ying Han Cc: kosaki.motohiro@jp.fujitsu.com, Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org > > > { > > > struct xfs_mount *mp; > > > struct xfs_perag *pag; > > > xfs_agnumber_t ag; > > > int reclaimable; > > > + int nr_to_scan = sc->nr_slab_to_reclaim; > > > + gfp_t gfp_mask = sc->gfp_mask; > > > > And, this very near meaning field .nr_scanned and .nr_slab_to_reclaim > > poped up new question. > > Why don't we pass more clever slab shrinker target? Why do we need pass > > similar two argument? > > > > I renamed the nr_slab_to_reclaim and nr_scanned in shrink struct. Oh no. that's not naming issue. example, Nick's previous similar patch pass zone-total-pages and how-much-scanned-pages. (ie shrink_slab don't calculate current magical target scanning objects anymore) ie, "4 * max_pass * (scanned / nr- lru_pages-in-zones)" Instead, individual shrink_slab callback calculate this one. see git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.git I'm curious why you change the design from another guy's previous very similar effort and We have to be convinced which is better. -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with ESMTP id 7C8469000C1 for ; Tue, 26 Apr 2011 21:15:58 -0400 (EDT) Received: from kpbe12.cbf.corp.google.com (kpbe12.cbf.corp.google.com [172.25.105.76]) by smtp-out.google.com with ESMTP id p3R1FsbU030295 for ; Tue, 26 Apr 2011 18:15:56 -0700 Received: from qyk2 (qyk2.prod.google.com [10.241.83.130]) by kpbe12.cbf.corp.google.com with ESMTP id p3R1FZWx004554 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 26 Apr 2011 18:15:53 -0700 Received: by qyk2 with SMTP id 2so1670375qyk.7 for ; Tue, 26 Apr 2011 18:15:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110427094902.D170.A69D9226@jp.fujitsu.com> References: <20110426101631.F34C.A69D9226@jp.fujitsu.com> <20110427094902.D170.A69D9226@jp.fujitsu.com> Date: Tue, 26 Apr 2011 18:15:52 -0700 Message-ID: Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct From: Ying Han Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: KOSAKI Motohiro Cc: Nick Piggin , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org On Tue, Apr 26, 2011 at 5:47 PM, KOSAKI Motohiro wrote: >> > > =A0{ >> > > =A0 =A0 =A0 struct xfs_mount *mp; >> > > =A0 =A0 =A0 struct xfs_perag *pag; >> > > =A0 =A0 =A0 xfs_agnumber_t =A0ag; >> > > =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 reclaimable; >> > > + =A0 =A0 int nr_to_scan =3D sc->nr_slab_to_reclaim; >> > > + =A0 =A0 gfp_t gfp_mask =3D sc->gfp_mask; >> > >> > And, this very near meaning field .nr_scanned and .nr_slab_to_reclaim >> > poped up new question. >> > Why don't we pass more clever slab shrinker target? Why do we need pas= s >> > similar two argument? >> > >> >> I renamed the nr_slab_to_reclaim and nr_scanned in shrink struct. > > Oh no. that's not naming issue. example, Nick's previous similar patch pa= ss > zone-total-pages and how-much-scanned-pages. (ie shrink_slab don't calcul= ate > current magical target scanning objects anymore) > =A0 =A0 =A0 =A0ie, =A0"4 * =A0max_pass =A0* (scanned / nr- lru_pages-in-z= ones)" > > Instead, individual shrink_slab callback calculate this one. > see git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.g= it > > I'm curious why you change the design from another guy's previous very si= milar effort and > We have to be convinced which is better. Thank you for the pointer. My patch is intended to consolidate all existing parameters passed from reclaim code to the shrinker. Talked w/ Nick and Andrew from last LSF, we agree that this patch will be useful for other extensions later which allows us easily adding extensions to the shrinkers without shrinker files. Nick and I talked about the effort later to pass the nodemask down to the shrinker. He is cc-ed in the thread. Another thing I would like to repost is to add the reclaim priority down to the shrinker, which we won't throw tons of page caches pages by reclaiming one inode slab object. --Ying > > > > -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with ESMTP id ABCD99000C1 for ; Tue, 26 Apr 2011 21:18:54 -0400 (EDT) Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id p3R1IqeB030437 for ; Tue, 26 Apr 2011 18:18:52 -0700 Received: from qwi4 (qwi4.prod.google.com [10.241.195.4]) by kpbe18.cbf.corp.google.com with ESMTP id p3R1IR2n013856 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 26 Apr 2011 18:18:51 -0700 Received: by qwi4 with SMTP id 4so1169305qwi.1 for ; Tue, 26 Apr 2011 18:18:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20110426101631.F34C.A69D9226@jp.fujitsu.com> <20110427094902.D170.A69D9226@jp.fujitsu.com> Date: Tue, 26 Apr 2011 18:18:50 -0700 Message-ID: Subject: Re: [PATCH V2 2/2] change shrinker API by passing shrink_control struct From: Ying Han Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: KOSAKI Motohiro Cc: npiggin@kernel.dk, Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Rik van Riel , Johannes Weiner , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org Hmm, got Nick's email wrong. --Ying On Tue, Apr 26, 2011 at 6:15 PM, Ying Han wrote: > On Tue, Apr 26, 2011 at 5:47 PM, KOSAKI Motohiro > wrote: >>> > > =A0{ >>> > > =A0 =A0 =A0 struct xfs_mount *mp; >>> > > =A0 =A0 =A0 struct xfs_perag *pag; >>> > > =A0 =A0 =A0 xfs_agnumber_t =A0ag; >>> > > =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 reclaimable; >>> > > + =A0 =A0 int nr_to_scan =3D sc->nr_slab_to_reclaim; >>> > > + =A0 =A0 gfp_t gfp_mask =3D sc->gfp_mask; >>> > >>> > And, this very near meaning field .nr_scanned and .nr_slab_to_reclaim >>> > poped up new question. >>> > Why don't we pass more clever slab shrinker target? Why do we need pa= ss >>> > similar two argument? >>> > >>> >>> I renamed the nr_slab_to_reclaim and nr_scanned in shrink struct. >> >> Oh no. that's not naming issue. example, Nick's previous similar patch p= ass >> zone-total-pages and how-much-scanned-pages. (ie shrink_slab don't calcu= late >> current magical target scanning objects anymore) >> =A0 =A0 =A0 =A0ie, =A0"4 * =A0max_pass =A0* (scanned / nr- lru_pages-in-= zones)" >> >> Instead, individual shrink_slab callback calculate this one. >> see git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.= git >> >> I'm curious why you change the design from another guy's previous very s= imilar effort and >> We have to be convinced which is better. > > Thank you for the pointer. My patch is intended to consolidate all > existing parameters passed from reclaim code > to the shrinker. > > Talked w/ Nick and Andrew from last LSF, =A0we agree that this patch > will be useful for other extensions later which allows us easily > adding extensions to the shrinkers without shrinker files. Nick and I > talked about the effort later to pass the nodemask down to the > shrinker. He is cc-ed in the thread. Another thing I would like to > repost is to add the reclaim priority down to the shrinker, which we > won't throw tons of page caches pages by reclaiming one inode slab > object. > > --Ying > > > >> >> >> >> > -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org