RFR: 8236569: -Xss not multiple of 4K does not work for the main thread on macOS [v5]

Henry Jen henryjen at openjdk.java.net
Tue Jun 8 16:48:19 UTC 2021


On Tue, 8 Jun 2021 08:17:54 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Henry Jen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
>> 
>>  - Cast type
>>  - Merge
>>  - Change java -X output for -Xss
>>  - Merge
>>  - Only try to round-up when current value failed
>>  - Avoid overflow on page size
>>  - JDK-8236569: -Xss not multiple of 4K does not work for the main thread on macOS
>
> src/java.base/unix/native/libjli/java_md.c line 666:
> 
>> 664:         return page_size * pages;
>> 665:     }
>> 666: }
> 
> Could probably be shortened to something like this:
> 
> 
> size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
> return (stack_size + (pagesize - 1)) & ~(pagesize - 1);
> 
> 
> or, if you insist on checking for SIZE_MAX:
> 
> 
> size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
> size_t max = SIZE_MAX - pagesize;
> return stack_size <= max ? (stack_size + (pagesize - 1)) & ~(pagesize - 1) : max;
> 
> 
> (I see David requested this, so this is fine, though passing SIZE_MAX to this function will quite likely fail anyway :)

While sysconf(_SC_PAGESIZE) is most likely(if not always) be power of 2, it's not a constant we know for sure here and this is not critical path for performance, thus I didn't take that approach.

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

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


More information about the core-libs-dev mailing list