Skip to content

Commit f11c0ca

Browse files
Johannes Weinertorvalds
authored andcommitted
mm: vmscan: drop nr_force_scan[] from get_scan_count
The nr_force_scan[] tuple holds the effective scan numbers for anon and file pages in case the situation called for a forced scan and the regularly calculated scan numbers turned out zero. However, the effective scan number can always be assumed to be SWAP_CLUSTER_MAX right before the division into anon and file. The numerators and denominator are properly set up for all cases, be it force scan for just file, just anon, or both, to do the right thing. Signed-off-by: Johannes Weiner <jweiner@redhat.com> Reviewed-by: Minchan Kim <minchan.kim@gmail.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: Ying Han <yinghan@google.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Acked-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4f31888 commit f11c0ca

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

‎mm/vmscan.c‎

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,12 +1817,19 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
18171817
enum lru_list l;
18181818
int noswap = 0;
18191819
bool force_scan = false;
1820-
unsigned long nr_force_scan[2];
18211820

1822-
/* kswapd does zone balancing and needs to scan this zone */
1821+
/*
1822+
* If the zone or memcg is small, nr[l] can be 0. This
1823+
* results in no scanning on this priority and a potential
1824+
* priority drop. Global direct reclaim can go to the next
1825+
* zone and tends to have no problems. Global kswapd is for
1826+
* zone balancing and it needs to scan a minimum amount. When
1827+
* reclaiming for a memcg, a priority drop can cause high
1828+
* latencies, so it's better to scan a minimum amount there as
1829+
* well.
1830+
*/
18231831
if (scanning_global_lru(sc) && current_is_kswapd())
18241832
force_scan = true;
1825-
/* memcg may have small limit and need to avoid priority drop */
18261833
if (!scanning_global_lru(sc))
18271834
force_scan = true;
18281835

@@ -1832,8 +1839,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
18321839
fraction[0] = 0;
18331840
fraction[1] = 1;
18341841
denominator = 1;
1835-
nr_force_scan[0] = 0;
1836-
nr_force_scan[1] = SWAP_CLUSTER_MAX;
18371842
goto out;
18381843
}
18391844

@@ -1850,8 +1855,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
18501855
fraction[0] = 1;
18511856
fraction[1] = 0;
18521857
denominator = 1;
1853-
nr_force_scan[0] = SWAP_CLUSTER_MAX;
1854-
nr_force_scan[1] = 0;
18551858
goto out;
18561859
}
18571860
}
@@ -1900,11 +1903,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
19001903
fraction[0] = ap;
19011904
fraction[1] = fp;
19021905
denominator = ap + fp + 1;
1903-
if (force_scan) {
1904-
unsigned long scan = SWAP_CLUSTER_MAX;
1905-
nr_force_scan[0] = div64_u64(scan * ap, denominator);
1906-
nr_force_scan[1] = div64_u64(scan * fp, denominator);
1907-
}
19081906
out:
19091907
for_each_evictable_lru(l) {
19101908
int file = is_file_lru(l);
@@ -1913,20 +1911,10 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
19131911
scan = zone_nr_lru_pages(zone, sc, l);
19141912
if (priority || noswap) {
19151913
scan >>= priority;
1914+
if (!scan && force_scan)
1915+
scan = SWAP_CLUSTER_MAX;
19161916
scan = div64_u64(scan * fraction[file], denominator);
19171917
}
1918-
1919-
/*
1920-
* If zone is small or memcg is small, nr[l] can be 0.
1921-
* This results no-scan on this priority and priority drop down.
1922-
* For global direct reclaim, it can visit next zone and tend
1923-
* not to have problems. For global kswapd, it's for zone
1924-
* balancing and it need to scan a small amounts. When using
1925-
* memcg, priority drop can cause big latency. So, it's better
1926-
* to scan small amount. See may_noscan above.
1927-
*/
1928-
if (!scan && force_scan)
1929-
scan = nr_force_scan[file];
19301918
nr[l] = scan;
19311919
}
19321920
}

0 commit comments

Comments
 (0)