Patch "mm: migrate: fix missing update page_private to hugetlb_page_subpool" has been added to the 5.13-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mm: migrate: fix missing update page_private to hugetlb_page_subpool

to the 5.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mm-migrate-fix-missing-update-page_private-to-hugetl.patch
and it can be found in the queue-5.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 912ca1348489c11423fe9a451c4fe612b5db2ec2
Author: Muchun Song <songmuchun@xxxxxxxxxxxxx>
Date:   Wed Jun 30 18:51:29 2021 -0700

    mm: migrate: fix missing update page_private to hugetlb_page_subpool
    
    [ Upstream commit 6acfb5ba150cf75005ce85e0e25d79ef2fec287c ]
    
    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().
    
    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.
    
    The commit forgot to update it in the page migration routine.  So fix it.
    
    [songmuchun@xxxxxxxxxxxxx: fix compiler error when !CONFIG_HUGETLB_PAGE reported by Randy]
      Link: https://lkml.kernel.org/r/20210521022747.35736-1-songmuchun@xxxxxxxxxxxxx
    
    Link: https://lkml.kernel.org/r/20210520025949.1866-1-songmuchun@xxxxxxxxxxxxx
    Fixes: d6995da31122 ("hugetlb: use page.private for hugetlb specific page flags")
    Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
    Reported-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
    Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
    Acked-by: Michal Hocko <mhocko@xxxxxxxx>
    Tested-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>        [arm64]
    Cc: Oscar Salvador <osalvador@xxxxxxx>
    Cc: David Hildenbrand <david@xxxxxxxxxx>
    Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
    Cc: Xiongchun Duan <duanxiongchun@xxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 3c0117656745..28a110ec2a0d 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -875,6 +875,11 @@ static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
 #else	/* CONFIG_HUGETLB_PAGE */
 struct hstate {};
 
+static inline struct hugepage_subpool *hugetlb_page_subpool(struct page *hpage)
+{
+	return NULL;
+}
+
 static inline int isolate_or_dissolve_huge_page(struct page *page,
 						struct list_head *list)
 {
diff --git a/mm/migrate.c b/mm/migrate.c
index 41ff2c9896c4..047209d6602e 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1288,7 +1288,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;
 	}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux