[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240626043240.1156168-1-ranxiaokai627@163.com>
Date: Wed, 26 Jun 2024 04:32:40 +0000
From: ran xiaokai <ranxiaokai627@....com>
To: ziy@...dia.com
Cc: yang.yang29@....com.cn,
si.hao@....com.cn,
akpm@...ux-foundation.org,
baohua@...nel.org,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
peterx@...hat.com,
ran.xiaokai@....com.cn,
ranxiaokai627@....com,
ryan.roberts@....com,
svetly.todorov@...verge.com,
vbabka@...e.cz,
willy@...radead.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.
I see, the THP naming implies userspace memory. Not only compound order.
> >
> > 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.
yes, will fix.
>
> > 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.
thanks, will fix.
>
> > + 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
Powered by blists - more mailing lists