Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp
40971 views
1
/*
2
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
#include "gc/z/zCPU.inline.hpp"
25
#include "gc/z/zErrno.hpp"
26
#include "gc/z/zNUMA.hpp"
27
#include "gc/z/zSyscall_linux.hpp"
28
#include "runtime/globals.hpp"
29
#include "runtime/os.hpp"
30
#include "utilities/debug.hpp"
31
32
void ZNUMA::pd_initialize() {
33
_enabled = UseNUMA;
34
}
35
36
uint32_t ZNUMA::count() {
37
if (!_enabled) {
38
// NUMA support not enabled
39
return 1;
40
}
41
42
return os::Linux::numa_max_node() + 1;
43
}
44
45
uint32_t ZNUMA::id() {
46
if (!_enabled) {
47
// NUMA support not enabled
48
return 0;
49
}
50
51
return os::Linux::get_node_by_cpu(ZCPU::id());
52
}
53
54
uint32_t ZNUMA::memory_id(uintptr_t addr) {
55
if (!_enabled) {
56
// NUMA support not enabled, assume everything belongs to node zero
57
return 0;
58
}
59
60
uint32_t id = (uint32_t)-1;
61
62
if (ZSyscall::get_mempolicy((int*)&id, NULL, 0, (void*)addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
63
ZErrno err;
64
fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string());
65
}
66
67
assert(id < count(), "Invalid NUMA id");
68
69
return id;
70
}
71
72