Skip to content

Commit 8cd2e0f

Browse files
jaokimkstefanj
authored andcommittedNov 25, 2020
8243315: ParallelScavengeHeap::initialize() passes GenAlignment as page size to os::trace_page_sizes instead of actual page size
Reviewed-by: sjohanss, tschatzl
1 parent cdb41ba commit 8cd2e0f

7 files changed

+120
-28
lines changed
 

‎src/hotspot/share/gc/g1/g1CollectedHeap.cpp

+2-21
Original file line numberDiff line numberDiff line change
@@ -1476,32 +1476,13 @@ G1CollectedHeap::G1CollectedHeap() :
14761476
guarantee(_task_queues != NULL, "task_queues allocation failure.");
14771477
}
14781478

1479-
static size_t actual_reserved_page_size(ReservedSpace rs) {
1480-
size_t page_size = os::vm_page_size();
1481-
if (UseLargePages) {
1482-
// There are two ways to manage large page memory.
1483-
// 1. OS supports committing large page memory.
1484-
// 2. OS doesn't support committing large page memory so ReservedSpace manages it.
1485-
// And ReservedSpace calls it 'special'. If we failed to set 'special',
1486-
// we reserved memory without large page.
1487-
if (os::can_commit_large_page_memory() || rs.special()) {
1488-
// An alignment at ReservedSpace comes from preferred page size or
1489-
// heap alignment, and if the alignment came from heap alignment, it could be
1490-
// larger than large pages size. So need to cap with the large page size.
1491-
page_size = MIN2(rs.alignment(), os::large_page_size());
1492-
}
1493-
}
1494-
1495-
return page_size;
1496-
}
1497-
14981479
G1RegionToSpaceMapper* G1CollectedHeap::create_aux_memory_mapper(const char* description,
14991480
size_t size,
15001481
size_t translation_factor) {
15011482
size_t preferred_page_size = os::page_size_for_region_unaligned(size, 1);
15021483
// Allocate a new reserved space, preferring to use large pages.
15031484
ReservedSpace rs(size, preferred_page_size);
1504-
size_t page_size = actual_reserved_page_size(rs);
1485+
size_t page_size = ReservedSpace::actual_reserved_page_size(rs);
15051486
G1RegionToSpaceMapper* result =
15061487
G1RegionToSpaceMapper::create_mapper(rs,
15071488
size,
@@ -1593,7 +1574,7 @@ jint G1CollectedHeap::initialize() {
15931574
_hot_card_cache = new G1HotCardCache(this);
15941575

15951576
// Create space mappers.
1596-
size_t page_size = actual_reserved_page_size(heap_rs);
1577+
size_t page_size = ReservedSpace::actual_reserved_page_size(heap_rs);
15971578
G1RegionToSpaceMapper* heap_storage =
15981579
G1RegionToSpaceMapper::create_mapper(heap_rs,
15991580
heap_rs.size(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
#include "precompiled.hpp"
26+
#include "gc/parallel/parallelInitLogger.hpp"
27+
#include "gc/shared/genArguments.hpp"
28+
#include "gc/shared/gcLogPrecious.hpp"
29+
30+
void ParallelInitLogger::print_heap() {
31+
log_info_p(gc, init)("Alignments:"
32+
" Space " SIZE_FORMAT "%s,"
33+
" Generation " SIZE_FORMAT "%s,"
34+
" Heap " SIZE_FORMAT "%s",
35+
byte_size_in_exact_unit(SpaceAlignment), exact_unit_for_byte_size(SpaceAlignment),
36+
byte_size_in_exact_unit(GenAlignment), exact_unit_for_byte_size(GenAlignment),
37+
byte_size_in_exact_unit(HeapAlignment), exact_unit_for_byte_size(HeapAlignment));
38+
GCInitLogger::print_heap();
39+
}
40+
41+
void ParallelInitLogger::print() {
42+
ParallelInitLogger init_log;
43+
init_log.print_all();
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
#ifndef SHARE_GC_PARALLEL_PARALLELINITLOGGER_HPP
26+
#define SHARE_GC_PARALLEL_PARALLELINITLOGGER_HPP
27+
28+
#include "gc/shared/gcInitLogger.hpp"
29+
30+
class ParallelInitLogger : public GCInitLogger {
31+
protected:
32+
virtual void print_heap();
33+
public:
34+
static void print();
35+
};
36+
37+
#endif //SHARE_GC_PARALLEL_PARALLELINITLOGGER_HPP

‎src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "code/codeCache.hpp"
2727
#include "gc/parallel/parallelArguments.hpp"
2828
#include "gc/parallel/objectStartArray.inline.hpp"
29+
#include "gc/parallel/parallelInitLogger.hpp"
2930
#include "gc/parallel/parallelScavengeHeap.inline.hpp"
3031
#include "gc/parallel/psAdaptiveSizePolicy.hpp"
3132
#include "gc/parallel/psMemoryPool.hpp"
@@ -63,12 +64,7 @@ jint ParallelScavengeHeap::initialize() {
6364

6465
ReservedHeapSpace heap_rs = Universe::reserve_heap(reserved_heap_size, HeapAlignment);
6566

66-
os::trace_page_sizes("Heap",
67-
MinHeapSize,
68-
reserved_heap_size,
69-
GenAlignment,
70-
heap_rs.base(),
71-
heap_rs.size());
67+
trace_actual_reserved_page_size(reserved_heap_size, heap_rs);
7268

7369
initialize_reserved_region(heap_rs);
7470

@@ -133,7 +129,7 @@ jint ParallelScavengeHeap::initialize() {
133129
return JNI_ENOMEM;
134130
}
135131

136-
GCInitLogger::print();
132+
ParallelInitLogger::print();
137133

138134
return JNI_OK;
139135
}
@@ -739,6 +735,19 @@ void ParallelScavengeHeap::verify(VerifyOption option /* ignored */) {
739735
}
740736
}
741737

738+
void ParallelScavengeHeap::trace_actual_reserved_page_size(const size_t reserved_heap_size, const ReservedSpace rs) {
739+
// Check if Info level is enabled, since os::trace_page_sizes() logs on Info level.
740+
if(log_is_enabled(Info, pagesize)) {
741+
const size_t page_size = ReservedSpace::actual_reserved_page_size(rs);
742+
os::trace_page_sizes("Heap",
743+
MinHeapSize,
744+
reserved_heap_size,
745+
page_size,
746+
rs.base(),
747+
rs.size());
748+
}
749+
}
750+
742751
void ParallelScavengeHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
743752
const PSHeapSummary& heap_summary = create_ps_heap_summary();
744753
gc_tracer->report_gc_heap_summary(when, heap_summary);

‎src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ParallelScavengeHeap : public CollectedHeap {
7777

7878
virtual void initialize_serviceability();
7979

80+
void trace_actual_reserved_page_size(const size_t reserved_heap_size, const ReservedSpace rs);
8081
void trace_heap(GCWhen::Type when, const GCTracer* tracer);
8182

8283
protected:

‎src/hotspot/share/memory/virtualspace.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,24 @@ size_t ReservedSpace::allocation_align_size_up(size_t size) {
286286
return align_up(size, os::vm_allocation_granularity());
287287
}
288288

289+
size_t ReservedSpace::actual_reserved_page_size(const ReservedSpace& rs) {
290+
size_t page_size = os::vm_page_size();
291+
if (UseLargePages) {
292+
// There are two ways to manage large page memory.
293+
// 1. OS supports committing large page memory.
294+
// 2. OS doesn't support committing large page memory so ReservedSpace manages it.
295+
// And ReservedSpace calls it 'special'. If we failed to set 'special',
296+
// we reserved memory without large page.
297+
if (os::can_commit_large_page_memory() || rs.special()) {
298+
// An alignment at ReservedSpace comes from preferred page size or
299+
// heap alignment, and if the alignment came from heap alignment, it could be
300+
// larger than large pages size. So need to cap with the large page size.
301+
page_size = MIN2(rs.alignment(), os::large_page_size());
302+
}
303+
}
304+
305+
return page_size;
306+
}
289307

290308
void ReservedSpace::release() {
291309
if (is_reserved()) {

‎src/hotspot/share/memory/virtualspace.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class ReservedSpace {
9696
bool contains(const void* p) const {
9797
return (base() <= ((char*)p)) && (((char*)p) < (base() + size()));
9898
}
99+
100+
static size_t actual_reserved_page_size(const ReservedSpace& rs);
99101
};
100102

101103
ReservedSpace

0 commit comments

Comments
 (0)
Please sign in to comment.