RFR: 8273872: ZGC: Explicitly use 2M large pages [v4]

Thomas Schatzl tschatzl at openjdk.java.net
Thu Sep 16 13:51:46 UTC 2021


On Thu, 16 Sep 2021 09:35:22 GMT, Per Liden <pliden at openjdk.org> wrote:

>> src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp line 210:
>> 
>>> 208: 
>>> 209:   // Create file
>>> 210:   const int extra_flags = ZLargePages::is_explicit() ? (MFD_HUGETLB | MFD_HUGE_2MB) : 0;
>> 
>> Potentially the use of the constant `MFD_HUGE_2MB` could be generalized a little and calculated from a required page size like we do in `Linux::commit_memory_special` via a helper function like `os::Linux::hugetlbfs_page_size_flag`; at least that extra flag just looks like it is actually generated the same way. Looking through `memfd.h` it is *exactly* the same as for the corresponding `HUGETLB_*` flags.
>> But since this is really ZGC specific code, up to you.
>
> I don't think we should be passing `MAP_*` flags to `memfd_create()` as there's no guarantee that `MAP_HUGE_2MB` and `MFD_HUGE_2MB` are the same values. It's more of a lucky/convenient implementation detail that they happen to be the same.

The manpages explicitly mention that the calculation is the same:
>       MFD_HUGE_2MB, MFD_HUGE_1GB, ...
>            Used in conjunction with MFD_HUGETLB to select alternative
>            hugetlb page sizes (respectively, 2 MB, 1 GB, ...)  on
>            systems that support multiple hugetlb page sizes.
>            Definitions for known huge page sizes are included in the
>            header file <linux/memfd.h>.
>
>            For details on encoding huge page sizes not included in
>            the header file, see the discussion of the similarly named
>            constants in mmap(2).

I.e. this is specified that way.

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

PR: https://git.openjdk.java.net/jdk/pull/5541


More information about the hotspot-dev mailing list