author | stuefe |
Tue, 19 Nov 2019 20:01:05 +0100 | |
branch | stuefe-new-metaspace-branch |
changeset 59138 | 714474295e0a |
parent 58063 | bdf136b8ae0e |
permissions | -rw-r--r-- |
50193 | 1 |
/* |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
3 |
* Copyright (c) 2018, 2019 SAP SE. All rights reserved. |
50193 | 4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
26 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
27 |
#include <memory/metaspace/settings.hpp> |
50193 | 28 |
#include "precompiled.hpp" |
29 |
||
30 |
#include "logging/log.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
31 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
32 |
#include "memory/metaspace/chunkLevel.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
33 |
#include "memory/metaspace/chunkHeaderPool.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
34 |
#include "memory/metaspace/commitLimiter.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
35 |
#include "memory/metaspace/counter.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
36 |
#include "memory/metaspace/internStat.hpp" |
50193 | 37 |
#include "memory/metaspace/metachunk.hpp" |
38 |
#include "memory/metaspace/metaspaceCommon.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
39 |
#include "memory/metaspace/rootChunkArea.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
40 |
#include "memory/metaspace/runningCounters.hpp" |
50193 | 41 |
#include "memory/metaspace/virtualSpaceNode.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
42 |
|
59138 | 43 |
#include "runtime/globals.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
44 |
#include "runtime/mutexLocker.hpp" |
50193 | 45 |
#include "runtime/os.hpp" |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
46 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
47 |
#include "utilities/align.hpp" |
50193 | 48 |
#include "utilities/debug.hpp" |
49 |
#include "utilities/globalDefinitions.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
50 |
#include "utilities/ostream.hpp" |
50193 | 51 |
|
52 |
namespace metaspace { |
|
53 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
54 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
55 |
void check_pointer_is_aligned_to_commit_granule(const MetaWord* p) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
56 |
assert(is_aligned(p, Settings::commit_granule_bytes()), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
57 |
"Pointer not aligned to commit granule size: " PTR_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
58 |
p2i(p)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
59 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
60 |
void check_word_size_is_aligned_to_commit_granule(size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
61 |
assert(is_aligned(word_size, Settings::commit_granule_words()), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
62 |
"Not aligned to commit granule size: " SIZE_FORMAT ".", word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
63 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
64 |
#endif |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
65 |
|
59138 | 66 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
67 |
// Given an address range, ensure it is committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
68 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
69 |
// The range has to be aligned to granule size. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
70 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
71 |
// Function will: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
72 |
// - check how many granules in that region are uncommitted; If all are committed, it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
73 |
// returns true immediately. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
74 |
// - check if committing those uncommitted granules would bring us over the commit limit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
75 |
// (GC threshold, MaxMetaspaceSize). If true, it returns false. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
76 |
// - commit the memory. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
77 |
// - mark the range as committed in the commit mask |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
78 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
79 |
// Returns true if success, false if it did hit a commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
80 |
bool VirtualSpaceNode::commit_range(MetaWord* p, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
81 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
82 |
DEBUG_ONLY(check_pointer_is_aligned_to_commit_granule(p);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
83 |
DEBUG_ONLY(check_word_size_is_aligned_to_commit_granule(word_size);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
84 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
85 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
86 |
// First calculate how large the committed regions in this range are |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
87 |
const size_t committed_words_in_range = _commit_mask.get_committed_size_in_range(p, word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
88 |
DEBUG_ONLY(check_word_size_is_aligned_to_commit_granule(committed_words_in_range);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
89 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
90 |
// By how much words we would increase commit charge |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
91 |
// were we to commit the given address range completely. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
92 |
const size_t commit_increase_words = word_size - committed_words_in_range; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
93 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
94 |
log_debug(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": committing range " PTR_FORMAT ".." PTR_FORMAT "(" SIZE_FORMAT " words)", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
95 |
_node_id, p2i(_base), p2i(p), p2i(p + word_size), word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
96 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
97 |
if (commit_increase_words == 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
98 |
log_debug(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": ... already fully committed.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
99 |
_node_id, p2i(_base)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
100 |
return true; // Already fully committed, nothing to do. |
50193 | 101 |
} |
102 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
103 |
// Before committing any more memory, check limits. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
104 |
if (_commit_limiter->possible_expansion_words() < commit_increase_words) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
105 |
return false; |
50193 | 106 |
} |
107 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
108 |
// Commit... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
109 |
if (os::commit_memory((char*)p, word_size * BytesPerWord, false) == false) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
110 |
vm_exit_out_of_memory(word_size * BytesPerWord, OOM_MMAP_ERROR, "Failed to commit metaspace."); |
50193 | 111 |
} |
112 |
||
59138 | 113 |
if (AlwaysPreTouch) { |
114 |
os::pretouch_memory(p, p + word_size); |
|
115 |
} |
|
116 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
117 |
log_debug(gc, metaspace)("Increased metaspace by " SIZE_FORMAT " bytes.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
118 |
commit_increase_words * BytesPerWord); |
50193 | 119 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
120 |
// ... tell commit limiter... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
121 |
_commit_limiter->increase_committed(commit_increase_words); |
50193 | 122 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
123 |
// ... update counters in containing vslist ... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
124 |
_total_committed_words_counter->increment_by(commit_increase_words); |
50193 | 125 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
126 |
// ... and update the commit mask. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
127 |
_commit_mask.mark_range_as_committed(p, word_size); |
50193 | 128 |
|
129 |
#ifdef ASSERT |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
130 |
// The commit boundary maintained in the CommitLimiter should be equal the sum of committed words |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
131 |
// in both class and non-class vslist (outside gtests). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
132 |
if (_commit_limiter == CommitLimiter::globalLimiter()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
133 |
assert(_commit_limiter->committed_words() == RunningCounters::committed_words(), "counter mismatch"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
134 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
135 |
#endif |
50193 | 136 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
137 |
DEBUG_ONLY(InternalStats::inc_num_space_committed();) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
138 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
139 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
140 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
141 |
} |
50193 | 142 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
143 |
// Given an address range, ensure it is committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
144 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
145 |
// The range does not have to be aligned to granule size. However, the function will always commit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
146 |
// whole granules. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
147 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
148 |
// Function will: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
149 |
// - check how many granules in that region are uncommitted; If all are committed, it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
150 |
// returns true immediately. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
151 |
// - check if committing those uncommitted granules would bring us over the commit limit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
152 |
// (GC threshold, MaxMetaspaceSize). If true, it returns false. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
153 |
// - commit the memory. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
154 |
// - mark the range as committed in the commit mask |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
155 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
156 |
// !! Careful: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
157 |
// calling ensure_range_is_committed on a range which contains both committed and uncommitted |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
158 |
// areas will commit the whole area, thus erase the content in the existing committed parts. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
159 |
// Make sure you never call this on an address range containing live data. !! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
160 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
161 |
// Returns true if success, false if it did hit a commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
162 |
bool VirtualSpaceNode::ensure_range_is_committed(MetaWord* p, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
163 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
164 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
165 |
assert(p != NULL && word_size > 0, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
166 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
167 |
MetaWord* p_start = align_down(p, Settings::commit_granule_bytes()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
168 |
MetaWord* p_end = align_up(p + word_size, Settings::commit_granule_bytes()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
169 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
170 |
// Todo: simple for now. Make it more intelligent late |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
171 |
return commit_range(p_start, p_end - p_start); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
172 |
|
50193 | 173 |
} |
174 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
175 |
// Given an address range (which has to be aligned to commit granule size): |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
176 |
// - uncommit it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
177 |
// - mark it as uncommitted in the commit mask |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
178 |
void VirtualSpaceNode::uncommit_range(MetaWord* p, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
179 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
180 |
DEBUG_ONLY(check_pointer_is_aligned_to_commit_granule(p);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
181 |
DEBUG_ONLY(check_word_size_is_aligned_to_commit_granule(word_size);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
182 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
183 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
184 |
// First calculate how large the committed regions in this range are |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
185 |
const size_t committed_words_in_range = _commit_mask.get_committed_size_in_range(p, word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
186 |
DEBUG_ONLY(check_word_size_is_aligned_to_commit_granule(committed_words_in_range);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
187 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
188 |
log_debug(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": uncommitting range " PTR_FORMAT ".." PTR_FORMAT "(" SIZE_FORMAT " words)", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
189 |
_node_id, p2i(_base), p2i(p), p2i(p + word_size), word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
190 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
191 |
if (committed_words_in_range == 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
192 |
log_debug(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": ... already fully uncommitted.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
193 |
_node_id, p2i(_base)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
194 |
return; // Already fully uncommitted, nothing to do. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
195 |
} |
50193 | 196 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
197 |
// Uncommit... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
198 |
if (os::uncommit_memory((char*)p, word_size * BytesPerWord) == false) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
199 |
// Note: this can actually happen, since uncommit may increase the number of mappings. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
200 |
fatal("Failed to uncommit metaspace."); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
201 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
202 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
203 |
log_debug(metaspace)("Decreased metaspace by " SIZE_FORMAT " bytes.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
204 |
committed_words_in_range * BytesPerWord); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
205 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
206 |
// ... tell commit limiter... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
207 |
_commit_limiter->decrease_committed(committed_words_in_range); |
53970 | 208 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
209 |
// ... and global counters... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
210 |
_total_committed_words_counter->decrement_by(committed_words_in_range); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
211 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
212 |
// ... and update the commit mask. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
213 |
_commit_mask.mark_range_as_uncommitted(p, word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
214 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
215 |
#ifdef ASSERT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
216 |
// The commit boundary maintained in the CommitLimiter should be equal the sum of committed words |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
217 |
// in both class and non-class vslist (outside gtests). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
218 |
if (_commit_limiter == CommitLimiter::globalLimiter()) { // We are outside a test scenario |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
219 |
assert(_commit_limiter->committed_words() == RunningCounters::committed_words(), "counter mismatch"); |
50193 | 220 |
} |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
221 |
#endif |
50193 | 222 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
223 |
DEBUG_ONLY(InternalStats::inc_num_space_uncommitted();) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
224 |
|
50193 | 225 |
} |
226 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
227 |
//// creation, destruction //// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
228 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
229 |
VirtualSpaceNode::VirtualSpaceNode(int node_id, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
230 |
ReservedSpace rs, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
231 |
CommitLimiter* limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
232 |
SizeCounter* reserve_words_counter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
233 |
SizeCounter* commit_words_counter) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
234 |
: _next(NULL), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
235 |
_rs(rs), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
236 |
_base((MetaWord*)rs.base()), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
237 |
_word_size(rs.size() / BytesPerWord), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
238 |
_used_words(0), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
239 |
_commit_mask((MetaWord*)rs.base(), rs.size() / BytesPerWord), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
240 |
_root_chunk_area_lut((MetaWord*)rs.base(), rs.size() / BytesPerWord), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
241 |
_commit_limiter(limiter), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
242 |
_total_reserved_words_counter(reserve_words_counter), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
243 |
_total_committed_words_counter(commit_words_counter), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
244 |
_node_id(node_id) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
245 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
246 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
247 |
log_debug(metaspace)("Create new VirtualSpaceNode %d, base " PTR_FORMAT ", word size " SIZE_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
248 |
_node_id, p2i(_base), _word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
249 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
250 |
// Update reserved counter in vslist |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
251 |
_total_reserved_words_counter->increment_by(_word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
252 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
253 |
assert_is_aligned(_base, chklvl::MAX_CHUNK_BYTE_SIZE); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
254 |
assert_is_aligned(_word_size, chklvl::MAX_CHUNK_WORD_SIZE); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
255 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
256 |
// Explicitly uncommit the whole node to make it guaranteed |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
257 |
// inaccessible, for testing |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
258 |
// os::uncommit_memory((char*)_base, _word_size * BytesPerWord); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
259 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
260 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
261 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
262 |
// Create a node of a given size |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
263 |
VirtualSpaceNode* VirtualSpaceNode::create_node(int node_id, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
264 |
size_t word_size, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
265 |
CommitLimiter* limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
266 |
SizeCounter* reserve_words_counter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
267 |
SizeCounter* commit_words_counter) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
268 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
269 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
270 |
DEBUG_ONLY(assert_is_aligned(word_size, chklvl::MAX_CHUNK_WORD_SIZE);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
271 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
272 |
ReservedSpace rs(word_size * BytesPerWord, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
273 |
chklvl::MAX_CHUNK_BYTE_SIZE, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
274 |
false, // TODO deal with large pages |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
275 |
false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
276 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
277 |
if (!rs.is_reserved()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
278 |
vm_exit_out_of_memory(word_size * BytesPerWord, OOM_MMAP_ERROR, "Failed to reserve memory for metaspace"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
279 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
280 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
281 |
assert_is_aligned(rs.base(), chklvl::MAX_CHUNK_BYTE_SIZE); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
282 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
283 |
return create_node(node_id, rs, limiter, reserve_words_counter, commit_words_counter); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
284 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
285 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
286 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
287 |
// Create a node over an existing space |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
288 |
VirtualSpaceNode* VirtualSpaceNode::create_node(int node_id, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
289 |
ReservedSpace rs, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
290 |
CommitLimiter* limiter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
291 |
SizeCounter* reserve_words_counter, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
292 |
SizeCounter* commit_words_counter) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
293 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
294 |
DEBUG_ONLY(InternalStats::inc_num_vsnodes_created();) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
295 |
return new VirtualSpaceNode(node_id, rs, limiter, reserve_words_counter, commit_words_counter); |
50193 | 296 |
} |
297 |
||
298 |
VirtualSpaceNode::~VirtualSpaceNode() { |
|
299 |
_rs.release(); |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
300 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
301 |
log_debug(metaspace)("Destroying VirtualSpaceNode %d, base " PTR_FORMAT ", word size " SIZE_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
302 |
_node_id, p2i(_base), _word_size); |
50193 | 303 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
304 |
// Update counters in vslist |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
305 |
_total_committed_words_counter->decrement_by(committed_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
306 |
_total_reserved_words_counter->decrement_by(_word_size); |
50193 | 307 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
308 |
DEBUG_ONLY(InternalStats::inc_num_vsnodes_destroyed();) |
50193 | 309 |
|
310 |
} |
|
311 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
312 |
|
50193 | 313 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
314 |
//// Chunk allocation, splitting, merging ///// |
50193 | 315 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
316 |
// Allocate a root chunk from this node. Will fail and return NULL |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
317 |
// if the node is full. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
318 |
// Note: this just returns a chunk whose memory is reserved; no memory is committed yet. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
319 |
// Hence, before using this chunk, it must be committed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
320 |
// Also, no limits are checked, since no committing takes place. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
321 |
Metachunk* VirtualSpaceNode::allocate_root_chunk() { |
50193 | 322 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
323 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
324 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
325 |
assert_is_aligned(free_words(), chklvl::MAX_CHUNK_WORD_SIZE); |
50193 | 326 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
327 |
if (free_words() >= chklvl::MAX_CHUNK_WORD_SIZE) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
328 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
329 |
MetaWord* loc = _base + _used_words; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
330 |
_used_words += chklvl::MAX_CHUNK_WORD_SIZE; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
331 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
332 |
RootChunkArea* rca = _root_chunk_area_lut.get_area_by_address(loc); |
50193 | 333 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
334 |
// Create a root chunk header and initialize it; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
335 |
Metachunk* c = rca->alloc_root_chunk_header(this); |
50193 | 336 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
337 |
assert(c->base() == loc && c->vsnode() == this && |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
338 |
c->is_free(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
339 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
340 |
DEBUG_ONLY(c->verify(true);) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
341 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
342 |
log_debug(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": newborn root chunk " METACHUNK_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
343 |
_node_id, p2i(_base), METACHUNK_FORMAT_ARGS(c)); |
50193 | 344 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
345 |
if (Settings::newborn_root_chunks_are_fully_committed()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
346 |
log_trace(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": committing newborn root chunk.", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
347 |
_node_id, p2i(_base)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
348 |
// Note: use Metachunk::ensure_commit, do not commit directly. This makes sure the chunk knows |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
349 |
// its commit range and does not ask needlessly. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
350 |
c->ensure_fully_committed_locked(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
351 |
} |
50193 | 352 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
353 |
return c; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
354 |
|
50193 | 355 |
} |
356 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
357 |
return NULL; // Node is full. |
50193 | 358 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
359 |
} |
50193 | 360 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
361 |
// Given a chunk c, split it recursively until you get a chunk of the given target_level. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
362 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
363 |
// The original chunk must not be part of a freelist. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
364 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
365 |
// Returns pointer to the result chunk; the splitted-off chunks are added as |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
366 |
// free chunks to the freelists. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
367 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
368 |
// Returns NULL if chunk cannot be split at least once. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
369 |
Metachunk* VirtualSpaceNode::split(chklvl_t target_level, Metachunk* c, MetachunkListCluster* freelists) { |
50193 | 370 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
371 |
assert_lock_strong(MetaspaceExpand_lock); |
50193 | 372 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
373 |
// Get the area associated with this chunk and let it handle the splitting |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
374 |
RootChunkArea* rca = _root_chunk_area_lut.get_area_by_address(c->base()); |
50193 | 375 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
376 |
DEBUG_ONLY(rca->verify_area_is_ideally_merged();) |
50193 | 377 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
378 |
return rca->split(target_level, c, freelists); |
50193 | 379 |
|
380 |
} |
|
381 |
||
382 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
383 |
// Given a chunk, attempt to merge it recursively with its neighboring chunks. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
384 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
385 |
// If successful (merged at least once), returns address of |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
386 |
// the merged chunk; NULL otherwise. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
387 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
388 |
// The merged chunks are removed from the freelists. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
389 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
390 |
// !!! Please note that if this method returns a non-NULL value, the |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
391 |
// original chunk will be invalid and should not be accessed anymore! !!! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
392 |
Metachunk* VirtualSpaceNode::merge(Metachunk* c, MetachunkListCluster* freelists) { |
50193 | 393 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
394 |
assert(c != NULL && c->is_free(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
395 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
396 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
397 |
// Get the tree associated with this chunk and let it handle the merging |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
398 |
RootChunkArea* rca = _root_chunk_area_lut.get_area_by_address(c->base()); |
50193 | 399 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
400 |
Metachunk* c2 = rca->merge(c, freelists); |
50193 | 401 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
402 |
DEBUG_ONLY(rca->verify_area_is_ideally_merged();) |
50193 | 403 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
404 |
return c2; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
405 |
|
50193 | 406 |
} |
407 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
408 |
// Given a chunk c, which must be "in use" and must not be a root chunk, attempt to |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
409 |
// enlarge it in place by claiming its trailing buddy. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
410 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
411 |
// This will only work if c is the leader of the buddy pair and the trailing buddy is free. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
412 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
413 |
// If successful, the follower chunk will be removed from the freelists, the leader chunk c will |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
414 |
// double in size (level decreased by one). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
415 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
416 |
// On success, true is returned, false otherwise. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
417 |
bool VirtualSpaceNode::attempt_enlarge_chunk(Metachunk* c, MetachunkListCluster* freelists) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
418 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
419 |
assert(c != NULL && c->is_in_use() && !c->is_root_chunk(), "Sanity"); |
50193 | 420 |
assert_lock_strong(MetaspaceExpand_lock); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
421 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
422 |
// Get the tree associated with this chunk and let it handle the merging |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
423 |
RootChunkArea* rca = _root_chunk_area_lut.get_area_by_address(c->base()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
424 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
425 |
bool rc = rca->attempt_enlarge_chunk(c, freelists); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
426 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
427 |
DEBUG_ONLY(rca->verify_area_is_ideally_merged();) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
428 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
429 |
return rc; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
430 |
|
50193 | 431 |
} |
432 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
433 |
// Attempts to purge the node: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
434 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
435 |
// If all chunks living in this node are free, they will all be removed from their freelists |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
436 |
// and deletes the node. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
437 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
438 |
// Returns true if the node has been deleted, false if not. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
439 |
// !! If this returns true, do not access the node from this point on. !! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
440 |
bool VirtualSpaceNode::attempt_purge(MetachunkListCluster* freelists) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
441 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
442 |
assert_lock_strong(MetaspaceExpand_lock); |
50193 | 443 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
444 |
// First find out if all areas are empty. Since empty chunks collapse to root chunk |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
445 |
// size, if all chunks in this node are free root chunks we are good to go. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
446 |
for (int narea = 0; narea < _root_chunk_area_lut.number_of_areas(); narea ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
447 |
const RootChunkArea* ra = _root_chunk_area_lut.get_area_by_index(narea); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
448 |
const Metachunk* c = ra->first_chunk(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
449 |
if (c != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
450 |
if (!(c->is_root_chunk() && c->is_free())) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
451 |
return false; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
452 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
453 |
} |
50193 | 454 |
} |
455 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
456 |
log_debug(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": purging.", _node_id, p2i(_base)); |
50193 | 457 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
458 |
// Okay, we can purge. Before we can do this, we need to remove all chunks from the freelist. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
459 |
for (int narea = 0; narea < _root_chunk_area_lut.number_of_areas(); narea ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
460 |
RootChunkArea* ra = _root_chunk_area_lut.get_area_by_index(narea); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
461 |
Metachunk* c = ra->first_chunk(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
462 |
if (c != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
463 |
log_trace(metaspace)("VirtualSpaceNode %d, base " PTR_FORMAT ": removing chunk " METACHUNK_FULL_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
464 |
_node_id, p2i(_base), METACHUNK_FULL_FORMAT_ARGS(c)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
465 |
assert(c->is_free() && c->is_root_chunk(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
466 |
freelists->remove(c); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
467 |
} |
50193 | 468 |
} |
469 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
470 |
// Now, delete the node, then right away return since this object is invalid. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
471 |
delete this; |
50193 | 472 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
473 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
474 |
|
50193 | 475 |
} |
476 |
||
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
477 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
478 |
void VirtualSpaceNode::print_on(outputStream* st) const { |
50193 | 479 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
480 |
size_t scale = K; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
481 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
482 |
st->print("id: %d, base " PTR_FORMAT ": ", _node_id, p2i(base())); |
50193 | 483 |
st->print("reserved="); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
484 |
print_scaled_words(st, word_size(), scale); |
50193 | 485 |
st->print(", committed="); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
486 |
print_scaled_words_and_percentage(st, committed_words(), word_size(), scale); |
50193 | 487 |
st->print(", used="); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
488 |
print_scaled_words_and_percentage(st, used_words(), word_size(), scale); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
489 |
|
50193 | 490 |
st->cr(); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
491 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
492 |
_root_chunk_area_lut.print_on(st); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
493 |
_commit_mask.print_on(st); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
494 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
495 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
496 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
497 |
// Returns size, in words, of committed space in this node alone. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
498 |
// Note: iterates over commit mask and hence may be a tad expensive on large nodes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
499 |
size_t VirtualSpaceNode::committed_words() const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
500 |
return _commit_mask.get_committed_size(); |
50193 | 501 |
} |
502 |
||
503 |
#ifdef ASSERT |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
504 |
// Verify counters and basic structure. Slow mode: verify all chunks in depth |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
505 |
void VirtualSpaceNode::verify(bool slow) const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
506 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
507 |
assert_lock_strong(MetaspaceExpand_lock); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
508 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
509 |
assert(base() != NULL, "Invalid base"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
510 |
assert(base() == (MetaWord*)_rs.base() && |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
511 |
word_size() == _rs.size() / BytesPerWord, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
512 |
"Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
513 |
assert_is_aligned(base(), chklvl::MAX_CHUNK_BYTE_SIZE); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
514 |
assert(used_words() <= word_size(), "Sanity"); |
50193 | 515 |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
516 |
// Since we only ever hand out root chunks from a vsnode, top should always be aligned |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
517 |
// to root chunk size. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
518 |
assert_is_aligned(used_words(), chklvl::MAX_CHUNK_WORD_SIZE); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
519 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
520 |
_commit_mask.verify(slow); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
521 |
assert(committed_words() <= word_size(), "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
522 |
assert_is_aligned(committed_words(), Settings::commit_granule_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
523 |
_root_chunk_area_lut.verify(slow); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
524 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
525 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
53970
diff
changeset
|
526 |
|
53970 | 527 |
#endif |
50193 | 528 |
|
529 |
||
530 |
} // namespace metaspace |
|
531 |