mm: migrate: fix missing update page_private to hugetlb_page_subpool
Subsystems (2)
PATCH 1/1 mm: migrate: fix missing update page_private to hugetlb_page_subpool
Since commit d6995da31122 ("hugetlb: use page.private for hugetlb specific page flags") converts page.private for hugetlb specific page flags. We should use hugetlb_page_subpool() to get the subpool pointer instead of page_private(). The commit forgot to update it in the page migration routine. So fix it.
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -1290,7 +1290,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,* page_mapping() set, hugetlbfs specific move page routine will not * be called and we could leak usage counts for subpools. */ -if (page_private (hpage) && !page_mapping (hpage)) { +if (hugetlb_page_subpool (hpage) && !page_mapping (hpage)) { rc = -EBUSY ; goto out_unlock; }
Signature · 1 line
2.11.0
Quoted 6 lines · Muchun Song
Since commit
d6995da31122("hugetlb: use page.private for hugetlb specific page flags") converts page.private for hugetlb specific page flags. We should usehugetlb_page_subpool()to get the subpool pointer instead ofpage_private(). The commit forgot to update it in the page migration routine. So fix it.
Quoted 6 lines
Fixes d6995da31122 ("hugetlb: use page.private for hugetlb specific page flags")Reported-by Anshuman Khandual <[email protected]>Signed-off-by Muchun Song <[email protected]>--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thank you Muchun!
Signature · 1 line
Mike Kravetz
Andrew Morton
maintainerQuoted 11 lines · On Thu, 20 May 2021 10:59:49 +0800 Muchun Song <[email protected]> wrote:
Since commit
d6995da31122("hugetlb: use page.private for hugetlb specific page flags") converts page.private for hugetlb specific page flags. We should usehugetlb_page_subpool()to get the subpool pointer instead ofpage_private(). The commit forgot to update it in the page migration routine. So fix it....
mm/migrate.c static int unmap_and_move_huge_page(new_page_t get_new_page, · line 1296
Quoted 8 lines
mm/migrate.c +1
-1@@ -1290,7 +1290,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,* page_mapping() set, hugetlbfs specific move page routine will not * be called and we could leak usage counts for subpools. */ -if (page_private (hpage) && !page_mapping (hpage)) { +if (hugetlb_page_subpool (hpage) && !page_mapping (hpage)) { rc = -EBUSY ; goto out_unlock; }
So it uses the wrong page*, so this isn't just a cosmetic fix. One cannot tell from this changelog.
Please describe the runtime effects of this bug. Please always include this information when fixing bugs. And when adding them.
Quoted 26 lines · Andrew Morton
Quoted 11 lines · On Thu, 20 May 2021 10:59:49 +0800 Muchun Song <[email protected]> wrote:
Since commit
d6995da31122("hugetlb: use page.private for hugetlb specific page flags") converts page.private for hugetlb specific page flags. We should usehugetlb_page_subpool()to get the subpool pointer instead ofpage_private(). The commit forgot to update it in the page migration routine. So fix it....
mm/migrate.c static int unmap_and_move_huge_page(new_page_t get_new_page, · line 1296
Quoted 8 lines
mm/migrate.c +1
-1@@ -1290,7 +1290,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,* page_mapping() set, hugetlbfs specific move page routine will not * be called and we could leak usage counts for subpools. */ -if (page_private (hpage) && !page_mapping (hpage)) { +if (hugetlb_page_subpool (hpage) && !page_mapping (hpage)) { rc = -EBUSY ; goto out_unlock; }So it uses the wrong page*, so this isn't just a cosmetic fix. One cannot tell from this changelog.
Quoted 2 lines
Please describe the runtime effects of this bug. Please always include this information when fixing bugs. And when adding them.
OK. I should update the commit log in the next version.
Thanks.
Quoted 28 lines · Muchun Song
Quoted 26 lines · Andrew Morton
Quoted 11 lines · On Thu, 20 May 2021 10:59:49 +0800 Muchun Song <[email protected]> wrote:
Since commit
d6995da31122("hugetlb: use page.private for hugetlb specific page flags") converts page.private for hugetlb specific page flags. We should usehugetlb_page_subpool()to get the subpool pointer instead ofpage_private(). The commit forgot to update it in the page migration routine. So fix it....
mm/migrate.c static int unmap_and_move_huge_page(new_page_t get_new_page, · line 1296
Quoted 8 lines
mm/migrate.c +1
-1@@ -1290,7 +1290,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,* page_mapping() set, hugetlbfs specific move page routine will not * be called and we could leak usage counts for subpools. */ -if (page_private (hpage) && !page_mapping (hpage)) { +if (hugetlb_page_subpool (hpage) && !page_mapping (hpage)) { rc = -EBUSY ; goto out_unlock; }So it uses the wrong page*, so this isn't just a cosmetic fix. One cannot tell from this changelog.
Quoted 5 lines
Quoted 2 lines
Please describe the runtime effects of this bug. Please always include this information when fixing bugs. And when adding them.
OK. I should update the commit log in the next version.
Unfortunately, it is more than a cosmetic fix.
This 'could' prevent the migration of hugetlb pages. page_private(hpage) is now used for hugetlb page specific flags. At migration time, the only flag which could be set is HPageVmemmapOptimized. This flag will only be set if the new vmemmap reduction feature is enabled. In addition, !page_mapping() implies an anonymous mapping. So, this will prevent migration of hugetb pages in anonymous mappings if the vmemmap reduction feature is enabled.
In addition, that if statement checked for the rare race condition of a page being migrated while in the process of being freed. Since that check is now wrong, we could leak hugetlb subpool usage counts.
Muchun, feel free to use as much of that as you would like in the updated commit message.
Signature · 1 line
Mike Kravetz
Quoted 46 lines · Mike Kravetz
Quoted 28 lines · Muchun Song
Quoted 26 lines · Andrew Morton
Quoted 11 lines · On Thu, 20 May 2021 10:59:49 +0800 Muchun Song <[email protected]> wrote:
Since commit
d6995da31122("hugetlb: use page.private for hugetlb specific page flags") converts page.private for hugetlb specific page flags. We should usehugetlb_page_subpool()to get the subpool pointer instead ofpage_private(). The commit forgot to update it in the page migration routine. So fix it....
mm/migrate.c static int unmap_and_move_huge_page(new_page_t get_new_page, · line 1296
Quoted 8 lines
mm/migrate.c +1
-1@@ -1290,7 +1290,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,* page_mapping() set, hugetlbfs specific move page routine will not * be called and we could leak usage counts for subpools. */ -if (page_private (hpage) && !page_mapping (hpage)) { +if (hugetlb_page_subpool (hpage) && !page_mapping (hpage)) { rc = -EBUSY ; goto out_unlock; }So it uses the wrong page*, so this isn't just a cosmetic fix. One cannot tell from this changelog.
Quoted 5 lines
Quoted 2 lines
Please describe the runtime effects of this bug. Please always include this information when fixing bugs. And when adding them.
OK. I should update the commit log in the next version.
Unfortunately, it is more than a cosmetic fix.
This 'could' prevent the migration of hugetlb pages.
page_private(hpage)is now used for hugetlb page specific flags. At migration time, the only flag which could be set is HPageVmemmapOptimized. This flag will only be set if the new vmemmap reduction feature is enabled. In addition, !page_mapping() implies an anonymous mapping. So, this will prevent migration of hugetb pages in anonymous mappings if the vmemmap reduction feature is enabled.
Quoted 6 lines
In addition, that if statement checked for the rare race condition of a page being migrated while in the process of being freed. Since that check is now wrong, we could leak hugetlb subpool usage counts.
Muchun, feel free to use as much of that as you would like in the updated commit message.
Thanks Mike. I'll use this.
Quoted 2 lines
--
Mike Kravetz