[LTP] [PATCH 01/29] Hugetlb: Migrating libhugetlbfs brk_near_huge
Li Wang
liwang@redhat.com
Mon Oct 17 12:20:15 CEST 2022
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
> +};
>
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20221017/42a87d59/attachment.htm>
More information about the ltp
mailing list