author | kbarrett |
Fri, 22 Mar 2019 15:42:43 -0400 | |
changeset 54255 | c81fbf340ceb |
parent 53116 | bb03098c4dde |
child 54264 | 41af8d0546bc |
permissions | -rw-r--r-- |
26160 | 1 |
/* |
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
26160 | 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" |
|
30764 | 26 |
#include "gc/g1/g1BiasedArray.hpp" |
27 |
#include "gc/g1/g1RegionToSpaceMapper.hpp" |
|
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
28 |
#include "logging/log.hpp" |
26163
89f44df5b438
8055635: Missing include in g1RegionToSpaceMapper.hpp results in unresolved symbol of fastdebug build without precompiled headers
tschatzl
parents:
26160
diff
changeset
|
29 |
#include "memory/allocation.inline.hpp" |
30291
54cdc5c1a9cb
8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents:
30158
diff
changeset
|
30 |
#include "memory/virtualspace.hpp" |
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
31 |
#include "runtime/java.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
32 |
#include "runtime/os.inline.hpp" |
26160 | 33 |
#include "services/memTracker.hpp" |
46625 | 34 |
#include "utilities/align.hpp" |
26160 | 35 |
#include "utilities/bitMap.inline.hpp" |
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
36 |
#include "utilities/formatBuffer.hpp" |
26160 | 37 |
|
38 |
G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
39 |
size_t used_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
40 |
size_t page_size, |
26160 | 41 |
size_t region_granularity, |
38177 | 42 |
size_t commit_factor, |
26160 | 43 |
MemoryType type) : |
51332 | 44 |
_listener(NULL), |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
45 |
_storage(rs, used_size, page_size), |
26160 | 46 |
_region_granularity(region_granularity), |
46745
f7b9bb98bb72
8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents:
46625
diff
changeset
|
47 |
_commit_map(rs.size() * commit_factor / region_granularity, mtGC) { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
48 |
guarantee(is_power_of_2(page_size), "must be"); |
26160 | 49 |
guarantee(is_power_of_2(region_granularity), "must be"); |
50 |
||
51 |
MemTracker::record_virtual_memory_type((address)rs.base(), type); |
|
52 |
} |
|
53 |
||
54 |
// G1RegionToSpaceMapper implementation where the region granularity is larger than |
|
55 |
// or the same as the commit granularity. |
|
56 |
// Basically, the space corresponding to one region region spans several OS pages. |
|
57 |
class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { |
|
58 |
private: |
|
59 |
size_t _pages_per_region; |
|
60 |
||
61 |
public: |
|
62 |
G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
63 |
size_t actual_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
64 |
size_t page_size, |
26160 | 65 |
size_t alloc_granularity, |
66 |
size_t commit_factor, |
|
67 |
MemoryType type) : |
|
38177 | 68 |
G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
69 |
_pages_per_region(alloc_granularity / (page_size * commit_factor)) { |
26160 | 70 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
71 |
guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity"); |
26160 | 72 |
} |
73 |
||
41178 | 74 |
virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) { |
75 |
size_t const start_page = (size_t)start_idx * _pages_per_region; |
|
76 |
bool zero_filled = _storage.commit(start_page, num_regions * _pages_per_region); |
|
77 |
if (AlwaysPreTouch) { |
|
78 |
_storage.pretouch(start_page, num_regions * _pages_per_region, pretouch_gang); |
|
79 |
} |
|
26160 | 80 |
_commit_map.set_range(start_idx, start_idx + num_regions); |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
27149
diff
changeset
|
81 |
fire_on_commit(start_idx, num_regions, zero_filled); |
26160 | 82 |
} |
83 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
84 |
virtual void uncommit_regions(uint start_idx, size_t num_regions) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
85 |
_storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); |
26160 | 86 |
_commit_map.clear_range(start_idx, start_idx + num_regions); |
87 |
} |
|
88 |
}; |
|
89 |
||
90 |
// G1RegionToSpaceMapper implementation where the region granularity is smaller |
|
91 |
// than the commit granularity. |
|
92 |
// Basically, the contents of one OS page span several regions. |
|
93 |
class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { |
|
94 |
private: |
|
95 |
class CommitRefcountArray : public G1BiasedMappedArray<uint> { |
|
96 |
protected: |
|
97 |
virtual uint default_value() const { return 0; } |
|
98 |
}; |
|
99 |
||
100 |
size_t _regions_per_page; |
|
101 |
||
102 |
CommitRefcountArray _refcounts; |
|
103 |
||
104 |
uintptr_t region_idx_to_page_idx(uint region) const { |
|
105 |
return region / _regions_per_page; |
|
106 |
} |
|
107 |
||
108 |
public: |
|
109 |
G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs, |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
110 |
size_t actual_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
111 |
size_t page_size, |
26160 | 112 |
size_t alloc_granularity, |
113 |
size_t commit_factor, |
|
114 |
MemoryType type) : |
|
38177 | 115 |
G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
116 |
_regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() { |
26160 | 117 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
118 |
guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity"); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
41178
diff
changeset
|
119 |
_refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_up(rs.size(), page_size)), page_size); |
26160 | 120 |
} |
121 |
||
41178 | 122 |
virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) { |
123 |
size_t const NoPage = ~(size_t)0; |
|
124 |
||
125 |
size_t first_committed = NoPage; |
|
126 |
size_t num_committed = 0; |
|
127 |
||
128 |
bool all_zero_filled = true; |
|
129 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
130 |
for (uint i = start_idx; i < start_idx + num_regions; i++) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
131 |
assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
132 |
size_t idx = region_idx_to_page_idx(i); |
26160 | 133 |
uint old_refcount = _refcounts.get_by_index(idx); |
41178 | 134 |
|
27149 | 135 |
bool zero_filled = false; |
26160 | 136 |
if (old_refcount == 0) { |
41178 | 137 |
if (first_committed == NoPage) { |
138 |
first_committed = idx; |
|
139 |
num_committed = 1; |
|
140 |
} else { |
|
141 |
num_committed++; |
|
142 |
} |
|
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
27149
diff
changeset
|
143 |
zero_filled = _storage.commit(idx, 1); |
26160 | 144 |
} |
41178 | 145 |
all_zero_filled &= zero_filled; |
146 |
||
26160 | 147 |
_refcounts.set_by_index(idx, old_refcount + 1); |
148 |
_commit_map.set_bit(i); |
|
149 |
} |
|
41178 | 150 |
if (AlwaysPreTouch && num_committed > 0) { |
151 |
_storage.pretouch(first_committed, num_committed, pretouch_gang); |
|
152 |
} |
|
153 |
fire_on_commit(start_idx, num_regions, all_zero_filled); |
|
26160 | 154 |
} |
155 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
156 |
virtual void uncommit_regions(uint start_idx, size_t num_regions) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
157 |
for (uint i = start_idx; i < start_idx + num_regions; i++) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
158 |
assert(_commit_map.at(i), "Trying to uncommit storage at region %u that is not committed", i); |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
159 |
size_t idx = region_idx_to_page_idx(i); |
26160 | 160 |
uint old_refcount = _refcounts.get_by_index(idx); |
161 |
assert(old_refcount > 0, "must be"); |
|
162 |
if (old_refcount == 1) { |
|
163 |
_storage.uncommit(idx, 1); |
|
164 |
} |
|
165 |
_refcounts.set_by_index(idx, old_refcount - 1); |
|
166 |
_commit_map.clear_bit(i); |
|
167 |
} |
|
168 |
} |
|
169 |
}; |
|
170 |
||
27149 | 171 |
void G1RegionToSpaceMapper::fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled) { |
26160 | 172 |
if (_listener != NULL) { |
27149 | 173 |
_listener->on_commit(start_idx, num_regions, zero_filled); |
26160 | 174 |
} |
175 |
} |
|
176 |
||
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
177 |
static bool map_nvdimm_space(ReservedSpace rs) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
178 |
assert(AllocateOldGenAt != NULL, ""); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
179 |
int _backing_fd = os::create_file_for_heap(AllocateOldGenAt); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
180 |
if (_backing_fd == -1) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
181 |
log_error(gc, init)("Could not create file for Old generation at location %s", AllocateOldGenAt); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
182 |
return false; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
183 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
184 |
// commit this memory in nv-dimm |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
185 |
char* ret = os::attempt_reserve_memory_at(rs.size(), rs.base(), _backing_fd); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
186 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
187 |
if (ret != rs.base()) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
188 |
if (ret != NULL) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
189 |
os::unmap_memory(rs.base(), rs.size()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
190 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
191 |
log_error(gc, init)("Error in mapping Old Gen to given AllocateOldGenAt = %s", AllocateOldGenAt); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
192 |
os::close(_backing_fd); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
193 |
return false; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
194 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
195 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
196 |
os::close(_backing_fd); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
197 |
return true; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
198 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
199 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
200 |
G1RegionToHeteroSpaceMapper::G1RegionToHeteroSpaceMapper(ReservedSpace rs, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
201 |
size_t actual_size, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
202 |
size_t page_size, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
203 |
size_t alloc_granularity, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
204 |
size_t commit_factor, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
205 |
MemoryType type) : |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
206 |
G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
207 |
_rs(rs), |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
208 |
_num_committed_dram(0), |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
209 |
_num_committed_nvdimm(0), |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
210 |
_page_size(page_size), |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
211 |
_commit_factor(commit_factor), |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
212 |
_type(type) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
213 |
assert(actual_size == 2 * MaxHeapSize, "For 2-way heterogenuous heap, reserved space is two times MaxHeapSize"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
214 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
215 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
216 |
bool G1RegionToHeteroSpaceMapper::initialize() { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
217 |
// Since we need to re-map the reserved space - 'Xmx' to nv-dimm and 'Xmx' to dram, we need to release the reserved memory first. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
218 |
// Because on some OSes (e.g. Windows) you cannot do a file mapping on memory reserved with regular mapping. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
219 |
os::release_memory(_rs.base(), _rs.size()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
220 |
// First half of size Xmx is for nv-dimm. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
221 |
ReservedSpace rs_nvdimm = _rs.first_part(MaxHeapSize); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
222 |
assert(rs_nvdimm.base() == _rs.base(), "We should get the same base address"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
223 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
224 |
// Second half of reserved memory is mapped to dram. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
225 |
ReservedSpace rs_dram = _rs.last_part(MaxHeapSize); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
226 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
227 |
assert(rs_dram.size() == rs_nvdimm.size() && rs_nvdimm.size() == MaxHeapSize, "They all should be same"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
228 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
229 |
// Reserve dram memory |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
230 |
char* base = os::attempt_reserve_memory_at(rs_dram.size(), rs_dram.base()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
231 |
if (base != rs_dram.base()) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
232 |
if (base != NULL) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
233 |
os::release_memory(base, rs_dram.size()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
234 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
235 |
log_error(gc, init)("Error in re-mapping memory on dram during G1 heterogenous memory initialization"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
236 |
return false; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
237 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
238 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
239 |
// We reserve and commit this entire space to NV-DIMM. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
240 |
if (!map_nvdimm_space(rs_nvdimm)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
241 |
log_error(gc, init)("Error in re-mapping memory to nv-dimm during G1 heterogenous memory initialization"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
242 |
return false; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
243 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
244 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
245 |
if (_region_granularity >= (_page_size * _commit_factor)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
246 |
_dram_mapper = new G1RegionsLargerThanCommitSizeMapper(rs_dram, rs_dram.size(), _page_size, _region_granularity, _commit_factor, _type); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
247 |
} else { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
248 |
_dram_mapper = new G1RegionsSmallerThanCommitSizeMapper(rs_dram, rs_dram.size(), _page_size, _region_granularity, _commit_factor, _type); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
249 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
250 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
251 |
_start_index_of_nvdimm = 0; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
252 |
_start_index_of_dram = (uint)(rs_nvdimm.size() / _region_granularity); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
253 |
return true; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
254 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
255 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
256 |
void G1RegionToHeteroSpaceMapper::commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
257 |
uint end_idx = (start_idx + (uint)num_regions - 1); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
258 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
259 |
uint num_dram = end_idx >= _start_index_of_dram ? MIN2((end_idx - _start_index_of_dram + 1), (uint)num_regions) : 0; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
260 |
uint num_nvdimm = (uint)num_regions - num_dram; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
261 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
262 |
if (num_nvdimm > 0) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
263 |
// We do not need to commit nv-dimm regions, since they are committed in the beginning. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
264 |
_num_committed_nvdimm += num_nvdimm; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
265 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
266 |
if (num_dram > 0) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
267 |
_dram_mapper->commit_regions(start_idx > _start_index_of_dram ? (start_idx - _start_index_of_dram) : 0, num_dram, pretouch_gang); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
268 |
_num_committed_dram += num_dram; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
269 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
270 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
271 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
272 |
void G1RegionToHeteroSpaceMapper::uncommit_regions(uint start_idx, size_t num_regions) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
273 |
uint end_idx = (start_idx + (uint)num_regions - 1); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
274 |
uint num_dram = end_idx >= _start_index_of_dram ? MIN2((end_idx - _start_index_of_dram + 1), (uint)num_regions) : 0; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
275 |
uint num_nvdimm = (uint)num_regions - num_dram; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
276 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
277 |
if (num_nvdimm > 0) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
278 |
// We do not uncommit memory for nv-dimm regions. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
279 |
_num_committed_nvdimm -= num_nvdimm; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
280 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
281 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
282 |
if (num_dram > 0) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
283 |
_dram_mapper->uncommit_regions(start_idx > _start_index_of_dram ? (start_idx - _start_index_of_dram) : 0, num_dram); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
284 |
_num_committed_dram -= num_dram; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
285 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
286 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
287 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
288 |
uint G1RegionToHeteroSpaceMapper::num_committed_dram() const { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
289 |
return _num_committed_dram; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
290 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
291 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
292 |
uint G1RegionToHeteroSpaceMapper::num_committed_nvdimm() const { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
293 |
return _num_committed_nvdimm; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
294 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
295 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
296 |
G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_heap_mapper(ReservedSpace rs, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
297 |
size_t actual_size, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
298 |
size_t page_size, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
299 |
size_t region_granularity, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
300 |
size_t commit_factor, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
301 |
MemoryType type) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
302 |
if (AllocateOldGenAt != NULL) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
303 |
G1RegionToHeteroSpaceMapper* mapper = new G1RegionToHeteroSpaceMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
304 |
if (!mapper->initialize()) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
305 |
delete mapper; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
306 |
return NULL; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
307 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
308 |
return (G1RegionToSpaceMapper*)mapper; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
309 |
} else { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
310 |
return create_mapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
311 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
312 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
313 |
|
26160 | 314 |
G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs, |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
315 |
size_t actual_size, |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
316 |
size_t page_size, |
26160 | 317 |
size_t region_granularity, |
318 |
size_t commit_factor, |
|
319 |
MemoryType type) { |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
320 |
if (region_granularity >= (page_size * commit_factor)) { |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
321 |
return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
26160 | 322 |
} else { |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
323 |
return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); |
26160 | 324 |
} |
325 |
} |
|
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
326 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
327 |
void G1RegionToSpaceMapper::commit_and_set_special() { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
328 |
_storage.commit_and_set_special(); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
329 |
} |