From 9feea361b9a28d941a6ced8369446bd5753286ee Mon Sep 17 00:00:00 2001 From: Waldemar Kozaczuk Date: Fri, 30 Aug 2019 15:03:56 -0400 Subject: [PATCH] syscall: add set_mempolicy and sched_setaffinity needed by libnuma Signed-off-by: Waldemar Kozaczuk --- linux.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/linux.cc b/linux.cc index 4ecb1aeede..9487af35c5 100644 --- a/linux.cc +++ b/linux.cc @@ -156,6 +156,14 @@ static long get_mempolicy(int *policy, unsigned long *nmask, return 0; } +static long set_mempolicy(int policy, unsigned long *nmask, + unsigned long maxnode) +{ + // OSv has very minimal support for NUMA - merely exposes + // all cpus as a single node0 and cannot really apply any meaningful policy + // Therefore we implement this as noop, ignore all arguments and return success + return 0; +} // As explained in the sched_getaffinity(2) manual page, the interface of the // sched_getaffinity() function is slightly different than that of the actual @@ -180,6 +188,14 @@ static int sched_getaffinity_syscall( return ret; } +#define __NR_sched_setaffinity_syscall __NR_sched_setaffinity +static int sched_setaffinity_syscall( + pid_t pid, unsigned len, unsigned long *mask) +{ + return sched_setaffinity( + pid, len, reinterpret_cast(mask)); +} + // Only void* return value of mmap is type casted, as syscall returns long. long long_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { return (long) mmap(addr, length, prot, flags, fd, offset); @@ -419,6 +435,8 @@ long syscall(long number, ...) SYSCALL1(sys_exit_group, int); SYSCALL4(readlinkat, int, const char *, char *, size_t); SYSCALL0(getpid); + SYSCALL3(set_mempolicy, int, unsigned long *, unsigned long); + SYSCALL3(sched_setaffinity_syscall, pid_t, unsigned, unsigned long *); } debug_always("syscall(): unimplemented system call %d\n", number);