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
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
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.
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_