[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D29M7U8SPSYJ.39VMTRSKXW140@nvidia.com>
Date: Tue, 25 Jun 2024 23:06:25 -0400
From: "Zi Yan" <ziy@...dia.com>
To: "ran xiaokai" <ranxiaokai627@....com>, <akpm@...ux-foundation.org>,
<willy@...radead.org>
Cc: <vbabka@...e.cz>, <svetly.todorov@...verge.com>,
<ran.xiaokai@....com.cn>, <baohua@...nel.org>, <ryan.roberts@....com>,
<peterx@...hat.com>, <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH 2/2] kpageflags: fix wrong KPF_THP on non-pmd-mappable
compound pages
On Tue Jun 25, 2024 at 10:49 PM EDT, ran xiaokai wrote:
> From: Ran Xiaokai <ran.xiaokai@....com.cn>
>
> KPF_COMPOUND_HEAD and KPF_COMPOUND_TAIL are set on "common" compound
> pages, which means of any order, but KPF_THP should only be set
> when the folio is a 2M pmd mappable THP. Since commit 19eaf44954df
> ("mm: thp: support allocation of anonymous multi-size THP"),
> multiple orders of folios can be allocated and mapped to userspace,
> so the folio_test_large() check is not sufficient here,
> replace it with folio_test_pmd_mappable() to fix this.
>
> Also kpageflags is not only for userspace memory but for all valid pfn
> pages,including slab pages or drivers used pages, so the PG_lru and
> is_anon check are unnecessary here.
But THP is userspace memory. slab pages or driver pages cannot be THP.
>
> Signed-off-by: Ran Xiaokai <ran.xiaokai@....com.cn>
> ---
> fs/proc/page.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/fs/proc/page.c b/fs/proc/page.c
> index 2fb64bdb64eb..3e7b70449c2f 100644
> --- a/fs/proc/page.c
> +++ b/fs/proc/page.c
> @@ -146,19 +146,13 @@ u64 stable_page_flags(const struct page *page)
> u |= kpf_copy_bit(k, KPF_COMPOUND_HEAD, PG_head);
> else
> u |= 1 << KPF_COMPOUND_TAIL;
> +
Unnecessary new line.
> if (folio_test_hugetlb(folio))
> u |= 1 << KPF_HUGE;
> - /*
> - * We need to check PageLRU/PageAnon
> - * to make sure a given page is a thp, not a non-huge compound page.
> - */
> - else if (folio_test_large(folio)) {
> - if ((k & (1 << PG_lru)) || is_anon)
> - u |= 1 << KPF_THP;
> - else if (is_huge_zero_folio(folio)) {
> + else if (folio_test_pmd_mappable(folio)) {
> + u |= 1 << KPF_THP;
lru and anon check should stay.
> + if (is_huge_zero_folio(folio))
> u |= 1 << KPF_ZERO_PAGE;
> - u |= 1 << KPF_THP;
> - }
> } else if (is_zero_pfn(page_to_pfn(page)))
> u |= 1 << KPF_ZERO_PAGE;
>
--
Best Regards,
Yan, Zi
Download attachment "signature.asc" of type "application/pgp-signature" (855 bytes)
Powered by blists - more mailing lists