mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

Check the default huge page size for Linux

Open hankluo6 opened this issue 4 years ago • 2 comments

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.

hankluo6 avatar Jun 27 '21 15:06 hankluo6

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.

daanx avatar Oct 19 '21 17:10 daanx

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

scottlamb avatar Apr 04 '25 16:04 scottlamb