mm: Fix mis accounting of isolated pages in memcg_numa_isolate_pages()

Submitted by Kirill Tkhai on Nov. 13, 2017, 11:50 a.m.

Details

Message ID 151057379129.3841.6718083230217559545.stgit@localhost.localdomain
State New
Series "mm: Fix mis accounting of isolated pages in memcg_numa_isolate_pages()"
Headers show

Commit Message

Kirill Tkhai Nov. 13, 2017, 11:50 a.m.
When split_huge_page_to_list() fails, and a huge page is going back
to LRU, the number of isolated pages is decreasing. So we must
subtract HPAGE_PMD_NR from NR_ISOLATED_ANON counter, not to add it.

Otherwise, we may bumped into a situation, when number of isolated
pages grows up to number of inactive pages, and direct reclaim hangs in:

  shrink_inactive_list()
     while (too_many_isolated())
        congestion_wait(BLK_RW_ASYNC, HZ/10),

waiting for the counter becomes less. But it has no a chance
to finish, and hangs forever. Fix that.

https://jira.sw.ru/browse/PSBM-76970

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a7fa84a9980..a165a221e87 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4963,7 +4963,7 @@  static long memcg_numa_isolate_pages(struct lruvec *lruvec, enum lru_list lru,
 		if (PageTransHuge(page) && split_huge_page_to_list(page, dst)) {
 			list_del(&page->lru);
 			mod_zone_page_state(zone, NR_ISOLATED_ANON,
-					HPAGE_PMD_NR);
+					-HPAGE_PMD_NR);
 			putback_lru_page(page);
 		}
 	}

Comments

Andrey Ryabinin Nov. 13, 2017, 12:22 p.m.
On 11/13/2017 02:50 PM, Kirill Tkhai wrote:
> When split_huge_page_to_list() fails, and a huge page is going back
> to LRU, the number of isolated pages is decreasing. So we must
> subtract HPAGE_PMD_NR from NR_ISOLATED_ANON counter, not to add it.
> 
> Otherwise, we may bumped into a situation, when number of isolated
> pages grows up to number of inactive pages, and direct reclaim hangs in:
> 
>   shrink_inactive_list()
>      while (too_many_isolated())
>         congestion_wait(BLK_RW_ASYNC, HZ/10),
> 
> waiting for the counter becomes less. But it has no a chance
> to finish, and hangs forever. Fix that.
> 
> https://jira.sw.ru/browse/PSBM-76970
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>