lkml.org 
[lkml]   [2020]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v6 38/51] mm: Fix total_mapcount assumption of page size
    Date
    From: "Kirill A. Shutemov" <kirill@shutemov.name>

    File THPs may now be of arbitrary order.

    Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    ---
    mm/huge_memory.c | 9 +++++----
    1 file changed, 5 insertions(+), 4 deletions(-)

    diff --git a/mm/huge_memory.c b/mm/huge_memory.c
    index 80fb38e93837..744863aa0374 100644
    --- a/mm/huge_memory.c
    +++ b/mm/huge_memory.c
    @@ -2490,7 +2490,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,

    int total_mapcount(struct page *page)
    {
    - int i, compound, ret;
    + int i, compound, nr, ret;

    VM_BUG_ON_PAGE(PageTail(page), page);

    @@ -2498,16 +2498,17 @@ int total_mapcount(struct page *page)
    return atomic_read(&page->_mapcount) + 1;

    compound = compound_mapcount(page);
    + nr = compound_nr(page);
    if (PageHuge(page))
    return compound;
    ret = compound;
    - for (i = 0; i < HPAGE_PMD_NR; i++)
    + for (i = 0; i < nr; i++)
    ret += atomic_read(&page[i]._mapcount) + 1;
    /* File pages has compound_mapcount included in _mapcount */
    if (!PageAnon(page))
    - return ret - compound * HPAGE_PMD_NR;
    + return ret - compound * nr;
    if (PageDoubleMap(page))
    - ret -= HPAGE_PMD_NR;
    + ret -= nr;
    return ret;
    }

    --
    2.26.2
    \
     
     \ /
      Last update: 2020-06-10 22:15    [W:6.545 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site