set_mempolicy on x64
set default NUMA memory policy for a thread and its children
sys_set_mempolicy(int mode, const unsigned long *nmask, unsigned long maxnode)
| number | 238 (0xee) |
|---|---|
| abi | common |
| entry point | sys_set_mempolicy |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | set_mempolicy(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 238, the syscall number |
rdi | int mode |
rsi | const unsigned long *nmask |
rdx | unsigned long maxnode |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 276
- arm64 237
- arm 321
- riscv64 237
- ia32 276
- x32 1073742062
- loongarch64 237
- ppc64 261
- ppc 261
- s390x 270
- mips64 5229
- mipsn32 6233
- mipso32 4270
- arc 237
- csky 237
- frv 276, removed in 4.17
- hexagon 237
- ia64 1261, removed in 6.7
- m68k 270
- metag 237, removed in 4.17
- microblaze 276
- mn10300 276, removed in 4.17
- nds32 237, removed in 5.18
- nios2 237
- openrisc 237
- parisc 262
- score 237, removed in 4.17
- sh 276
- sparc 305
- sparc64 305
- tilegx 237, removed in 4.17
- tilepro 237, removed in 4.17
- xtensa 265
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/set_mempolicy