Commit f0f7902d authored by KOSAKI Motohiro's avatar KOSAKI Motohiro Committed by james toy

Currently, sc.scap_cluster_max has double meanings.

 1) reclaim batch size as isolate_lru_pages()'s argument
 2) reclaim baling out thresolds

The two meanings pretty unrelated. Thus, Let's separate it.
this patch doesn't change any behavior.
Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: default avatarRik van Riel <riel@redhat.com>
Reviewed-by: default avatarMinchan Kim <minchan.kim@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 250bc948
...@@ -55,6 +55,9 @@ struct scan_control { ...@@ -55,6 +55,9 @@ struct scan_control {
/* Number of pages freed so far during a call to shrink_zones() */ /* Number of pages freed so far during a call to shrink_zones() */
unsigned long nr_reclaimed; unsigned long nr_reclaimed;
/* How many pages shrink_list() should reclaim */
unsigned long nr_to_reclaim;
/* This context's GFP mask */ /* This context's GFP mask */
gfp_t gfp_mask; gfp_t gfp_mask;
...@@ -1599,6 +1602,7 @@ static void shrink_zone(int priority, struct zone *zone, ...@@ -1599,6 +1602,7 @@ static void shrink_zone(int priority, struct zone *zone,
enum lru_list l; enum lru_list l;
unsigned long nr_reclaimed = sc->nr_reclaimed; unsigned long nr_reclaimed = sc->nr_reclaimed;
unsigned long swap_cluster_max = sc->swap_cluster_max; unsigned long swap_cluster_max = sc->swap_cluster_max;
unsigned long nr_to_reclaim = sc->nr_to_reclaim;
struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc); struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
int noswap = 0; int noswap = 0;
...@@ -1643,8 +1647,7 @@ static void shrink_zone(int priority, struct zone *zone, ...@@ -1643,8 +1647,7 @@ static void shrink_zone(int priority, struct zone *zone,
* with multiple processes reclaiming pages, the total * with multiple processes reclaiming pages, the total
* freeing target can get unreasonably large. * freeing target can get unreasonably large.
*/ */
if (nr_reclaimed > swap_cluster_max && if (nr_reclaimed > nr_to_reclaim && priority < DEF_PRIORITY)
priority < DEF_PRIORITY && !current_is_kswapd())
break; break;
} }
...@@ -1742,6 +1745,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, ...@@ -1742,6 +1745,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
struct zoneref *z; struct zoneref *z;
struct zone *zone; struct zone *zone;
enum zone_type high_zoneidx = gfp_zone(sc->gfp_mask); enum zone_type high_zoneidx = gfp_zone(sc->gfp_mask);
unsigned long writeback_threshold;
delayacct_freepages_start(); delayacct_freepages_start();
...@@ -1777,7 +1781,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, ...@@ -1777,7 +1781,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
} }
} }
total_scanned += sc->nr_scanned; total_scanned += sc->nr_scanned;
if (sc->nr_reclaimed >= sc->swap_cluster_max) { if (sc->nr_reclaimed >= sc->nr_to_reclaim) {
ret = sc->nr_reclaimed; ret = sc->nr_reclaimed;
goto out; goto out;
} }
...@@ -1789,8 +1793,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, ...@@ -1789,8 +1793,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
* that's undesirable in laptop mode, where we *want* lumpy * that's undesirable in laptop mode, where we *want* lumpy
* writeout. So in laptop mode, write out the whole world. * writeout. So in laptop mode, write out the whole world.
*/ */
if (total_scanned > sc->swap_cluster_max + writeback_threshold = sc->nr_to_reclaim + sc->nr_to_reclaim / 2;
sc->swap_cluster_max / 2) { if (total_scanned > writeback_threshold) {
wakeup_flusher_threads(laptop_mode ? 0 : total_scanned); wakeup_flusher_threads(laptop_mode ? 0 : total_scanned);
sc->may_writepage = 1; sc->may_writepage = 1;
} }
...@@ -1836,6 +1840,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, ...@@ -1836,6 +1840,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
.gfp_mask = gfp_mask, .gfp_mask = gfp_mask,
.may_writepage = !laptop_mode, .may_writepage = !laptop_mode,
.swap_cluster_max = SWAP_CLUSTER_MAX, .swap_cluster_max = SWAP_CLUSTER_MAX,
.nr_to_reclaim = SWAP_CLUSTER_MAX,
.may_unmap = 1, .may_unmap = 1,
.may_swap = 1, .may_swap = 1,
.swappiness = vm_swappiness, .swappiness = vm_swappiness,
...@@ -1894,6 +1899,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, ...@@ -1894,6 +1899,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
.may_unmap = 1, .may_unmap = 1,
.may_swap = !noswap, .may_swap = !noswap,
.swap_cluster_max = SWAP_CLUSTER_MAX, .swap_cluster_max = SWAP_CLUSTER_MAX,
.nr_to_reclaim = SWAP_CLUSTER_MAX,
.swappiness = swappiness, .swappiness = swappiness,
.order = 0, .order = 0,
.mem_cgroup = mem_cont, .mem_cgroup = mem_cont,
...@@ -1959,6 +1965,11 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order) ...@@ -1959,6 +1965,11 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
.may_unmap = 1, .may_unmap = 1,
.may_swap = 1, .may_swap = 1,
.swap_cluster_max = SWAP_CLUSTER_MAX, .swap_cluster_max = SWAP_CLUSTER_MAX,
/*
* kswapd doesn't want to be bailed out while reclaim. because
* we want to put equal scanning pressure on each zone.
*/
.nr_to_reclaim = ULONG_MAX,
.swappiness = vm_swappiness, .swappiness = vm_swappiness,
.order = order, .order = order,
.mem_cgroup = NULL, .mem_cgroup = NULL,
...@@ -2628,7 +2639,9 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) ...@@ -2628,7 +2639,9 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
.may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP), .may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP),
.may_swap = 1, .may_swap = 1,
.swap_cluster_max = max_t(unsigned long, nr_pages, .swap_cluster_max = max_t(unsigned long, nr_pages,
SWAP_CLUSTER_MAX), SWAP_CLUSTER_MAX),
.nr_to_reclaim = max_t(unsigned long, nr_pages,
SWAP_CLUSTER_MAX),
.gfp_mask = gfp_mask, .gfp_mask = gfp_mask,
.swappiness = vm_swappiness, .swappiness = vm_swappiness,
.order = order, .order = order,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment