-
Notifications
You must be signed in to change notification settings - Fork 8
/
numa_other.go
98 lines (81 loc) · 2.72 KB
/
numa_other.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// +build !linux
package numa
import (
"runtime"
"syscall"
"unsafe"
)
func init() {
// only used for cross-compile
nnodemax = 1
memnodes = NewBitmask(NodePossibleCount())
numanodes = NewBitmask(NodePossibleCount())
nconfigurednode = setupconfigurednodes()
memnodes.Set(0, true)
numanodes.Set(0, true)
ncpumax = runtime.NumCPU()
nconfiguredcpu = runtime.NumCPU()
cpu2node = make(map[int]int, ncpumax)
for i := 0; i < ncpumax; i++ {
cpu2node[i] = 0
}
cpumask := NewBitmask(nconfiguredcpu)
for i := 0; i < nconfiguredcpu; i++ {
cpumask.Set(i, true)
}
node2cpu = map[int]Bitmask{0: cpumask}
}
func setupconfigurednodes() (n int) {
for i := 0; i < NodePossibleCount(); i++ {
numanodes.Set(i, true)
memnodes.Set(i, true)
}
return NodePossibleCount()
}
// GetMemPolicy retrieves the NUMA policy of the calling process or of a
// memory address, depending on the setting of flags.
func GetMemPolicy(nodemask Bitmask, addr unsafe.Pointer, flags int) (mode int, err error) {
return 0, syscall.ENOSYS
}
// SetMemPolicy sets the NUMA memory policy of the calling process, which
// consists of a policy mode and zero or more nodes, to the values specified
// by the mode, nodemask and maxnode arguments.
func SetMemPolicy(mode int, nodemask Bitmask) error {
return syscall.ENOSYS
}
// NodeMemSize64 return the memory total size and free size of given node.
func NodeMemSize64(node int) (total int64, free int64, err error) {
return 0, 0, syscall.ENOSYS
}
// MBind sets the NUMA memory policy, which consists of a policy mode and zero
// or more nodes, for the memory range starting with addr and continuing for
// length bytes. The memory policy defines from which node memory is allocated.
// Details to see manpage of mbind.
func MBind(addr unsafe.Pointer, length, mode, flags int, nodemask Bitmask) error {
return syscall.ENOSYS
}
// GetSchedAffinity writes the affinity mask of the process whose ID is pid
// into the input mask. If pid is zero, then the mask of the calling process
// is returned.
func GetSchedAffinity(pid int, cpumask Bitmask) (int, error) {
return 0, syscall.ENOSYS
}
// SetSchedAffinity sets the CPU affinity mask of the process whose ID
// is pid to the value specified by mask. If pid is zero, then the calling
// process is used.
func SetSchedAffinity(pid int, cpumask Bitmask) error {
return syscall.ENOSYS
}
// GetCPUAndNode returns the node id and cpu id which current caller running on.
func GetCPUAndNode() (cpu int, node int) {
cpu = runtime_procPin()
runtime_procUnpin()
return cpu % ncpumax, nnodemax - 1
}
// Implemented in runtime.
//go:linkname runtime_procPin runtime.procPin
//go:nosplit
func runtime_procPin() int
//go:linkname runtime_procUnpin runtime.procUnpin
//go:nosplit
func runtime_procUnpin()