author | sangheki |
Wed, 13 Nov 2019 10:51:41 -0800 | |
changeset 59062 | 6530de931b8e |
parent 59060 | fce1fa1bdc91 |
permissions | -rw-r--r-- |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
1 |
/* |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
4 |
* |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
8 |
* |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
13 |
* accompanied this code). |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
14 |
* |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
18 |
* |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
21 |
* questions. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
22 |
* |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
23 |
*/ |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
24 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
26 |
#include "gc/g1/g1NUMA.hpp" |
59062
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
27 |
#include "logging/logStream.hpp" |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
28 |
#include "runtime/globals.hpp" |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
29 |
#include "runtime/os.hpp" |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
30 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
31 |
G1NUMA* G1NUMA::_inst = NULL; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
32 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
33 |
size_t G1NUMA::region_size() const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
34 |
assert(_region_size > 0, "Heap region size is not yet set"); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
35 |
return _region_size; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
36 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
37 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
38 |
size_t G1NUMA::page_size() const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
39 |
assert(_page_size > 0, "Page size not is yet set"); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
40 |
return _page_size; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
41 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
42 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
43 |
bool G1NUMA::is_enabled() const { return num_active_nodes() > 1; } |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
44 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
45 |
G1NUMA* G1NUMA::create() { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
46 |
guarantee(_inst == NULL, "Should be called once."); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
47 |
_inst = new G1NUMA(); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
48 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
49 |
// NUMA only supported on Linux. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
50 |
#ifdef LINUX |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
51 |
_inst->initialize(UseNUMA); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
52 |
#else |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
53 |
_inst->initialize(false); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
54 |
#endif /* LINUX */ |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
55 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
56 |
return _inst; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
57 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
58 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
59 |
// Returns memory node ids |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
60 |
const int* G1NUMA::node_ids() const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
61 |
return _node_ids; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
62 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
63 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
64 |
uint G1NUMA::index_of_node_id(int node_id) const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
65 |
assert(node_id >= 0, "invalid node id %d", node_id); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
66 |
assert(node_id < _len_node_id_to_index_map, "invalid node id %d", node_id); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
67 |
uint node_index = _node_id_to_index_map[node_id]; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
68 |
assert(node_index != G1NUMA::UnknownNodeIndex, |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
69 |
"invalid node id %d", node_id); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
70 |
return node_index; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
71 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
72 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
73 |
G1NUMA::G1NUMA() : |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
74 |
_node_id_to_index_map(NULL), _len_node_id_to_index_map(0), |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
75 |
_node_ids(NULL), _num_active_node_ids(0), |
59062
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
76 |
_region_size(0), _page_size(0), _stats(NULL) { |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
77 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
78 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
79 |
void G1NUMA::initialize_without_numa() { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
80 |
// If NUMA is not enabled or supported, initialize as having a singel node. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
81 |
_num_active_node_ids = 1; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
82 |
_node_ids = NEW_C_HEAP_ARRAY(int, _num_active_node_ids, mtGC); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
83 |
_node_ids[0] = 0; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
84 |
// Map index 0 to node 0 |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
85 |
_len_node_id_to_index_map = 1; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
86 |
_node_id_to_index_map = NEW_C_HEAP_ARRAY(uint, _len_node_id_to_index_map, mtGC); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
87 |
_node_id_to_index_map[0] = 0; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
88 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
89 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
90 |
void G1NUMA::initialize(bool use_numa) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
91 |
if (!use_numa) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
92 |
initialize_without_numa(); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
93 |
return; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
94 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
95 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
96 |
assert(UseNUMA, "Invariant"); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
97 |
size_t num_node_ids = os::numa_get_groups_num(); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
98 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
99 |
// Create an array of active node ids. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
100 |
_node_ids = NEW_C_HEAP_ARRAY(int, num_node_ids, mtGC); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
101 |
_num_active_node_ids = (uint)os::numa_get_leaf_groups(_node_ids, num_node_ids); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
102 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
103 |
int max_node_id = 0; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
104 |
for (uint i = 0; i < _num_active_node_ids; i++) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
105 |
max_node_id = MAX2(max_node_id, _node_ids[i]); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
106 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
107 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
108 |
// Create a mapping between node_id and index. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
109 |
_len_node_id_to_index_map = max_node_id + 1; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
110 |
_node_id_to_index_map = NEW_C_HEAP_ARRAY(uint, _len_node_id_to_index_map, mtGC); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
111 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
112 |
// Set all indices with unknown node id. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
113 |
for (int i = 0; i < _len_node_id_to_index_map; i++) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
114 |
_node_id_to_index_map[i] = G1NUMA::UnknownNodeIndex; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
115 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
116 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
117 |
// Set the indices for the actually retrieved node ids. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
118 |
for (uint i = 0; i < _num_active_node_ids; i++) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
119 |
_node_id_to_index_map[_node_ids[i]] = i; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
120 |
} |
59062
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
121 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
122 |
_stats = new G1NUMAStats(_node_ids, _num_active_node_ids); |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
123 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
124 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
125 |
G1NUMA::~G1NUMA() { |
59062
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
126 |
delete _stats; |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
127 |
FREE_C_HEAP_ARRAY(int, _node_id_to_index_map); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
128 |
FREE_C_HEAP_ARRAY(int, _node_ids); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
129 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
130 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
131 |
void G1NUMA::set_region_info(size_t region_size, size_t page_size) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
132 |
_region_size = region_size; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
133 |
_page_size = page_size; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
134 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
135 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
136 |
uint G1NUMA::num_active_nodes() const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
137 |
assert(_num_active_node_ids > 0, "just checking"); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
138 |
return _num_active_node_ids; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
139 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
140 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
141 |
uint G1NUMA::index_of_current_thread() const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
142 |
if (!is_enabled()) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
143 |
return 0; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
144 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
145 |
return index_of_node_id(os::numa_get_group_id()); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
146 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
147 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
148 |
uint G1NUMA::preferred_node_index_for_index(uint region_index) const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
149 |
if (region_size() >= page_size()) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
150 |
// Simple case, pages are smaller than the region so we |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
151 |
// can just alternate over the nodes. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
152 |
return region_index % _num_active_node_ids; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
153 |
} else { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
154 |
// Multiple regions in one page, so we need to make sure the |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
155 |
// regions within a page is preferred on the same node. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
156 |
size_t regions_per_page = page_size() / region_size(); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
157 |
return (region_index / regions_per_page) % _num_active_node_ids; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
158 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
159 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
160 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
161 |
int G1NUMA::numa_id(int index) const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
162 |
assert(index < _len_node_id_to_index_map, "Index %d out of range: [0,%d)", |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
163 |
index, _len_node_id_to_index_map); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
164 |
return _node_ids[index]; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
165 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
166 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
167 |
uint G1NUMA::index_of_address(HeapWord *address) const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
168 |
int numa_id = os::numa_get_group_id_for_address((const void*)address); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
169 |
if (numa_id == -1) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
170 |
return UnknownNodeIndex; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
171 |
} else { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
172 |
return index_of_node_id(numa_id); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
173 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
174 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
175 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
176 |
uint G1NUMA::index_for_region(HeapRegion* hr) const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
177 |
if (!is_enabled()) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
178 |
return 0; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
179 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
180 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
181 |
if (AlwaysPreTouch) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
182 |
// If we already pretouched, we can check actual node index here. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
183 |
// However, if node index is still unknown, use preferred node index. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
184 |
uint node_index = index_of_address(hr->bottom()); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
185 |
if (node_index != UnknownNodeIndex) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
186 |
return node_index; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
187 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
188 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
189 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
190 |
return preferred_node_index_for_index(hr->hrm_index()); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
191 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
192 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
193 |
// Request to spread the given memory evenly across the available NUMA |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
194 |
// nodes. Which node to request for a given address is given by the |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
195 |
// region size and the page size. Below are two examples on 4 NUMA nodes system: |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
196 |
// 1. G1HeapRegionSize(_region_size) is larger than or equal to page size. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
197 |
// * Page #: |-0--||-1--||-2--||-3--||-4--||-5--||-6--||-7--||-8--||-9--||-10-||-11-||-12-||-13-||-14-||-15-| |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
198 |
// * HeapRegion #: |----#0----||----#1----||----#2----||----#3----||----#4----||----#5----||----#6----||----#7----| |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
199 |
// * NUMA node #: |----#0----||----#1----||----#2----||----#3----||----#0----||----#1----||----#2----||----#3----| |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
200 |
// 2. G1HeapRegionSize(_region_size) is smaller than page size. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
201 |
// Memory will be touched one page at a time because G1RegionToSpaceMapper commits |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
202 |
// pages one by one. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
203 |
// * Page #: |-----0----||-----1----||-----2----||-----3----||-----4----||-----5----||-----6----||-----7----| |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
204 |
// * HeapRegion #: |-#0-||-#1-||-#2-||-#3-||-#4-||-#5-||-#6-||-#7-||-#8-||-#9-||#10-||#11-||#12-||#13-||#14-||#15-| |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
205 |
// * NUMA node #: |----#0----||----#1----||----#2----||----#3----||----#0----||----#1----||----#2----||----#3----| |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
206 |
void G1NUMA::request_memory_on_node(void* aligned_address, size_t size_in_bytes, uint region_index) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
207 |
if (!is_enabled()) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
208 |
return; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
209 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
210 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
211 |
if (size_in_bytes == 0) { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
212 |
return; |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
213 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
214 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
215 |
uint node_index = preferred_node_index_for_index(region_index); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
216 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
217 |
assert(is_aligned(aligned_address, page_size()), "Given address (" PTR_FORMAT ") should be aligned.", p2i(aligned_address)); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
218 |
assert(is_aligned(size_in_bytes, page_size()), "Given size (" SIZE_FORMAT ") should be aligned.", size_in_bytes); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
219 |
|
59062
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
220 |
log_trace(gc, heap, numa)("Request memory [" PTR_FORMAT ", " PTR_FORMAT ") to be NUMA id (%d)", |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
221 |
p2i(aligned_address), p2i((char*)aligned_address + size_in_bytes), _node_ids[node_index]); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
222 |
os::numa_make_local((char*)aligned_address, size_in_bytes, _node_ids[node_index]); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
223 |
} |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
224 |
|
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
225 |
uint G1NUMA::max_search_depth() const { |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
226 |
// Multiple of 3 is just random number to limit iterations. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
227 |
// There would be some cases that 1 page may be consisted of multiple HeapRegions. |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
228 |
return 3 * MAX2((uint)(page_size() / region_size()), (uint)1) * num_active_nodes(); |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
diff
changeset
|
229 |
} |
59062
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
230 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
231 |
void G1NUMA::update_statistics(G1NUMAStats::NodeDataItems phase, |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
232 |
uint requested_node_index, |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
233 |
uint allocated_node_index) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
234 |
if (_stats == NULL) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
235 |
return; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
236 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
237 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
238 |
uint converted_req_index; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
239 |
if(requested_node_index < _num_active_node_ids) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
240 |
converted_req_index = requested_node_index; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
241 |
} else { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
242 |
assert(requested_node_index == AnyNodeIndex, |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
243 |
"Requested node index %u should be AnyNodeIndex.", requested_node_index); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
244 |
converted_req_index = _num_active_node_ids; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
245 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
246 |
_stats->update(phase, converted_req_index, allocated_node_index); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
247 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
248 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
249 |
void G1NUMA::copy_statistics(G1NUMAStats::NodeDataItems phase, |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
250 |
uint requested_node_index, |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
251 |
size_t* allocated_stat) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
252 |
if (_stats == NULL) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
253 |
return; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
254 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
255 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
256 |
_stats->copy(phase, requested_node_index, allocated_stat); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
257 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
258 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
259 |
void G1NUMA::print_statistics() const { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
260 |
if (_stats == NULL) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
261 |
return; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
262 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
263 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
264 |
_stats->print_statistics(); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
265 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
266 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
267 |
G1NodeIndexCheckClosure::G1NodeIndexCheckClosure(const char* desc, G1NUMA* numa, LogStream* ls) : |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
268 |
_desc(desc), _numa(numa), _ls(ls) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
269 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
270 |
uint num_nodes = _numa->num_active_nodes(); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
271 |
_matched = NEW_C_HEAP_ARRAY(uint, num_nodes, mtGC); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
272 |
_mismatched = NEW_C_HEAP_ARRAY(uint, num_nodes, mtGC); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
273 |
_total = NEW_C_HEAP_ARRAY(uint, num_nodes, mtGC); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
274 |
memset(_matched, 0, sizeof(uint) * num_nodes); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
275 |
memset(_mismatched, 0, sizeof(uint) * num_nodes); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
276 |
memset(_total, 0, sizeof(uint) * num_nodes); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
277 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
278 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
279 |
G1NodeIndexCheckClosure::~G1NodeIndexCheckClosure() { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
280 |
_ls->print("%s: NUMA region verification (id: matched/mismatched/total): ", _desc); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
281 |
const int* numa_ids = _numa->node_ids(); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
282 |
for (uint i = 0; i < _numa->num_active_nodes(); i++) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
283 |
_ls->print("%d: %u/%u/%u ", numa_ids[i], _matched[i], _mismatched[i], _total[i]); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
284 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
285 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
286 |
FREE_C_HEAP_ARRAY(uint, _matched); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
287 |
FREE_C_HEAP_ARRAY(uint, _mismatched); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
288 |
FREE_C_HEAP_ARRAY(uint, _total); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
289 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
290 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
291 |
bool G1NodeIndexCheckClosure::do_heap_region(HeapRegion* hr) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
292 |
// Preferred node index will only have valid node index. |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
293 |
uint preferred_node_index = _numa->preferred_node_index_for_index(hr->hrm_index()); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
294 |
// Active node index may have UnknownNodeIndex. |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
295 |
uint active_node_index = _numa->index_of_address(hr->bottom()); |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
296 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
297 |
if (preferred_node_index == active_node_index) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
298 |
_matched[preferred_node_index]++; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
299 |
} else if (active_node_index != G1NUMA::UnknownNodeIndex) { |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
300 |
_mismatched[preferred_node_index]++; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
301 |
} |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
302 |
_total[preferred_node_index]++; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
303 |
|
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
304 |
return false; |
6530de931b8e
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
59060
diff
changeset
|
305 |
} |