Skip to content

Commit a4d3e9e

Browse files
Johannes Weinertorvalds
authored andcommitted
mm: vmscan: fix force-scanning small targets without swap
Without swap, anonymous pages are not scanned. As such, they should not count when considering force-scanning a small target if there is no swap. Otherwise, targets are not force-scanned even when their effective scan number is zero and the other conditions--kswapd/memcg--apply. This fixes 246e87a ("memcg: fix get_scan_count() for small targets"). [akpm@linux-foundation.org: fix comment] Signed-off-by: Johannes Weiner <jweiner@redhat.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 d4c32f3 commit a4d3e9e

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

‎mm/vmscan.c‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,23 +1808,15 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
18081808
u64 fraction[2], denominator;
18091809
enum lru_list l;
18101810
int noswap = 0;
1811-
int force_scan = 0;
1811+
bool force_scan = false;
18121812
unsigned long nr_force_scan[2];
18131813

1814-
1815-
anon = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_ANON) +
1816-
zone_nr_lru_pages(zone, sc, LRU_INACTIVE_ANON);
1817-
file = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_FILE) +
1818-
zone_nr_lru_pages(zone, sc, LRU_INACTIVE_FILE);
1819-
1820-
if (((anon + file) >> priority) < SWAP_CLUSTER_MAX) {
1821-
/* kswapd does zone balancing and need to scan this zone */
1822-
if (scanning_global_lru(sc) && current_is_kswapd())
1823-
force_scan = 1;
1824-
/* memcg may have small limit and need to avoid priority drop */
1825-
if (!scanning_global_lru(sc))
1826-
force_scan = 1;
1827-
}
1814+
/* kswapd does zone balancing and needs to scan this zone */
1815+
if (scanning_global_lru(sc) && current_is_kswapd())
1816+
force_scan = true;
1817+
/* memcg may have small limit and need to avoid priority drop */
1818+
if (!scanning_global_lru(sc))
1819+
force_scan = true;
18281820

18291821
/* If we have no swap space, do not bother scanning anon pages. */
18301822
if (!sc->may_swap || (nr_swap_pages <= 0)) {
@@ -1837,6 +1829,11 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
18371829
goto out;
18381830
}
18391831

1832+
anon = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_ANON) +
1833+
zone_nr_lru_pages(zone, sc, LRU_INACTIVE_ANON);
1834+
file = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_FILE) +
1835+
zone_nr_lru_pages(zone, sc, LRU_INACTIVE_FILE);
1836+
18401837
if (scanning_global_lru(sc)) {
18411838
free = zone_page_state(zone, NR_FREE_PAGES);
18421839
/* If we have very few page cache pages,

0 commit comments

Comments
 (0)