RFR: 8285979: G1: G1SegmentedArraySegment::header_size() is incorrect since JDK-8283368 [v2]
Ivan Walulya
iwalulya at openjdk.java.net
Mon May 2 12:06:46 UTC 2022
On Mon, 2 May 2022 10:48:43 GMT, Jie Fu <jiefu at openjdk.org> wrote:
>> Hi all,
>>
>> `G1SegmentedArraySegment::header_size()` is incorrect if `DEFAULT_CACHE_LINE_SIZE <= 32`.
>> This bug can be easily reproduced by running `gc/g1` with VM configured and built with `--with-jvm-features=-compiler2`.
>>
>> The reason is that there are paddings in the layout of `G1SegmentedArraySegment`.
>>
>> const uint _slot_size; // offset 0-byte
>> const uint _num_slots; // offset 4-byte
>> const MEMFLAGS _mem_flag; // offset 8-byte
>> // --- padding 4 bytes
>> G1SegmentedArraySegment* volatile _next; // offset 16-byte
>> uint volatile _next_allocate; // offset 24
>> // --- padding 4 bytes
>> char* _bottom; // offset 32-byte
>>
>>
>> So if we calculate `header_size()` like this, it will return 32 bytes when `DEFAULT_CACHE_LINE_SIZE=32`, which should be at least 40 bytes actually.
>>
>> static size_t header_size() { return align_up(offset_of(G1SegmentedArraySegment, _bottom) + sizeof(_bottom), DEFAULT_CACHE_LINE_SIZE); }
>>
>>
>> Two changes are made in this patch:
>> - Fix the implementation of `header_size()`.
>> - Fix the layout of `G1SegmentedArraySegment` to eliminate paddings.
>>
>> Testing:
>> - tier1~3 on Linux/x64, no regression
>> - gc/g1 with `--with-jvm-features=-compiler2` on Linux/x64, all passed
>>
>> Thanks.
>> Best regards,
>> Jie
>
> Jie Fu has updated the pull request incrementally with one additional commit since the last revision:
>
> Address review comment
Marked as reviewed by iwalulya (Reviewer).
-------------
PR: https://git.openjdk.java.net/jdk/pull/8494
More information about the hotspot-gc-dev
mailing list