Documentation ¶
Index ¶
- Constants
- Variables
- func Bind(mask Bitmask) error
- func CPUCount() int
- func CPUPossibleCount() int
- func CPUToNode(cpu int) (int, error)
- func ELFGNUHash(name string) (h uint32)
- func ELFHash(name string) (h uint32)
- func ELFstBind(val byte) byte
- func ELFstType(val byte) byte
- func GetCPUAndNode() (cpu, node int)
- func GetMemPolicy(nodemask Bitmask, addr unsafe.Pointer, flags int) (mode int, err error)
- func GetSchedAffinity(pid int, cpumask Bitmask) (int, error)
- func MBind(addr unsafe.Pointer, length, mode, flags int, nodemask Bitmask) (err error)
- func MaxNodeID() int
- func MaxPossibleNodeID() int
- func NUMAavailable() bool
- func NodeCount() int
- func NodeMemSize64(node int) (total, free int64, err error)
- func NodePossibleCount() int
- func RunOnNode(node int) (err error)
- func RunOnNodeMask(mask Bitmask) error
- func SetMemPolicy(mode int, nodemask Bitmask) (err error)
- func SetSchedAffinity(pid int, cpumask Bitmask) error
- func VdsoSym(name string) uintptr
- type Bitmask
Constants ¶
const ( MPolDefault = iota MPolPreferred MPolBind MPolInterleave MPolLocal MPolMax // MPolFStaticNodes since Linux 2.6.26 ... // A nonempty nodemask specifies physical node ids. Linux does will // not remap the nodemask when the process moves to a different cpuset // context, nor when the set of nodes allowed by the process current // cpuset context changes. MPolFStaticNodes = 1 << 15 // MPolFRelativeNodes since Linux 2.6.26 ... // A nonempty nodemask specifies node ids that are relative to the set // of node ids allowed by the process's current cpuset. MPolFRelativeNodes = 1 << 14 // MPolModeFlags is the union of all possible optional mode flags passed // to either SetMemPolicy() or mbind(). MPolModeFlags = MPolFStaticNodes | MPolFRelativeNodes )
const block
const ( // MPolFNode is unsupported and subject to change. // Flags for get_mem_policy return next IL node or node of address MPolFNode = 1 << iota // MPolFAddr looks up vma using address MPolFAddr // MPolFMemsAllowed queries nodes allowed in cpuset MPolFMemsAllowed )
const ( // MPolMFStrict verifies existing pages in the mapping Flags for mbind MPolMFStrict = 1 << iota // MPolMFMove moves pages owned by this process to conform to mapping MPolMFMove // MPolMFMoveAll moves every page to conform to mapping MPolMFMoveAll // MpolMfLazy modifies '_MOVE: lazy migrate on fault MpolMfLazy // PolMfInternal is for internal flags starting here PolMfInternal // MPolMFValid = ... MPolMFValid = MPolMFStrict | MPolMFMove | MPolMFMoveAll )
const ( // AtNull ... AtNull = 0 // End of vector // AtSysInfoEHdr ... AtSysInfoEHdr = 33 // PtLoad ... PtLoad = 1 /* Loadable program segment */ // PtDynamic ... PtDynamic = 2 /* Dynamic linking information */ // DtNull ... DtNull = 0 /* Marks end of dynamic section */ // DtHash ... DtHash = 4 /* Dynamic symbol hash table */ // DtStrTab ... DtStrTab = 5 /* Address of string table */ // DtSymTab ... DtSymTab = 6 /* Address of symbol table */ // DtGNUHash ... DtGNUHash = 0x6ffffef5 /* GNU-style dynamic symbol hash table */ // DtVerSym ... DtVerSym = 0x6ffffff0 // DtVerDef ... DtVerDef = 0x6ffffffc // VerFlagBase ... VerFlagBase = 0x1 /* Version definition of file itself */ // ShnUndef ... ShnUndef = 0 /* Undefined section */ // ShtDynSym ... ShtDynSym = 11 /* Dynamic linker symbol table */ // SttFunc ... SttFunc = 2 /* Symbol is a code object */ // SttNoType ... SttNoType = 0 /* Symbol type is not specified */ // StbGlobal ... StbGlobal = 1 /* Global symbol */ // StbWeak ... StbWeak = 2 /* Weak symbol */ // EINIdent ... EINIdent = 16 // VdsoSymTabSize ... VdsoSymTabSize = vdsoArrayMax / unsafe.Sizeof(elfSym{}) // VdsoSymStringsSize ... VdsoSymStringsSize = vdsoArrayMax // byte )
Variables ¶
var ( // NUMAnodemax is the maximum possible node count. It represents // the absolute highest node count supported on the local platform. // NUMAnodemax =@nodemask_sz+1 NUMAnodemax int // NUMAconfigurednode represents the maximum possible number of // configured or enabled nodes supported on the local platform. // NUMAconfigurednode =@maxconfigurednode+1 NUMAconfigurednode int // NUMAcpuMax is the maximum possible CPU count, which represents // the absolute highest CPU count supported on the local platform. // NUMAcpuMax =@cpumask_sz+1 NUMAcpuMax int // NUMAconfiguredcpu is the number of currently configured CPUs. // NUMAconfiguredcpu =@maxconfiguredcpu NUMAconfiguredcpu int )
var NUMAfastway = cpuid.HasFeature(cpuid.RDTSCP)
NUMAfastway ...
Functions ¶
func Bind ¶
Bind bind current process on those nodes which given by a bitmask.
func CPUCount ¶
func CPUCount() int
CPUCount returns the current configured(enabled/detected) cpu count, which is different with runtime.NumCPU().
func CPUPossibleCount ¶
func CPUPossibleCount() int
CPUPossibleCount returns the possible cpu count current platform supports
func CPUToNode ¶
CPUToNode returns the node id by given cpu id.
func GetCPUAndNode ¶
func GetCPUAndNode() (cpu, node int)
GetCPUAndNode returns the node and cpu which current caller is running on.
func GetMemPolicy ¶
GetMemPolicy retrieves the NUMA policy of the calling process or of a memory address, depending on the setting of flags. Details to see manpage of get_mempolicy.
If flags is specified as 0, then information about the calling process's default policy (as set by set_mempolicy(2)) is returned. The policy returned [mode and nodemask] may be used to restore the process's policy to its state at the time of the call to get_mempolicy() using set_mempolicy(2).
If flags specifies MPolFMemsAllowed (available since Linux 2.6.24), the mode argument is ignored and the set of nodes [memories] that the process is allowed to specify in subsequent calls to mbind(2) or set_mempolicy(2) [in the absence of any mode flags] is returned in nodemask. It is not permitted to combine MPolFMemsAllowed with either MPolFAddr or MPolFNode.
If flags specifies MPolFAddr, then information is returned about the policy governing the memory address given in addr. This policy may be different from the process's default policy if mbind(2) or one of the helper functions described in numa(3) has been used to establish a policy for the memory range containing addr.
If flags specifies both MPolFNode and MPolFAddr, get_mempolicy() will return the node ID of the node on which the address addr is allocated into the location pointed to by mode. If no page has yet been allocated for the specified address, get_mempolicy() will allocate a page as if the process had performed a read [load] access to that address, and return the ID of the node where that page was allocated.
If flags specifies MPolFNode, but not MPolFAddr, and the process's current policy is MPolInterleave, then get_mempolicy() will return in the location pointed to by a non-NULL mode argument, the node ID of the next node that will be used for interleaving of internal kernel pages allocated on behalf of the process. These allocations include pages for memory mapped files in process memory ranges mapped using the mmap(2) call with the MAP_PRIVATE flag for read accesses, and in memory ranges mapped with the MAP_SHARED flag for all accesses.
func GetSchedAffinity ¶
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 MBind ¶
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. If the memory range specified by the addr and length arguments includes an "anonymous" region of memory that is a region of memory created using the mmap(2) system call with the MAP_ANONYMOUS or a memory mapped file, mapped using the mmap(2) system call with the MAP_PRIVATE flag, pages will be allocated only according to the specified policy when the application writes [stores] to the page. For anonymous regions, an initial read access will use a shared page in the kernel containing all zeros. For a file mapped with MAP_PRIVATE, an initial read access will allocate pages according to the process policy of the process that causes the page to be allocated. This may not be the process that called mbind(). The specified policy will be ignored for any MAP_SHARED mappings in the specified memory range. Rather the pages will be allocated according to the process policy of the process that caused the page to be allocated. Again, this may not be the process that called mbind(). If the specified memory range includes a shared memory region created using the shmget(2) system call and attached using the shmat(2) system call, pages allocated for the anonymous or shared memory region will be allocated according to the policy specified, regardless which process attached to the shared memory segment causes the allocation. If, however, the shared memory region was created with the SHM_HUGETLB flag, the huge pages will be allocated according to the policy specified only if the page allocation is caused by the process that calls mbind() for that region. By default, mbind() has an effect only for new allocations; if the pages inside the range have been already touched before setting the policy, then the policy has no effect. This default behavior may be overridden by the MPolMFMove and MPolMFMoveAll flags described below.
func MaxNodeID ¶
func MaxNodeID() int
MaxNodeID returns the max id of current configured NUMA nodes.
func MaxPossibleNodeID ¶
func MaxPossibleNodeID() int
MaxPossibleNodeID returns the max possible node id this platform supports The possible node id always larger than max node id.
func NUMAavailable ¶
func NUMAavailable() bool
NUMAavailable returns current platform is whether support NUMA.
func NodeCount ¶
func NodeCount() int
NodeCount returns the count of current configured NUMA nodes. NOTE: this function's behavior matches the documentation (ie: it returns a count of nodes with memory) despite the poor function naming. We also cannot use the similarly poorly named numa_all_nodes_ptr as it only tracks nodes with memory from which the calling process can allocate. Think sparse nodes, memory-less nodes, cpusets.
func NodeMemSize64 ¶
NodeMemSize64 return the memory total size and free size of given node.
func NodePossibleCount ¶
func NodePossibleCount() int
NodePossibleCount returns the possible NUMA nodes count of current platform supported.
func RunOnNode ¶
RunOnNode set current process run on given node. The special node "-1" will set current process on all available nodes.
func RunOnNodeMask ¶
RunOnNodeMask run current process to the given nodes.
func SetMemPolicy ¶
SetMemPolicy defines the default policy for the process. The process policy governs allocation of pages in the process's address space outside of memory ranges controlled by a more specific policy set by mbind(2). The process default policy also controls allocation of any pages for memory mapped files mapped using the mmap(2) call with the MAP_PRIVATE flag and that are only read [loaded] from by the process and of memory mapped files mapped using the mmap(2) call with the MAP_SHARED flag, regardless of the access type. The policy is applied only when a new page is allocated for the process. For anonymous memory this is when the page is first touched by the application. The mode argument must specify one of MPolDefault, MPolBind, MPolInterleave or PolPreferred. All modes except MPolDefault require the caller to specify via the nodemask argument one or more nodes. The mode argument may also include an optional mode flag. The supported mode flags are: MPolFStaticNodes and MPolFRelativeNodes. Where a nodemask is required, it must contain at least one node that is on-line, allowed by the process current cpuset context, [unless the MPolFStaticNodes mode flag is specified], and contains memory. If the MPolFStaticNodes is set in mode and a required nodemask contains no nodes that are allowed by the process current cpuset context, the memory policy reverts to local allocation. This effectively overrides the specified policy until the process cpuset context includes one or more of the nodes specified by nodemask.
func SetSchedAffinity ¶
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.
Types ¶
type Bitmask ¶
type Bitmask []uint64
Bitmask is used for syscall or other operation in NUMA API.
func GetMemAllowedNodeMask ¶
GetMemAllowedNodeMask returns the bitmask of current process allowed running nodes.
func NewBitmask ¶
NewBitmask returns a bitmask with length always rounded to a multiple of sizeof(uint64). The input param n represents the bit count of this bitmask.
func NodeToCPUMask ¶
NodeToCPUMask returns the cpumask of given node id.
func RunningCPUMask ¶
RunningCPUMask return the cpu bitmask of current process running on.
func RunningNodesMask ¶
RunningNodesMask return the bitmask of current process using NUMA nodes.
func (Bitmask) OnesCount ¶
OnesCount returns the number of one bits ("population count") in this bitmask.
func (Bitmask) String ¶
String returns the hex string of this bitmask.