// 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);
}
printf("Returned address is %p whose pfn is %lx\n", addr, pfn);
if (check_page_flags(pfn) < 0) {
munmap(addr, maplength);
perror("check_page_flags"); exit(1);
}
/* munmap() length of MAP_HUGETLB memory must be hugepage aligned */ if (munmap(addr, maplength)) {
perror("munmap"); exit(1);
}
return 0;
}
Messung V0.5 in Prozent
¤ 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.0.15Bemerkung:
(vorverarbeitet am 2026-04-27)
¤
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.