It appears that some BSD systems have a superpage size of 2MB while others have 4MB. I've not seen any others. Is there any way to tell what the available superpage size is? Ideally from the command line, and without having to enable them.


Alan L. Cox made some interesting Opteron benchmarks and was co-author of the original superpage paper (presented at Usenix 2002): Practical, transparent operating system support for superpages

Superpages was introduced in 2013 for FreeBSD 7.2 for amd64 and i386

[amd64, i386] The FreeBSD virtual memory subsystem now supports fully transparent use of superpages for application memory; application memory pages are dynamically promoted to or demoted from superpages without any modification to application code. This change offers the benefit of large page sizes such as improved virtual memory efficiency and reduced TLB (translation lookaside buffer) misses without downsides like application changes and virtual memory inflexibility. This is disabled by default and can be enabled by setting a loader tunable vm.pmap.pg_ps_enabled to 1.

In 2014 it was added to FreeBSD 10.0 for ARMv6/v7. It supports 4KB and 1MB pages dynamicly. Revision 25418 states that vm.pmap.sp_enabled is used (set in loader.conf). If you are not using loader then find it in sys/arm/arm/pmap-v6.c. There is a nice BSDcan presentation by Zbigniew Bodek: Transparent Superpages Support for FreeBSD on ARM

You check it using sysctl:

$ uname -rm
11.2-STABLE amd64
$ sysctl vm.pmap.pg_ps_enabled
vm.pmap.pg_ps_enabled: 1

Linux got huge page (superpage) support in 2011 with kernel version 2.6.38. See also Huge pages Introduction. On Linux (only!) this is handled by hugeadm as hinted in another answer.

As for OS X I think it is enabled by default but I am in no way an authorative source on this. It seems that when they test they simply try to allocate the superpages. I see no check if superpages are enabled or not.

  • This is about enabling superpages, which is not the same as finding out how big they are. – OrangeDog Feb 13 at 10:40
  • 1
    You are not in control of that. Read the release quote: It is transparent and handled dynamicly. Ideal page sizes are closely related to the architecture. The memory space must be contigous and you have no guarantee of that. This is handled by the system (and should be!). I would then ask another question where you clarify why it really is important to you. But at least I have a hard time thinking up those cases. – Claus Andersen Feb 13 at 10:47
  • Your own links show that mach's mmap allows you to request a specific superpage size. All I want to know is a convenient way to list the available sizes. – OrangeDog Feb 13 at 10:52
  • 1
    I only mentioned for arm. For amd64 it uses 4 KB, 2 MB and 1 GB as needed and if possible. If the memory map is fragmented - then you will get small pages. If not - then a larger. You only want the memory if it is non-fragmented? To me it reads as you are trying to outsmart the OS. Again - I would recommend a separate question to outline what you are trying to accomplish. To me you are going about this wrong. Hence I recommend another question. If not - sit back and wait - maybe you get a better answer to this one ;-) – Claus Andersen Feb 13 at 11:05
  • 1
    Good luck with that condescending attitude. I hope you are more personal IRL. I choose not to participate in this anymore. – Claus Andersen Feb 13 at 11:20

For the XNU and Mach kernels (MacOS/Darwin), if I'm reading the headers right, on x86_64 it's always 2MB, otherwise it's not supported.

To do this dynamically you have to do something like:

echo "#include <mach/vm_statistics.h>" | gcc -dM -E - | grep VM_FLAGS_SUPERPAGE_SIZE_

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.