vmscan: move reclaim_state handling to shrink_slab
Subsystems (4)
PATCH 1/1 vmscan: move reclaim_state handling to shrink_slab
current->reclaim_state is only used to count the number of slab pages reclaimed by shrink_slab(). So instead of initializing it before we are going to call try_to_free_pages() or shrink_zone(), let's set in directly in shrink_slab().
This patch also makes shrink_slab() return the number of reclaimed slab pages (obtained from reclaim_state) instead of the number of reclaimed objects, because the latter is not of much use - it was only checked by drop_slab() to decide whether it should continue reclaim or abort. The number of reclaimed pages is more appropriate, because it also can be used by shrink_zone() to accumulate scan_control->nr_reclaimed.
Note that after this patch try_to_free_mem_cgroup_pages() will count not only reclaimed user pages, but also slab pages, which is expected, because it can reclaim kmem from kmem-active sub cgroups.
--- mm/page_alloc.c | 4 --- mm/vmscan.c | 73 ++++++++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 50 deletions(-)
mm/page_alloc.c +0 -4
@@ -2448,7 +2448,6 @@ static int __perform_reclaim(gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist, nodemask_t *nodemask) { - struct reclaim_state reclaim_state; int progress;cond_resched ();
@@ -2457,12 +2456,9 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist,cpuset_memory_pressure_bump (); current->flags |=PF_MEMALLOC ;lockdep_set_current_reclaim_state (gfp_mask); - reclaim_state.reclaimed_slab =0 ; - current->reclaim_state = &reclaim_state; progress =try_to_free_pages (zonelist, order, gfp_mask, nodemask); - current->reclaim_state =NULL ;lockdep_clear_current_reclaim_state (); current->flags &= ~PF_MEMALLOC ;
mm/vmscan.c +27 -46
197 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 11 lines · On Wed, 14 Jan 2015 16:55:36 +0300 Vladimir Davydov <[email protected]>…
current->reclaim_stateis only used to count the number of slab pages reclaimed byshrink_slab(). So instead of initializing it before we are going to calltry_to_free_pages()orshrink_zone(), let's set in directly inshrink_slab().This patch also makes
shrink_slab()return the number of reclaimed slab pages (obtained fromreclaim_state) instead of the number of reclaimed objects, because the latter is not of much use - it was only checked bydrop_slab()to decide whether it should continue reclaim or abort. The number of reclaimed pages is more appropriate, because it also can be used byshrink_zone()to accumulatescan_control->nr_reclaimed.
Not sure that this is a good change. If shrink_slab() managed to free some objects but didn't free any pages then that's a good sign that additional calls to shrink_slab() *will* free some pages. With this change, drop_slab_node() can give up too early.
The general philosophy throughout here is: "pass it nr_to_scan, it returns nr_scanned/nr_freed". Switching the return value to nr_pages_freed kinda breaks that paradigm.
Quoted 7 lines
Note that after this patch
try_to_free_mem_cgroup_pages()will count not only reclaimed user pages, but also slab pages, which is expected, because it can reclaim kmem from kmem-active sub cgroups.mm/page_alloc.c | 4 --- mm/vmscan.c | 73 ++++++++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 50 deletions(-)
That's nice though.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Wed, 14 Jan 2015 16:55:36 +0300 Vladimir Davydov <[email protected]>…
This patch also makes
shrink_slab()return the number of reclaimed slab pages (obtained fromreclaim_state) instead of the number of reclaimed objects, because the latter is not of much use - it was only checked bydrop_slab()to decide whether it should continue reclaim or abort. The number of reclaimed pages is more appropriate, because it also can be used byshrink_zone()to accumulatescan_control->nr_reclaimed.
Quoted 4 lines
Not sure that this is a good change. If
shrink_slab()managed to free some objects but didn't free any pages then that's a good sign that additional calls toshrink_slab()*will* free some pages. With this change,drop_slab_node()can give up too early.
Fair enough. We'd better leave the return value intact then. I think we should add an additional argument to add the number of reclaimed slab pages to, as I intended to do initially. Will resend.
Thanks,
Vladimir