RFR: 8319969: os::large_page_init() turns off THPs for ZGC [v3]

Stefan Karlsson stefank at openjdk.org
Mon Dec 4 08:26:41 UTC 2023


On Sat, 2 Dec 2023 06:40:55 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> src/hotspot/os/linux/os_linux.cpp line 2886:
>> 
>>> 2884: 
>>> 2885: void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
>>> 2886:   if (HugePages::should_madvise_anonymous_thps() && alignment_hint > vm_page_size()) {
>> 
>> The use of `HugePages::should_madvise_anonymous_thps()` adds a change in behavior. By using it instead of `UseTransparentHugepages`, we only call `madvise` when the OS is configured to care about `madvise`. I've been using this in my testing, but I can revert back to using `UseTransparentHugepages`, and then we can change this separately with [JDK-8312468](https://bugs.openjdk.org/browse/JDK-8312468).
>
> This makes sense. We can close https://bugs.openjdk.org/browse/JDK-8312468 as dup then.
> 
> But why don't you madvise for shmemthp ?

The assumption here is that pd_realign_memory is used for anonymous memory. The madvise for shmemthp is in the ZGC code (which is the only user of shmemthp, AFAIK):

  // Maybe madvise the mapping to use transparent huge pages
  if (os::Linux::should_madvise_shmem_thps()) {
    os::Linux::madvise_transparent_huge_pages(addr, length);
  }

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16690#discussion_r1413517946


More information about the hotspot-dev mailing list