[LTP] [PATCH 01/29] Hugetlb: Migrating libhugetlbfs brk_near_huge

Tarun Sahu tsahu@linux.ibm.com
Tue Oct 18 09:36:25 CEST 2022


Hi Li, 
Thanks for reviewing the patch.

I will update it to TST_NEEDS
wherever required in other tests
too. Thanks for pointing it.

On Mon,
2022-10-17 at 18:20 +0800, Li Wang wrote:
> This Message Is From an External Sender
> This message came from outside your organization.       
> Tarun Sahu <tsahu@linux.ibm.com> wrote:
> 
>  
> > +
> > +static void setup(void)
> > +{
> > +       if (tst_hugepages < 1)
> > +               tst_brk(TCONF, "Not enough hugepages for
> > testing.");
> 
> 
> If we needs at least 1 huge page for testing, the TST_NEEDS will
> be more useful than TST_REQUEST, and do not need to double
> check the hpage numbers anymore.
> 
> 
> TST_REQUEST:
>   It will try the best to reserve available huge pages and return the
> number
>   of available hugepages in tst_hugepages, which may be 0 if
> hugepages are
>   not supported at all.
> 
> TST_NEEDS:
>   This is an enforced requirement, LTP should strictly do hpages
> applying and
>   guarantee the 'HugePages_Free' no less than pages which makes that
> test can
>   use these specified numbers correctly. Otherwise, test exits with
> TCONF if
>   the attempt to reserve hugepages fails or reserves less than
> requested.
> 
> See: 
> https://github.com/linux-test-project/ltp/blob/master/doc/c-test-api.txt#L2009
> 
>  
> > +
> > +       if (!Hopt)
> > +               Hopt = tst_get_tmpdir();
> > +       SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
> > +
> > +       snprintf(hfile, sizeof(hfile), "%s/ltp_hugetlbfile%d",
> > Hopt, getpid());
> > +       hpage_size = SAFE_READ_MEMINFO("Hugepagesize:")*1024;
> > +}
> > +
> > +static void cleanup(void)
> > +{
> > +       if (fd >= 0)
> > +               SAFE_CLOSE(fd);
> > +       umount2(Hopt, MNT_DETACH);
> > +}
> > +
> > +static struct tst_test test = {
> > +       .needs_root = 1,
> > +       .needs_tmpdir = 1,
> > +       .options = (struct tst_option[]) {
> > +               {"v", &verbose, "Turns on verbose mode"},
> > +               {"H:", &Hopt,   "Location of hugetlbfs, i.e.  -H
> > /var/hugetlbfs"},
> > +               {"s:", &nr_opt, "Set the number of the been
> > allocated hugepages"},
> > +               {}
> > +       },
> > +       .setup = setup,
> > +       .cleanup = cleanup,
> > +       .test_all = run_test,
> > +       .hugepages = {1, TST_REQUEST},
> 
> ^ TST_NEEDS
> 
>  
> > +};
> 
>  
> 



More information about the ltp mailing list