[LTP] [PATCH 09/29] Hugetlb: Migrating libhugetlbfs fork-cow
Li Wang
liwang@redhat.com
Tue Oct 18 08:56:43 CEST 2022
Tarun Sahu <tsahu@linux.ibm.com> wrote:
> +static void run_test(void)
> +{
> + int status;
> + void *syncarea;
> + volatile unsigned int *p;
> + volatile unsigned int *trigger, *child_readback;
> + int parent_readback;
> + pid_t pid;
> + struct sigaction sa = {
> + .sa_sigaction = sigchld_handler,
> + .sa_flags = SA_SIGINFO,
> + };
> +
> + /* Get a shared normal page for synchronization */
> + if (verbose)
> + tst_res(TINFO, "Mapping synchronization area..");
> + syncarea = SAFE_MMAP(NULL, getpagesize(), PROT_READ|PROT_WRITE,
> + MAP_SHARED|MAP_ANONYMOUS, -1, 0);
> + if (verbose)
> + tst_res(TINFO, "done");
> +
> + trigger = syncarea;
> + *trigger = 0;
> +
> + child_readback = trigger + 1;
> + *child_readback = 0;
> +
> + fd = SAFE_OPEN(hfile, O_RDWR | O_CREAT, 0600);
> + SAFE_UNLINK(hfile);
> +
> + if (verbose)
> + tst_res(TINFO, "Mapping hugepage area...");
> + p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
> fd, 0);
>
After roughly looking at those hpage testcases, almost each one
requests the huge memory via mapping a file on hugetlbfs, which
can work but quite don't have to.
We can absolutely simplify them via `MAP_HUGETLB` to get expected
size of huge memory for use.
Reference how hugemamp06.c does:
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c#L71
+static void setup(void)
> +{
> + int free_pages = SAFE_READ_MEMINFO("HugePages_Free:");
> +
> + if (tst_hugepages < 2 || free_pages < 2)
> + tst_brk(TCONF, "Not enough hugepages for testing.");
>
> +
> + if (!Hopt)
> + Hopt = tst_get_tmpdir();
> + SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);
> +
> + snprintf(hfile, sizeof(hfile), "%s/ltp_hugetlbfile%d", Hopt,
> getpid());
>
If we go using MAP_HUGETLB above, those lines can be removed.
> + hpage_size = SAFE_READ_MEMINFO("Hugepagesize:")*1024;
> +}
>
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20221018/efebd233/attachment.htm>
More information about the ltp
mailing list