File: mempolicy.c

package info (click to toggle)
systemtap 4.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 38,260 kB
  • sloc: cpp: 77,147; ansic: 61,828; xml: 49,277; exp: 42,244; sh: 11,046; python: 2,772; perl: 2,252; tcl: 1,305; makefile: 1,086; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (86 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* COVERAGE: set_mempolicy get_mempolicy */

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/mempolicy.h>

#if defined(__NR_get_mempolicy) && defined(__NR_set_mempolicy)
// Since we don't want to require the libnuma development and library
// packages, we'll define our own routines.

static inline int
get_mempolicy(int *mode, unsigned long *nodemask, unsigned long maxnode,
	      unsigned long addr, unsigned long flags)
{
    return syscall(__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags);
}

static inline int
set_mempolicy(int mode, unsigned long *nodemask, unsigned long maxnode)
{
    return syscall(__NR_set_mempolicy, mode, nodemask, maxnode);
}

int main(int argc, char **argv)
{
    int mode;

    // ENOSYS expected on i686 kernels, so expect it.

    // Get the default policy. Notice we're not specifying a node
    // mask. Figuring out the proper size without the numa library is
    // tricky, so don't bother. 
    get_mempolicy(&mode, NULL, 0, 0, 0);
    //staptest// [[[[get_mempolicy (XXXX, 0x0, 0, 0x0, 0x0) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]]

    set_mempolicy(MPOL_DEFAULT, NULL, 0);
    //staptest// [[[[set_mempolicy (MPOL_DEFAULT, 0x0, 0)!!!!ni_syscall ()]]]] = NNNN

    /* Limit testing. */

    get_mempolicy((int *)-1, NULL, 0, 0, MPOL_F_NODE);
    //staptest// [[[[get_mempolicy (0x[f]+, 0x0, 0, 0x0, MPOL_F_NODE)!!!!ni_syscall ()]]]] = NNNN

    get_mempolicy(NULL, (unsigned long *)-1, 0, 0, MPOL_F_NODE | MPOL_F_ADDR);
    //staptest// [[[[get_mempolicy (0x0, 0x[f]+, 0, 0x0, MPOL_F_NODE|MPOL_F_ADDR)!!!!ni_syscall ()]]]] = NNNN

    get_mempolicy(NULL, NULL, -1, 0, MPOL_F_ADDR);
#if __WORDSIZE == 64
    //staptest// [[[[get_mempolicy (0x0, 0x0, 18446744073709551615, 0x0, MPOL_F_ADDR)!!!!ni_syscall ()]]]] = NNNN
#else
    //staptest// [[[[get_mempolicy (0x0, 0x0, 4294967295, 0x0, MPOL_F_ADDR)!!!!ni_syscall ()]]]] = NNNN
#endif

    get_mempolicy(NULL, NULL, 0, 0, -1);
    //staptest// [[[[get_mempolicy (0x0, 0x0, 0, 0x0, MPOL[^ ]+|XXXX)!!!!ni_syscall ()]]]] = NNNN

    set_mempolicy(-1, NULL, 0);
    //staptest// [[[[set_mempolicy (0x[f]+, 0x0, 0)!!!!ni_syscall ()]]]] = NNNN

#ifdef MPOL_F_STATIC_NODES
    set_mempolicy(MPOL_F_STATIC_NODES | MPOL_DEFAULT, NULL, 0);
    //staptest// [[[[set_mempolicy (MPOL_F_STATIC_NODES|MPOL_DEFAULT, 0x0, 0)!!!!ni_syscall ()]]]] = NNNN
#endif

    set_mempolicy(MPOL_PREFERRED, (unsigned long *)-1, 0);
    //staptest// [[[[set_mempolicy (MPOL_PREFERRED, 0x[f]+, 0)!!!!ni_syscall ()]]]] = NNNN

    set_mempolicy(MPOL_BIND, NULL, -1);
#if __WORDSIZE == 64
    //staptest// [[[[set_mempolicy (MPOL_BIND, 0x0, 18446744073709551615)!!!!ni_syscall ()]]]] = NNNN
#else
    //staptest// [[[[set_mempolicy (MPOL_BIND, 0x0, 4294967295)!!!!ni_syscall ()]]]] = NNNN
#endif

    return 0;
}
#else
int main()
{
    return 0;
}
#endif