mm, thp: Do not queue fully unmapped pages for deferred split
Subsystems (2)
PATCH 1/1 mm, thp: Do not queue fully unmapped pages for deferred split
Adding fully unmapped pages into deferred split queue is not productive:
these pages are about to be freed or they are pinned and cannot be split anyway.
--- mm/rmap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
mm/rmap.c +10 -4
@@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)if (TestClearPageDoubleMap (page)) {/* * Subpages can be mapped with PTEs too. Check how many of -* themi are still mapped. +* them are still mapped. */ for (i =0 , nr =0 ; i <HPAGE_PMD_NR ; i++) {if (atomic_add_negative (-1 , &page[i]._mapcount)) nr++; } + +/* +* Queue the page for deferred split if at least one small +* page of the compound page is unmapped, but at least one +* small page is still mapped. +*/ +if (nr && nr <HPAGE_PMD_NR ) +deferred_split_huge_page (page); }else { nr =HPAGE_PMD_NR ; }
@@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)if (unlikely (PageMlocked (page)))clear_page_mlock (page); -if (nr) { +if (nr)__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , -nr); -deferred_split_huge_page (page); - } }/**
Signature · 1 line
2.21.0
Quoted 22 lines · Kirill A. Shutemov
Adding fully unmapped pages into deferred split queue is not productive:
these pages are about to be freed or they are pinned and cannot be split anyway.Signed-off-by Kirill A. Shutemov <[email protected]>--- mm/rmap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)mm/rmap.c +1
-1@@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)if (TestClearPageDoubleMap (page)) {/* * Subpages can be mapped with PTEs too. Check how many of -* themi are still mapped. +* them are still mapped. */ for (i =0 , nr =0 ; i <HPAGE_PMD_NR ; i++) {if (atomic_add_negative (-1 , &page[i]._mapcount))
mm/rmap.c static void page_remove_anon_compound_rmap(struct page *page) · line 1287
Quoted 10 lines
mm/rmap.c +8
-0nr++; } + +/* +* Queue the page for deferred split if at least one small +* page of the compound page is unmapped, but at least one +* small page is still mapped. +*/ +if (nr && nr <HPAGE_PMD_NR ) +deferred_split_huge_page (page);
You've set nr to zero in the for loop so this cannot work AFAICS.
Quoted 17 lines
mm/rmap.c +1
-3}else { nr =HPAGE_PMD_NR ; }@@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)if (unlikely (PageMlocked (page)))clear_page_mlock (page); -if (nr) { +if (nr)__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , -nr); -deferred_split_huge_page (page); - } }/** Signature · 1 line
2.21.0
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 27 lines · Michal Hocko
Quoted 26 lines · Kirill A. Shutemov
Adding fully unmapped pages into deferred split queue is not productive:
these pages are about to be freed or they are pinned and cannot be split anyway.Signed-off-by Kirill A. Shutemov <[email protected]>--- mm/rmap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)mm/rmap.c +3
-1@@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)if (TestClearPageDoubleMap (page)) {/* * Subpages can be mapped with PTEs too. Check how many of -* themi are still mapped. +* them are still mapped. */ for (i =0 , nr =0 ; i <HPAGE_PMD_NR ; i++) {if (atomic_add_negative (-1 , &page[i]._mapcount)) nr++; } + +/*
Quoted 8 lines
mm/rmap.c static void page_remove_anon_compound_rmap(struct page *page) · line 1287
Quoted 6 lines
mm/rmap.c +6
-0+* Queue the page for deferred split if at least one small +* page of the compound page is unmapped, but at least one +* small page is still mapped. +*/ +if (nr && nr <HPAGE_PMD_NR ) +deferred_split_huge_page (page);You've set nr to zero in the for loop so this cannot work AFAICS.
The for loop then does nr++ for each subpage that's still mapped?
Quoted 18 lines
Quoted 17 lines
mm/rmap.c +1
-3}else { nr =HPAGE_PMD_NR ; }@@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)if (unlikely (PageMlocked (page)))clear_page_mlock (page); -if (nr) { +if (nr)__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , -nr); -deferred_split_huge_page (page); - } }/** Signature · 1 line
2.21.0
Quoted 37 lines · Vlastimil Babka
Quoted 27 lines · Michal Hocko
Quoted 26 lines · Kirill A. Shutemov
Adding fully unmapped pages into deferred split queue is not productive:
these pages are about to be freed or they are pinned and cannot be split anyway.Signed-off-by Kirill A. Shutemov <[email protected]>--- mm/rmap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)mm/rmap.c +3
-1@@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)if (TestClearPageDoubleMap (page)) {/* * Subpages can be mapped with PTEs too. Check how many of -* themi are still mapped. +* them are still mapped. */ for (i =0 , nr =0 ; i <HPAGE_PMD_NR ; i++) {if (atomic_add_negative (-1 , &page[i]._mapcount)) nr++; } + +/* Quoted 8 lines
mm/rmap.c static void page_remove_anon_compound_rmap(struct page *page) · line 1287
Quoted 6 lines
mm/rmap.c +6
-0+* Queue the page for deferred split if at least one small +* page of the compound page is unmapped, but at least one +* small page is still mapped. +*/ +if (nr && nr <HPAGE_PMD_NR ) +deferred_split_huge_page (page);You've set nr to zero in the for loop so this cannot work AFAICS.
Quoted 1 line
The for loop then does nr++ for each subpage that's still mapped?
I am blind obviously. Sorry about the noise. Then the patch looks correct.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 4 lines · Kirill A. Shutemov
Adding fully unmapped pages into deferred split queue is not productive:
these pages are about to be freed or they are pinned and cannot be split anyway.
This change looks good to me. Reviewed-by: Yang Shi <[email protected]>
Quoted 48 lines
Signed-off-by Kirill A. Shutemov <[email protected]>--- mm/rmap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)mm/rmap.c +10
-5@@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)if (TestClearPageDoubleMap (page)) {/* * Subpages can be mapped with PTEs too. Check how many of -* themi are still mapped. +* them are still mapped. */ for (i =0 , nr =0 ; i <HPAGE_PMD_NR ; i++) {if (atomic_add_negative (-1 , &page[i]._mapcount)) nr++; } + +/* +* Queue the page for deferred split if at least one small +* page of the compound page is unmapped, but at least one +* small page is still mapped. +*/ +if (nr && nr <HPAGE_PMD_NR ) +deferred_split_huge_page (page); }else { nr =HPAGE_PMD_NR ; }@@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)if (unlikely (PageMlocked (page)))clear_page_mlock (page); -if (nr) { +if (nr)__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , -nr); -deferred_split_huge_page (page); - } }/** -- 2.21.0