Skip to content
Advertisement

Can I use 1G superpages to back shared mmaps?

So far when I’ve tried using a file in /mnt/hugepages1G/ as the backing I get segfaults. It works fine if I use 2M superpages in /mnt/hugepages/

I think I read somewhere that I now can’t find that Linux only supports 2M pages for Shared memory? But I can’t swear to it. Can’t find it in documentation.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/vm/hugetlbpage.txt?id=HEAD

$ hugeadm –pool-list claims to have pages of both 2M and 1G

The mount commands were successful.

Advertisement

Answer

For the next poor bozo:

You definitely can use 1G superpages to back shared mmaps on x86-64 linux.

I got bytes transferred between processes accross a 1G file in /mnt/hugepages1G properly configured and mounted, working with a distro (ubu) 4.4 kernel. It’s more fragile in the sense of it being more difficult to get the code right or you get SIGBUS etc. length parameter and ftruncate size of the mapped region seem to need to be multiples of the page size when the page size is 1G – at least I think that’s what is making it work. No documentation to support it, and the man page says it needn’t be (but may not have superpages in mind).

The best documentation is here: https://lwn.net/Articles/375096/

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement