1*346b59f2SPeter Shier /* SPDX-License-Identifier: GPL-2.0-only */
2*346b59f2SPeter Shier /*
3*346b59f2SPeter Shier * tools/testing/selftests/kvm/include/numaif.h
4*346b59f2SPeter Shier *
5*346b59f2SPeter Shier * Copyright (C) 2020, Google LLC.
6*346b59f2SPeter Shier *
7*346b59f2SPeter Shier * This work is licensed under the terms of the GNU GPL, version 2.
8*346b59f2SPeter Shier *
9*346b59f2SPeter Shier * Header file that provides access to NUMA API functions not explicitly
10*346b59f2SPeter Shier * exported to user space.
11*346b59f2SPeter Shier */
12*346b59f2SPeter Shier
13*346b59f2SPeter Shier #ifndef SELFTEST_KVM_NUMAIF_H
14*346b59f2SPeter Shier #define SELFTEST_KVM_NUMAIF_H
15*346b59f2SPeter Shier
16*346b59f2SPeter Shier #define __NR_get_mempolicy 239
17*346b59f2SPeter Shier #define __NR_migrate_pages 256
18*346b59f2SPeter Shier
19*346b59f2SPeter Shier /* System calls */
get_mempolicy(int * policy,const unsigned long * nmask,unsigned long maxnode,void * addr,int flags)20*346b59f2SPeter Shier long get_mempolicy(int *policy, const unsigned long *nmask,
21*346b59f2SPeter Shier unsigned long maxnode, void *addr, int flags)
22*346b59f2SPeter Shier {
23*346b59f2SPeter Shier return syscall(__NR_get_mempolicy, policy, nmask,
24*346b59f2SPeter Shier maxnode, addr, flags);
25*346b59f2SPeter Shier }
26*346b59f2SPeter Shier
migrate_pages(int pid,unsigned long maxnode,const unsigned long * frommask,const unsigned long * tomask)27*346b59f2SPeter Shier long migrate_pages(int pid, unsigned long maxnode,
28*346b59f2SPeter Shier const unsigned long *frommask,
29*346b59f2SPeter Shier const unsigned long *tomask)
30*346b59f2SPeter Shier {
31*346b59f2SPeter Shier return syscall(__NR_migrate_pages, pid, maxnode, frommask, tomask);
32*346b59f2SPeter Shier }
33*346b59f2SPeter Shier
34*346b59f2SPeter Shier /* Policies */
35*346b59f2SPeter Shier #define MPOL_DEFAULT 0
36*346b59f2SPeter Shier #define MPOL_PREFERRED 1
37*346b59f2SPeter Shier #define MPOL_BIND 2
38*346b59f2SPeter Shier #define MPOL_INTERLEAVE 3
39*346b59f2SPeter Shier
40*346b59f2SPeter Shier #define MPOL_MAX MPOL_INTERLEAVE
41*346b59f2SPeter Shier
42*346b59f2SPeter Shier /* Flags for get_mem_policy */
43*346b59f2SPeter Shier #define MPOL_F_NODE (1<<0) /* return next il node or node of address */
44*346b59f2SPeter Shier /* Warning: MPOL_F_NODE is unsupported and
45*346b59f2SPeter Shier * subject to change. Don't use.
46*346b59f2SPeter Shier */
47*346b59f2SPeter Shier #define MPOL_F_ADDR (1<<1) /* look up vma using address */
48*346b59f2SPeter Shier #define MPOL_F_MEMS_ALLOWED (1<<2) /* query nodes allowed in cpuset */
49*346b59f2SPeter Shier
50*346b59f2SPeter Shier /* Flags for mbind */
51*346b59f2SPeter Shier #define MPOL_MF_STRICT (1<<0) /* Verify existing pages in the mapping */
52*346b59f2SPeter Shier #define MPOL_MF_MOVE (1<<1) /* Move pages owned by this process to conform to mapping */
53*346b59f2SPeter Shier #define MPOL_MF_MOVE_ALL (1<<2) /* Move every page to conform to mapping */
54*346b59f2SPeter Shier
55*346b59f2SPeter Shier #endif /* SELFTEST_KVM_NUMAIF_H */
56