linux adding some NUMA support

This commit is contained in:
David CARLIER 2023-05-12 22:13:25 +01:00 committed by Veikka Tuominen
parent cceadf52ba
commit 6f418c11e1
2 changed files with 32 additions and 0 deletions

View File

@ -371,3 +371,19 @@ pub const dirent64 = struct {
d_type: u8,
d_name: [256]u8,
};
pub const MPOL = struct {
pub const F_NODE = 1 << 0;
pub const F_ADDR = 1 << 1;
pub const F_MEMS_ALLOWED = 1 << 2;
/// flags for SYS_mbind
pub const MF_STRICT = 1 << 0;
pub const MF_MOVE = 1 << 1;
pub const MF_MOVE_ALL = 1 << 2;
pub const MF_LAZY = 1 << 3;
pub const MF_INTERNAL = 1 << 4;
pub const MF_VALID = MPOL.MF_STRICT | MPOL.MF_MOVE | MPOL.MOVE_ALL;
};
pub extern "c" fn getcpu(cpu: *c_uint, node: *c_uint) c_int;
pub extern "c" fn sched_getcpu() c_int;

View File

@ -1519,6 +1519,22 @@ pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize {
return 0;
}
pub fn getcpu(cpu: *u32, node: *u32) usize {
return syscall3(.getcpu, cpu, node, null);
}
pub fn sched_getcpu() usize {
var cpu: u32 = undefined;
const rc = syscall3(.getcpu, &cpu, null, null);
if (@bitCast(isize, rc) < 0) return rc;
return @intCast(usize, cpu);
}
/// libc has no wrapper for this syscall
pub fn mbind(addr: ?*anyopaque, len: u32, mode: i32, nodemask: *const u32, maxnode: u32, flags: u32) usize {
return syscall6(.mbind, addr, len, mode, nodemask, maxnode, flags);
}
pub fn epoll_create() usize {
return epoll_create1(0);
}