Patch "mm/huge_memory.c: don't discard hugepage if other processes are mapping it" 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/huge_memory.c: don't discard hugepage if other processes are mapping it

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-huge_memory.c-don-t-discard-hugepage-if-other-pro.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 0872f648a820acdd3f8082b7c81d072e3b62cb78
Author: Miaohe Lin <linmiaohe@xxxxxxxxxx>
Date:   Wed Jun 30 18:47:57 2021 -0700

    mm/huge_memory.c: don't discard hugepage if other processes are mapping it
    
    [ Upstream commit babbbdd08af98a59089334eb3effbed5a7a0cf7f ]
    
    If other processes are mapping any other subpages of the hugepage, i.e.
    in pte-mapped thp case, page_mapcount() will return 1 incorrectly.  Then
    we would discard the page while other processes are still mapping it.  Fix
    it by using total_mapcount() which can tell whether other processes are
    still mapping it.
    
    Link: https://lkml.kernel.org/r/20210511134857.1581273-6-linmiaohe@xxxxxxxxxx
    Fixes: b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called")
    Reviewed-by: Yang Shi <shy828301@xxxxxxxxx>
    Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
    Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx>
    Cc: "Aneesh Kumar K . V" <aneesh.kumar@xxxxxxxxxxxxx>
    Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx>
    Cc: David Hildenbrand <david@xxxxxxxxxx>
    Cc: Hugh Dickins <hughd@xxxxxxxxxx>
    Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
    Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
    Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
    Cc: Minchan Kim <minchan@xxxxxxxxxx>
    Cc: Ralph Campbell <rcampbell@xxxxxxxxxx>
    Cc: Rik van Riel <riel@xxxxxxxxxxx>
    Cc: Song Liu <songliubraving@xxxxxx>
    Cc: William Kucharski <william.kucharski@xxxxxxxxxx>
    Cc: Zi Yan <ziy@xxxxxxxxxx>
    Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 2496f787a829..8857ef1543eb 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1613,7 +1613,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 	 * If other processes are mapping this page, we couldn't discard
 	 * the page unless they all do MADV_FREE so let's skip the page.
 	 */
-	if (page_mapcount(page) != 1)
+	if (total_mapcount(page) != 1)
 		goto out;
 
 	if (!trylock_page(page))



[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