Check the default huge page size for Linux
In Linux, we can read /proc/meminfo to get the huge page size.
Please node that this will get only one possible size, but Linux can supports more than one huge page size.
Thanks for the PR! and apologies for being so late addressing this :-(. But yikes -- this is so fragile; very hesitant to include this ... it may be the only way to get the large page size though so perhaps it is what it is :-). I need to think a bit more on this.
I believe there's another interface that requires less parsing, described here:
Some userspace (such as a test program, or an optimized memory allocation library) may want to know the size (in bytes) of a PMD-mappable transparent hugepage:
cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_size
On my system:
$ uname -a
Linux slamb-workstation 6.11.0-19-generic #19~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 17 11:51:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_size
2097152