Skip to content

Check the default huge page size for Linux #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

hankluo6
Copy link
Contributor

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.

In Linux, we can read `/proc/meminfo` to get the huge page size.
@daanx
Copy link
Collaborator

daanx commented Oct 19, 2021

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.

@scottlamb
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants