Commit 2ffebca6aa7e1687905c842dd8c5c1e811e574e7
Committed by
Linus Torvalds
1 parent
c5b947b288
Exists in
master
and in
4 other branches
memcg: fix lru rotation in isolate_pages
Try to fix memcg's lru rotation sanity: make memcg use the same logic as the global LRU does. Now, at __isolate_lru_page() retruns -EBUSY, the page is rotated to the tail of LRU in global LRU's isolate LRU pages. But in memcg, it's not handled. This makes memcg do the same behavior as global LRU and rotate LRU in the page is busy. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Minchan Kim <minchan.kim@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 15 additions and 2 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -649,6 +649,7 @@ |
649 | 649 | int zid = zone_idx(z); |
650 | 650 | struct mem_cgroup_per_zone *mz; |
651 | 651 | int lru = LRU_FILE * !!file + !!active; |
652 | + int ret; | |
652 | 653 | |
653 | 654 | BUG_ON(!mem_cont); |
654 | 655 | mz = mem_cgroup_zoneinfo(mem_cont, nid, zid); |
655 | 656 | |
656 | 657 | |
... | ... | @@ -666,9 +667,19 @@ |
666 | 667 | continue; |
667 | 668 | |
668 | 669 | scan++; |
669 | - if (__isolate_lru_page(page, mode, file) == 0) { | |
670 | + ret = __isolate_lru_page(page, mode, file); | |
671 | + switch (ret) { | |
672 | + case 0: | |
670 | 673 | list_move(&page->lru, dst); |
674 | + mem_cgroup_del_lru(page); | |
671 | 675 | nr_taken++; |
676 | + break; | |
677 | + case -EBUSY: | |
678 | + /* we don't affect global LRU but rotate in our LRU */ | |
679 | + mem_cgroup_rotate_lru_list(page, page_lru(page)); | |
680 | + break; | |
681 | + default: | |
682 | + break; | |
672 | 683 | } |
673 | 684 | } |
674 | 685 |
mm/vmscan.c
... | ... | @@ -837,7 +837,6 @@ |
837 | 837 | */ |
838 | 838 | ClearPageLRU(page); |
839 | 839 | ret = 0; |
840 | - mem_cgroup_del_lru(page); | |
841 | 840 | } |
842 | 841 | |
843 | 842 | return ret; |
844 | 843 | |
... | ... | @@ -885,12 +884,14 @@ |
885 | 884 | switch (__isolate_lru_page(page, mode, file)) { |
886 | 885 | case 0: |
887 | 886 | list_move(&page->lru, dst); |
887 | + mem_cgroup_del_lru(page); | |
888 | 888 | nr_taken++; |
889 | 889 | break; |
890 | 890 | |
891 | 891 | case -EBUSY: |
892 | 892 | /* else it is being freed elsewhere */ |
893 | 893 | list_move(&page->lru, src); |
894 | + mem_cgroup_rotate_lru_list(page, page_lru(page)); | |
894 | 895 | continue; |
895 | 896 | |
896 | 897 | default: |
... | ... | @@ -931,6 +932,7 @@ |
931 | 932 | continue; |
932 | 933 | if (__isolate_lru_page(cursor_page, mode, file) == 0) { |
933 | 934 | list_move(&cursor_page->lru, dst); |
935 | + mem_cgroup_del_lru(page); | |
934 | 936 | nr_taken++; |
935 | 937 | scan++; |
936 | 938 | } |