// SPDX-License-Identifier: GPL-2.0 /* * A test case of using hugepage memory in a user application using the * mmap system call with MAP_HUGETLB flag. Before running this program * make sure the administrator has allocated enough default sized huge * pages to cover the 2 MB allocation.
*/ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <sys/mman.h> #include <fcntl.h> #include"vm_util.h"
/* * 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 < maplength / pagesize; 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;
}
}
close(fd);
return 0;
}
int main(int argc, char **argv)
{ void *addr; unsignedlong pfn;
pagesize = psize();
maplength = default_huge_page_size(); if (!maplength) {
printf("Unable to determine huge page size\n"); exit(1);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.