Re: [PATCH RESEND v2 4/4] selftests: vm: add a hugetlb test case
From: Muchun Song
Date: Mon Sep 20 2021 - 10:26:43 EST
On Sat, Sep 18, 2021 at 1:20 PM Barry Song <21cnbao@xxxxxxxxx> wrote:
>
> On Sat, Sep 18, 2021 at 12:08 AM Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
> >
> > Since the head vmemmap page frame associated with each HugeTLB page is
> > reused, we should hide the PG_head flag of tail struct page from the
> > user. Add a tese case to check whether it is work properly.
> >
>
> TBH, I am a bit confused. I was thinking about some kernel unit tests to make
> sure those kernel APIs touched by this patchset are still working as before.
> This userspace test, while certainly useful for checking the content of page
> frames as expected, doesn't directly prove things haven't changed.
>
> In patch 1/4, a couple of APIs have the fixup for the fake head issue.
> Do you think a test like the below would be more sensible?
> 1. alloc 2MB hugeTLB
It is done in main().
> 2. get each page frame
> 3. apply those APIs in each page frame
> 4. Those APIs work completely the same as before.
Reading the flags of a page by /proc/kpageflags is done
in stable_page_flags(), which has invoked PageHead(),
PageTail(), PageCompound() and compound_head().
If those APIs work properly, the head page must have
15 and 17 bits set. And tail pages must have 16 and 17
bits set but 15 unset.
So I think check_page_flags() has done the step 2 to 4.
What do you think?
Thanks.