The patch titled vmscan: handle may_swap more strictly has been added to the -mm tree. Its filename is vmscan-handle-may_swap-more-strictly.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: vmscan: handle may_swap more strictly From: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx> Commit 2e2e425989080cc534fc0fca154cae515f971cf5 ("vmscan,memcg: reintroduce sc->may_swap) add may_swap flag and handle it at get_scan_ratio(). But the result of get_scan_ratio() is ignored when priority == 0, so anon lru is scanned even if may_swap == 0 or nr_swap_pages == 0. IMHO, this is not an expected behavior. As for memcg especially, because of this behavior many and many pages are swapped-out just in vain when oom is invoked by mem+swap limit. This patch is for handling may_swap flag more strictly. Signed-off-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Cc: Minchan Kim <minchan.kim@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Cc: Lee Schermerhorn <lee.schermerhorn@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmscan.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff -puN mm/vmscan.c~vmscan-handle-may_swap-more-strictly mm/vmscan.c --- a/mm/vmscan.c~vmscan-handle-may_swap-more-strictly +++ a/mm/vmscan.c @@ -1430,13 +1430,6 @@ static void get_scan_ratio(struct zone * unsigned long ap, fp; struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc); - /* If we have no swap space, do not bother scanning anon pages. */ - if (!sc->may_swap || (nr_swap_pages <= 0)) { - percent[0] = 0; - percent[1] = 100; - return; - } - anon = zone_nr_pages(zone, sc, LRU_ACTIVE_ANON) + zone_nr_pages(zone, sc, LRU_INACTIVE_ANON); file = zone_nr_pages(zone, sc, LRU_ACTIVE_FILE) + @@ -1534,15 +1527,22 @@ static void shrink_zone(int priority, st enum lru_list l; unsigned long nr_reclaimed = sc->nr_reclaimed; unsigned long swap_cluster_max = sc->swap_cluster_max; + int noswap = 0; - get_scan_ratio(zone, sc, percent); + /* If we have no swap space, do not bother scanning anon pages. */ + if (!sc->may_swap || (nr_swap_pages <= 0)) { + noswap = 1; + percent[0] = 0; + percent[1] = 100; + } else + get_scan_ratio(zone, sc, percent); for_each_evictable_lru(l) { int file = is_file_lru(l); unsigned long scan; scan = zone_nr_pages(zone, sc, l); - if (priority) { + if (priority || noswap) { scan >>= priority; scan = (scan * percent[file]) / 100; } _ Patches currently in -mm which might be from nishimura@xxxxxxxxxxxxxxxxx are mm-add-swap-cache-interface-for-swap-reference.patch mm-modify-swap_map-and-add-swap_has_cache-flag.patch mm-modify-swap_map-and-add-swap_has_cache-flag-update.patch mm-reuse-unused-swap-entry-if-necessary.patch mm-reuse-unused-swap-entry-if-necessary-update.patch vmscan-handle-may_swap-more-strictly.patch memcg-add-file-based-rss-accounting.patch memcg-add-file-based-rss-accounting-fix-mem_cgroup_update_mapped_file_stat-oops.patch memcg-remove-mem_cgroup_cache_charge_swapin.patch memcg-fix-swap-accounting.patch memcg-fix-swap-accounting-update.patch memcg-fix-behavior-under-memorylimit-equals-to-memswlimit.patch memcg-add-interface-to-reset-limits.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html