When committing memory, if we use THPs, we madvise the kernel about THP usage.
See os::pd_realign_memory():
```
if (UseTransparentHugePages && alignment_hint > vm_page_size()) {
// We don't check the return value: madvise(MADV_HUGEPAGE) may not
// be supported or the memory may already be backed by huge pages.
::madvise(addr, bytes, MADV_HUGEPAGE);
}
```
That madvise call is unnecessary if on the system side we are in THP "always" mode, since khugepaged will form THPs regardless of what we advise him to do, so that is an unnecessary system call and can be avoided.
See os::pd_realign_memory():
```
if (UseTransparentHugePages && alignment_hint > vm_page_size()) {
// We don't check the return value: madvise(MADV_HUGEPAGE) may not
// be supported or the memory may already be backed by huge pages.
::madvise(addr, bytes, MADV_HUGEPAGE);
}
```
That madvise call is unnecessary if on the system side we are in THP "always" mode, since khugepaged will form THPs regardless of what we advise him to do, so that is an unnecessary system call and can be avoided.