// SPDX-License-Identifier: GPL-2.0 /* * hugepage-mremap: * * Example of remapping huge page memory in a user application using the * mremap system call. The path to a file in a hugetlbfs filesystem must * be passed as the last argument to this test. The amount of memory used * by this test in MBs can optionally be passed as an argument. If no memory * amount is passed, the default amount is 10MB. * * To make sure the test triggers pmd sharing and goes through the 'unshare' * path in the mremap code use 1GB (1024) or more.
*/
/* Create a private anonymous mapping. The memory will be * demand-zero paged--that is, not yet allocated. When we * actually touch the memory, it will be allocated via * the userfaultfd.
*/
ksft_print_msg("Address returned by mmap() = %p\n", addr);
/* Register the memory range of the mapping we just created for * handling by the userfaultfd object. In mode, we request to track * missing pages (i.e., pages that have not yet been faulted in).
*/ if (uffd_register(uffd, addr, len, true, false, false))
ksft_exit_fail_msg("ioctl-UFFDIO_REGISTER: %s\n", strerror(errno));
}
int main(int argc, char *argv[])
{
size_t length = 0; int ret = 0, fd;
/* Read memory length as the first arg if valid, otherwise fallback to * the default length.
*/ if (argc >= 2)
length = (size_t)atoi(argv[1]); else
length = DEFAULT_LENGTH_MB;
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.