#define _GNU_SOURCE #include <sys/mman.h> #include <linux/memfd.h> #include <unistd.h> #include <stddef.h> int main(int ac, char** av) { size_t memsz = (size_t)2048 << 20; int fd = memfd_create("memory", MFD_CLOEXEC); ftruncate(fd, memsz); void* p = mmap((void*)0x40000000, memsz, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FILE, fd, 0); madvise(p, memsz, MADV_HUGEPAGE); madvise(p, memsz, MADV_POPULATE_WRITE); madvise(p, memsz, MADV_COLLAPSE); pause(); return 0; } While memfd is documented as using anonymous pages, AnonHugePages shows as zero. If memfd incompatible with transparent hugepages?