aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2011-07-26 19:08:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:42 -0400
commit4508378b9523e22a2a0175d8bf64d932fb10a67d (patch)
treef7ebd57322edc18ff91ed7d71236fbbd5633c21c /mm/vmscan.c
parent1af8efe965676ab30d6c8a5b1fccc9229f339a3b (diff)
memcg: fix vmscan count in small memcgs
Commit 246e87a93934 ("memcg: fix get_scan_count() for small targets") fixes the memcg/kswapd behavior against small targets and prevent vmscan priority too high. But the implementation is too naive and adds another problem to small memcg. It always force scan to 32 pages of file/anon and doesn't handle swappiness and other rotate_info. It makes vmscan to scan anon LRU regardless of swappiness and make reclaim bad. This patch fixes it by adjusting scanning count with regard to swappiness at el. At a test "cat 1G file under 300M limit." (swappiness=20) before patch scanned_pages_by_limit 360919 scanned_anon_pages_by_limit 180469 scanned_file_pages_by_limit 180450 rotated_pages_by_limit 31 rotated_anon_pages_by_limit 25 rotated_file_pages_by_limit 6 freed_pages_by_limit 180458 freed_anon_pages_by_limit 19 freed_file_pages_by_limit 180439 elapsed_ns_by_limit 429758872 after patch scanned_pages_by_limit 180674 scanned_anon_pages_by_limit 24 scanned_file_pages_by_limit 180650 rotated_pages_by_limit 35 rotated_anon_pages_by_limit 24 rotated_file_pages_by_limit 11 freed_pages_by_limit 180634 freed_anon_pages_by_limit 0 freed_file_pages_by_limit 180634 elapsed_ns_by_limit 367119089 scanned_pages_by_system 0 the numbers of scanning anon are decreased(as expected), and elapsed time reduced. By this patch, small memcgs will work better. (*) Because the amount of file-cache is much bigger than anon, recalaim_stat's rotate-scan counter make scanning files more. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Michal Hocko <mhocko@suse.cz> Cc: Ying Han <yinghan@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 91cee9dfc501..f87702a376d0 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1795,6 +1795,7 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1795 enum lru_list l; 1795 enum lru_list l;
1796 int noswap = 0; 1796 int noswap = 0;
1797 int force_scan = 0; 1797 int force_scan = 0;
1798 unsigned long nr_force_scan[2];
1798 1799
1799 1800
1800 anon = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_ANON) + 1801 anon = zone_nr_lru_pages(zone, sc, LRU_ACTIVE_ANON) +
@@ -1817,6 +1818,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1817 fraction[0] = 0; 1818 fraction[0] = 0;
1818 fraction[1] = 1; 1819 fraction[1] = 1;
1819 denominator = 1; 1820 denominator = 1;
1821 nr_force_scan[0] = 0;
1822 nr_force_scan[1] = SWAP_CLUSTER_MAX;
1820 goto out; 1823 goto out;
1821 } 1824 }
1822 1825
@@ -1828,6 +1831,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1828 fraction[0] = 1; 1831 fraction[0] = 1;
1829 fraction[1] = 0; 1832 fraction[1] = 0;
1830 denominator = 1; 1833 denominator = 1;
1834 nr_force_scan[0] = SWAP_CLUSTER_MAX;
1835 nr_force_scan[1] = 0;
1831 goto out; 1836 goto out;
1832 } 1837 }
1833 } 1838 }
@@ -1876,6 +1881,11 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1876 fraction[0] = ap; 1881 fraction[0] = ap;
1877 fraction[1] = fp; 1882 fraction[1] = fp;
1878 denominator = ap + fp + 1; 1883 denominator = ap + fp + 1;
1884 if (force_scan) {
1885 unsigned long scan = SWAP_CLUSTER_MAX;
1886 nr_force_scan[0] = div64_u64(scan * ap, denominator);
1887 nr_force_scan[1] = div64_u64(scan * fp, denominator);
1888 }
1879out: 1889out:
1880 for_each_evictable_lru(l) { 1890 for_each_evictable_lru(l) {
1881 int file = is_file_lru(l); 1891 int file = is_file_lru(l);
@@ -1896,12 +1906,8 @@ out:
1896 * memcg, priority drop can cause big latency. So, it's better 1906 * memcg, priority drop can cause big latency. So, it's better
1897 * to scan small amount. See may_noscan above. 1907 * to scan small amount. See may_noscan above.
1898 */ 1908 */
1899 if (!scan && force_scan) { 1909 if (!scan && force_scan)
1900 if (file) 1910 scan = nr_force_scan[file];
1901 scan = SWAP_CLUSTER_MAX;
1902 else if (!noswap)
1903 scan = SWAP_CLUSTER_MAX;
1904 }
1905 nr[l] = scan; 1911 nr[l] = scan;
1906 } 1912 }
1907} 1913}