[COMMIT osv master] syscalls: add getcpu

4 views
Skip to first unread message

Commit Bot

unread,
Oct 12, 2023, 10:19:02 PM10/12/23
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

syscalls: add getcpu

The implementation assumes single NUMA node

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/linux.cc b/linux.cc
--- a/linux.cc
+++ b/linux.cc
@@ -382,6 +382,20 @@ static long sys_getcwd(char *buf, unsigned long size)
return strlen(ret) + 1;
}

+#define __NR_sys_getcpu __NR_getcpu
+static long sys_getcpu(unsigned int *cpu, unsigned int *node, void *tcache)
+{
+ if (cpu) {
+ *cpu = sched::cpu::current()->id;
+ }
+
+ if (node) {
+ *node = 0;
+ }
+
+ return 0;
+}
+
#define __NR_sys_ioctl __NR_ioctl
//
// We need to define explicit sys_ioctl that takes these 3 parameters to conform
@@ -591,6 +605,7 @@ OSV_LIBC_API long syscall(long number, ...)
SYSCALL4(clock_nanosleep, clockid_t, int, const struct timespec *, struct timespec *);
SYSCALL4(mknodat, int, const char *, mode_t, dev_t);
SYSCALL5(statx, int, const char *, int, unsigned int, struct statx *);
+ SYSCALL3(sys_getcpu, unsigned int *, unsigned int *, void *);
}

debug_always("syscall(): unimplemented system call %d\n", number);
Reply all
Reply to author
Forward
0 new messages