Commit a4d3e9e76337059406fcf3ead288c0df22a790e9

Authored by Johannes Weiner
Committed by Linus Torvalds
1 parent d4c32f355c

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 246e87a93934 ("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>

Showing 1 changed file with 12 additions and 15 deletions Side-by-side Diff

... ... @@ -1808,24 +1808,16 @@
1808 1808 u64 fraction[2], denominator;
1809 1809 enum lru_list l;
1810 1810 int noswap = 0;
1811   - int force_scan = 0;
  1811 + bool force_scan = false;
1812 1812 unsigned long nr_force_scan[2];
1813 1813  
  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;
1814 1820  
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   - }
1828   -
1829 1821 /* If we have no swap space, do not bother scanning anon pages. */
1830 1822 if (!sc->may_swap || (nr_swap_pages <= 0)) {
1831 1823 noswap = 1;
... ... @@ -1836,6 +1828,11 @@
1836 1828 nr_force_scan[1] = SWAP_CLUSTER_MAX;
1837 1829 goto out;
1838 1830 }
  1831 +
  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);
1839 1836  
1840 1837 if (scanning_global_lru(sc)) {
1841 1838 free = zone_page_state(zone, NR_FREE_PAGES);