Re: [PATCH RESEND v2 4/4] selftests: vm: add a hugetlb test case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 21, 2021 at 2:26 AM Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
>
> 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?

yes. Thanks for your explanation. thereby, I think we just need some doc
here to explain what it is checking. something like
/*
 * pages other than the first page must be tail and shouldn't be head;
 * this also verifies kernel has correctly set the fake page_head to tail
 * while hugetlb_free_vmemmap is enabled
 */
+       for (i = 1; i < MAP_LENGTH / PAGE_SIZE; i++) {
+               read(fd, &pageflags, sizeof(pageflags));
+               if ((pageflags & TAIL_PAGE_FLAGS) != TAIL_PAGE_FLAGS ||
+                   (pageflags & HEAD_PAGE_FLAGS) == HEAD_PAGE_FLAGS) {
+                       close(fd);
+                       printf("Tail page flags (%lx) is invalid\n", pageflags);
+                       return -1;
+               }
+       }
>
> Thanks.

Thanks
barry



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux