[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHbLzkrYqKw+iF_+sDccyBEAsRySTPKyhd01p9f6KV0FLLAbnQ@mail.gmail.com>
Date: Tue, 27 Apr 2021 14:22:48 -0700
From: Yang Shi <shy828301@...il.com>
To: Miaohe Lin <linmiaohe@...wei.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Zi Yan <ziy@...dia.com>,
william.kucharski@...cle.com, Matthew Wilcox <willy@...radead.org>,
Yang Shi <yang.shi@...ux.alibaba.com>,
aneesh.kumar@...ux.ibm.com, Ralph Campbell <rcampbell@...dia.com>,
Song Liu <songliubraving@...com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Rik van Riel <riel@...riel.com>,
Johannes Weiner <hannes@...xchg.org>,
Minchan Kim <minchan@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux MM <linux-mm@...ck.org>
Subject: Re: [PATCH 5/5] mm/huge_memory.c: don't discard hugepage if other
processes are mapping it
On Tue, Apr 27, 2021 at 6:32 AM Miaohe Lin <linmiaohe@...wei.com> wrote:
>
> 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.
Seems correct to me. It is possible that the THP is PTE-mapped by the
other processes.
Reviewed-by: Yang Shi <shy828301@...il.com>
>
> Fixes: b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called")
> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
> ---
> mm/huge_memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index f652be6ecca3..d14fecb8cd00 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1604,7 +1604,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))
> --
> 2.23.0
>
>
Powered by blists - more mailing lists