Hi Sarthak,
On Mon, May 04, 2026 at 05:50:06PM +0530, Sarthak Sharma wrote:
> On 4/29/26 2:12 AM, Mike Rapoport wrote:
> > @@ -141,8 +135,8 @@ int main(void)
> >
> > ksft_print_header();
> >
> > - /* Check if huge pages are free */
> > - if (!hugetlb_free_default_pages())
> > + /* request a huge page */
> > + if (!hugetlb_setup_default(1))
> > ksft_exit_skip("No free hugepage, exiting\n");
>
> Before applying the patch, I get the following output:
>
> TAP version 13
> 1..4
> # No. Free pages before allocation : 112
> # No. Free pages after munmap : 112
> ok 1 free huge pages from 0-12288
> # No. Free pages before allocation : 112
> # No. Free pages after munmap : 112
> ok 2 free huge pages from 0-10240
> # No. Free pages before allocation : 112
> # No. Free pages after munmap : 112
> ok 3 free huge pages from 2048-12288
> # No. Free pages before allocation : 112
> # No. Free pages after munmap : 112
> ok 4 free huge pages from 2048-14336
> # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0
>
> After applying the patch, I get this:
>
> TAP version 13
> # [INFO] detected hugetlb page size: 2048 KiB
> # [INFO] detected hugetlb page size: 32768 KiB
> # [INFO] detected hugetlb page size: 64 KiB
> # [INFO] detected hugetlb page size: 1048576 KiB
> 1..0 # SKIP No free hugepage, exiting
>
> even when I have 112 free and 128 total hugepages of size 2MB (default
> for my system).
>
> Could it be because hugetlb_setup_default(1) here is trying to set the
> default hugetlb pool size to exactly 1, and then checking whether there
> is exactly 1 free hugepage, instead of simply checking whether at least
> 1 free hugepage is available?
I'm going to update hugetlb_setup_default() to check if there are enough
free huge pages and add more if necessary and I will add
hugetlb_setup_default_exact() for tests that require exact number of huge
pages.
> >
> > fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT, 0664);
>
--
Sincerely yours,
Mike.