Skip to content

Commit 5b52bf1

Browse files
Merge pull request #264 from kiyoungkim-gg/patch-1
Fix ESRCH in sched_setaffinity due to glibc TID caching with clone3
2 parents 6356dee + a1dd160 commit 5b52bf1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

cpu.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <sched.h>
2626
#include <stdint.h>
2727
#include <string.h>
28+
#include <sys/syscall.h>
2829
#include <unistd.h>
2930

3031
#include <memory>
@@ -127,7 +128,7 @@ bool initCpu(nsj_t* nsj) {
127128
(size_t)CPU_COUNT(new_mask.get()), available_cpus, (size_t)CPU_COUNT(orig_mask.get()),
128129
listCpusInSet(orig_mask.get()).c_str());
129130

130-
if (sched_setaffinity(0, CPU_ALLOC_SIZE(CPU_SETSIZE), new_mask.get()) == -1) {
131+
if (util::syscall(__NR_sched_setaffinity, 0, CPU_ALLOC_SIZE(CPU_SETSIZE), (uintptr_t)new_mask.get()) == -1) {
131132
PLOG_W("sched_setaffinity(mask=%s size=%zu max_cpus=%zu (CPU_COUNT=%zu)) failed",
132133
listCpusInSet(new_mask.get()).c_str(), (size_t)CPU_ALLOC_SIZE(CPU_SETSIZE),
133134
(size_t)nsj->njc.max_cpus(), (size_t)CPU_COUNT(new_mask.get()));

0 commit comments

Comments
 (0)