| 1 |
/* COVERAGE: set_mempolicy get_mempolicy */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE |
| 4 |
#include <stdio.h> |
| 5 |
#include <stdlib.h> |
| 6 |
#include <errno.h> |
| 7 |
#include <unistd.h> |
| 8 |
#include <sys/syscall.h> |
| 9 |
#include <linux/mempolicy.h> |
| 10 |
|
| 11 |
#if defined(__NR_get_mempolicy) && defined(__NR_set_mempolicy) |
| 12 |
// Since we don't want to require the libnuma development and library |
| 13 |
// packages, we'll define our own routines. |
| 14 |
|
| 15 |
static inline int |
| 16 |
get_mempolicy(int *mode, unsigned long *nodemask, unsigned long maxnode, |
| 17 |
unsigned long addr, unsigned long flags) |
| 18 |
{ |
| 19 |
return syscall(__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags); |
| 20 |
} |
| 21 |
|
| 22 |
static inline int |
| 23 |
set_mempolicy(int mode, unsigned long *nodemask, unsigned long maxnode) |
| 24 |
{ |
| 25 |
return syscall(__NR_set_mempolicy, mode, nodemask, maxnode); |
| 26 |
} |
| 27 |
|
| 28 |
int main(int argc, char **argv) |
| 29 |
{ |
| 30 |
int mode; |
| 31 |
|
| 32 |
// ENOSYS expected on i686 kernels, so expect it. |
| 33 |
|
| 34 |
// Get the default policy. Notice we're not specifying a node |
| 35 |
// mask. Figuring out the proper size without the numa library is |
| 36 |
// tricky, so don't bother. |
| 37 |
get_mempolicy(&mode, NULL, 0, 0, 0); |
| 38 |
//staptest// [[[[get_mempolicy (XXXX, 0x0, 0, 0x0, 0x0) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]] |
| 39 |
|
| 40 |
set_mempolicy(MPOL_DEFAULT, NULL, 0); |
| 41 |
//staptest// [[[[set_mempolicy (MPOL_DEFAULT, 0x0, 0)!!!!ni_syscall ()]]]] = NNNN |
| 42 |
|
| 43 |
/* Limit testing. */ |
| 44 |
|
| 45 |
get_mempolicy((int *)-1, NULL, 0, 0, MPOL_F_NODE); |
| 46 |
//staptest// [[[[get_mempolicy (0x[f]+, 0x0, 0, 0x0, MPOL_F_NODE)!!!!ni_syscall ()]]]] = NNNN |
| 47 |
|
| 48 |
get_mempolicy(NULL, (unsigned long *)-1, 0, 0, MPOL_F_NODE | MPOL_F_ADDR); |
| 49 |
//staptest// [[[[get_mempolicy (0x0, 0x[f]+, 0, 0x0, MPOL_F_NODE|MPOL_F_ADDR)!!!!ni_syscall ()]]]] = NNNN |
| 50 |
|
| 51 |
get_mempolicy(NULL, NULL, -1, 0, MPOL_F_ADDR); |
| 52 |
#if __WORDSIZE == 64 |
| 53 |
//staptest// [[[[get_mempolicy (0x0, 0x0, 18446744073709551615, 0x0, MPOL_F_ADDR)!!!!ni_syscall ()]]]] = NNNN |
| 54 |
#else |
| 55 |
//staptest// [[[[get_mempolicy (0x0, 0x0, 4294967295, 0x0, MPOL_F_ADDR)!!!!ni_syscall ()]]]] = NNNN |
| 56 |
#endif |
| 57 |
|
| 58 |
get_mempolicy(NULL, NULL, 0, 0, -1); |
| 59 |
//staptest// [[[[get_mempolicy (0x0, 0x0, 0, 0x0, MPOL[^ ]+|XXXX)!!!!ni_syscall ()]]]] = NNNN |
| 60 |
|
| 61 |
set_mempolicy(-1, NULL, 0); |
| 62 |
//staptest// [[[[set_mempolicy (0x[f]+, 0x0, 0)!!!!ni_syscall ()]]]] = NNNN |
| 63 |
|
| 64 |
#ifdef MPOL_F_STATIC_NODES |
| 65 |
set_mempolicy(MPOL_F_STATIC_NODES | MPOL_DEFAULT, NULL, 0); |
| 66 |
//staptest// [[[[set_mempolicy (MPOL_F_STATIC_NODES|MPOL_DEFAULT, 0x0, 0)!!!!ni_syscall ()]]]] = NNNN |
| 67 |
#endif |
| 68 |
|
| 69 |
set_mempolicy(MPOL_PREFERRED, (unsigned long *)-1, 0); |
| 70 |
//staptest// [[[[set_mempolicy (MPOL_PREFERRED, 0x[f]+, 0)!!!!ni_syscall ()]]]] = NNNN |
| 71 |
|
| 72 |
set_mempolicy(MPOL_BIND, NULL, -1); |
| 73 |
#if __WORDSIZE == 64 |
| 74 |
//staptest// [[[[set_mempolicy (MPOL_BIND, 0x0, 18446744073709551615)!!!!ni_syscall ()]]]] = NNNN |
| 75 |
#else |
| 76 |
//staptest// [[[[set_mempolicy (MPOL_BIND, 0x0, 4294967295)!!!!ni_syscall ()]]]] = NNNN |
| 77 |
#endif |
| 78 |
|
| 79 |
return 0; |
| 80 |
} |
| 81 |
#else |
| 82 |
int main() |
| 83 |
{ |
| 84 |
return 0; |
| 85 |
} |
| 86 |
#endif |