RFR: 8319969: os::large_page_init() turns off THPs for ZGC [v2]
Thomas Stuefe
stuefe at openjdk.org
Mon Dec 4 19:17:48 UTC 2023
On Mon, 4 Dec 2023 09:26:40 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> src/hotspot/os/linux/os_linux.cpp line 3722:
>>
>>> 3720: }
>>> 3721:
>>> 3722: log_warning(pagesize)("UseTransparentHugePages disabled, transparent huge pages are not supported by the operating system.");
>>
>> Would it be not clearer to define when to warn, as we do in warn_no_large_pages?
>>
>> Related to that, should we not warn if ZGC and +shmemthp configured but -anonymous thp? I am not sure the heap is the only part of the JVM that uses THP, and other parts would still use anon THP, or? E.g. Code heap.
>>
>> Also, maybe a better message for the poor admin that tries to setup. E.g.:
>>
>>
>> bool requires_shmem_thp = UseTHP + UseZGC
>> bool requires_anon_thp = UseTHP
>> bool off = false;
>>
>> if (requires_shmem && !shmem configured)
>> (log_warning "Shmem thp are not supported. Set /sys/kernel/mm/transparent_hugepage/shmem_enabled to advise to support shmem thp")
>> off = true;
>>
>> if (requires_anonthp && !anon_thp configured)
>> (log_warning "anonymous Thp are not supported. Set /sys/kernel/mm/transparent_hugepage/enabled to madvise")
>> off = true;
>>
>> if (off)
>> UseTHP = 0
>> log_warning(UseTHP disabled (see previous messages)
>>
>>
>> if ZGC and !supports shmemthp or
>
>> Would it be not clearer to define when to warn, as we do in warn_no_large_pages?
>
> I don't understand what you are suggesting with this question / request, so I'm not sure exactly what you are looking for. Instead, I made my own version of the pseudo code you posted.
>
> This is the warnings I get with that change:
>
> Without ZGC:
>
> $ thp never never
> always madvise [never]
> always within_size advise [never] deny force
>
> $ java -XX:+UseTransparentHugePages -version
> [0.002s][warning][pagesize] Anonymous transparent huge pages are not enabled in the OS. Set /sys/kernel/mm/transparent_hugepage/enabled to 'madvise' to enable them.
> [0.002s][warning][pagesize] UseTransparentHugePages disabled, transparent huge pages are not supported by the operating system.
> ...
>
> $ thp never advise
> always madvise [never]
> always within_size [advise] never deny force
>
> java -XX:+UseTransparentHugePages -version
> [0.002s][warning][pagesize] Anonymous transparent huge pages are not enabled in the OS. Set /sys/kernel/mm/transparent_hugepage/enabled to 'madvise' to enable them.
> [0.002s][warning][pagesize] UseTransparentHugePages disabled, transparent huge pages are not supported by the operating system.
> ...
>
> $ thp madvise never
> always [madvise] never
> always within_size advise [never] deny force
>
> $ java -XX:+UseTransparentHugePages -version
> ...
>
> $ thp madvise advise
> always [madvise] never
> always within_size [advise] never deny force
> $ java -XX:+UseTransparentHugePages -version
> ...
>
> With ZGC:
>
> $ thp never never
> always madvise [never]
> always within_size advise [never] deny force
>
> $ java -XX:+UseTransparentHugePages -XX:+UseZGC -version
> [0.002s][warning][pagesize] Shared memory transparent huge pages are not enabled in the OS. Set /sys/kernel/mm/transparent_hugepage/shmem_enabled to 'advise' to enable them.
> [0.002s][warning][pagesize] Anonymous transparent huge pages are not enabled in the OS. Set /sys/kernel/mm/transparent_hugepage/enabled to 'madvise' to enable them.
> [0.002s][warning][pagesize] UseTransparentHugePages disabled, transparent huge pages are not supported by the operating system.
> ...
>
> $ thp never advise
> always madvise [never]
> always within_size [advise] never deny force
>
> $ java -XX:+UseTransparentHugePages -XX:+UseZGC -version
> [0.001s][warning][pagesize] Anonymous transparent huge pages are not enabled in the OS. Set /sys/kernel/mm/transparent_hugepage/enabled to 'madvise' to enable them.
> [0.001s][warning][pagesize] UseTransparentHugePages disabled, transparent huge pages are not sup...
I think this is okay, what do you think? Too many messages?
>> src/hotspot/os/linux/os_linux.cpp line 3736:
>>
>>> 3734: ls.print_cr(". Default large page size: " EXACTFMT ".", EXACTFMTARGS(os::large_page_size()));
>>> 3735: } else {
>>> 3736: ls.print("Large page support %sdisabled.", uses_zgc_shmem_thp() ? "partially " : "");
>>
>> I wonder whether we could make our life simpler by not supporting mixes: we could require that for ZGC, to use THP, both shmen and anon thps have to be active. Would that be acceptable or do you think there are too many misconfigured systems out there?
>
> I would prefer to not force users to set both.
Fair enough. It is better to be able to run efficiently on as many configurations as possible.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16690#discussion_r1414366736
PR Review Comment: https://git.openjdk.org/jdk/pull/16690#discussion_r1414367277
More information about the hotspot-dev
mailing list