]>
Commit | Line | Data |
---|---|---|
314093c9 | 1 | .\" Copyright 2003,2004 Andi Kleen, SuSE Labs. |
45ca54fe | 2 | .\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard |
314093c9 | 3 | .\" |
9f882130 | 4 | .\" %%%LICENSE_START(VERBATIM_PROF) |
314093c9 MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
314093c9 MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
c13182ef MK |
17 | .\" the use of the information contained herein. |
18 | .\" | |
314093c9 MK |
19 | .\" Formatted or processed versions of this manual, if unaccompanied by |
20 | .\" the source, must acknowledge the copyright and authors of this work. | |
9f882130 | 21 | .\" %%%LICENSE_END |
c13182ef | 22 | .\" |
314093c9 | 23 | .\" 2006-02-03, mtk, substantial wording changes and other improvements |
9f5682a8 MK |
24 | .\" 2007-08-27, Lee Schermerhorn <Lee.Schermerhorn@hp.com> |
25 | .\" more precise specification of behavior. | |
314093c9 | 26 | .\" |
e198a28d | 27 | .\" FIXME |
1f3583c5 MK |
28 | .\" Linux 3.8 added MPOL_MF_LAZY, which needs to be documented. |
29 | .\" Does it also apply for move_pages()? | |
e198a28d | 30 | .\" |
e198a28d MK |
31 | .\" commit b24f53a0bea38b266d219ee651b22dba727c44ae |
32 | .\" Author: Lee Schermerhorn <lee.schermerhorn@hp.com> | |
33 | .\" Date: Thu Oct 25 14:16:32 2012 +0200 | |
34 | .\" | |
4b8c67d9 | 35 | .TH MBIND 2 2017-09-15 Linux "Linux Programmer's Manual" |
314093c9 | 36 | .SH NAME |
f68512e9 | 37 | mbind \- set memory policy for a memory range |
314093c9 | 38 | .SH SYNOPSIS |
521bf584 | 39 | .nf |
314093c9 | 40 | .B "#include <numaif.h>" |
68e4db0a | 41 | .PP |
b93d8cca RV |
42 | .BI "long mbind(void *" addr ", unsigned long " len ", int " mode , |
43 | .BI " const unsigned long *" nodemask ", unsigned long " maxnode , | |
44 | .BI " unsigned " flags ); | |
68e4db0a | 45 | .PP |
4ed3353d | 46 | Link with \fI\-lnuma\fP. |
521bf584 | 47 | .fi |
314093c9 MK |
48 | .SH DESCRIPTION |
49 | .BR mbind () | |
9f5682a8 MK |
50 | sets the NUMA memory policy, |
51 | which consists of a policy mode and zero or more nodes, | |
314093c9 | 52 | for the memory range starting with |
14f5ae6d | 53 | .I addr |
314093c9 | 54 | and continuing for |
0daa9e92 | 55 | .I len |
c13182ef | 56 | bytes. |
9f5682a8 | 57 | The memory policy defines from which node memory is allocated. |
efeece04 | 58 | .PP |
9f5682a8 | 59 | If the memory range specified by the |
14f5ae6d | 60 | .IR addr " and " len |
9f5682a8 MK |
61 | arguments includes an "anonymous" region of memory\(emthat is |
62 | a region of memory created using the | |
63 | .BR mmap (2) | |
64 | system call with the | |
65 | .BR MAP_ANONYMOUS \(emor | |
9a141bfb | 66 | a memory-mapped file, mapped using the |
9f5682a8 MK |
67 | .BR mmap (2) |
68 | system call with the | |
69 | .B MAP_PRIVATE | |
33a0ccb2 | 70 | flag, pages will be allocated only according to the specified |
8831d464 | 71 | policy when the application writes (stores) to the page. |
9f5682a8 MK |
72 | For anonymous regions, an initial read access will use a shared |
73 | page in the kernel containing all zeros. | |
74 | For a file mapped with | |
75 | .BR MAP_PRIVATE , | |
76 | an initial read access will allocate pages according to the | |
db0afb54 MK |
77 | memory policy of the thread that causes the page to be allocated. |
78 | This may not be the thread that called | |
9f5682a8 | 79 | .BR mbind (). |
efeece04 | 80 | .PP |
9f5682a8 MK |
81 | The specified policy will be ignored for any |
82 | .B MAP_SHARED | |
83 | mappings in the specified memory range. | |
db0afb54 MK |
84 | Rather the pages will be allocated according to the memory policy |
85 | of the thread that caused the page to be allocated. | |
86 | Again, this may not be the thread that called | |
9f5682a8 | 87 | .BR mbind (). |
efeece04 | 88 | .PP |
9f5682a8 MK |
89 | If the specified memory range includes a shared memory region |
90 | created using the | |
91 | .BR shmget (2) | |
92 | system call and attached using the | |
93 | .BR shmat (2) | |
94 | system call, | |
95 | pages allocated for the anonymous or shared memory region will | |
70f4be2c | 96 | be allocated according to the policy specified, regardless of which |
9f5682a8 MK |
97 | process attached to the shared memory segment causes the allocation. |
98 | If, however, the shared memory region was created with the | |
99 | .B SHM_HUGETLB | |
100 | flag, | |
101 | the huge pages will be allocated according to the policy specified | |
a0c1c6f0 | 102 | only if the page allocation is caused by the process that calls |
9f5682a8 MK |
103 | .BR mbind () |
104 | for that region. | |
efeece04 | 105 | .PP |
9f5682a8 | 106 | By default, |
314093c9 | 107 | .BR mbind () |
33a0ccb2 | 108 | has an effect only for new allocations; if the pages inside |
314093c9 MK |
109 | the range have been already touched before setting the policy, |
110 | then the policy has no effect. | |
9f5682a8 | 111 | This default behavior may be overridden by the |
0daa9e92 | 112 | .B MPOL_MF_MOVE |
9f5682a8 MK |
113 | and |
114 | .B MPOL_MF_MOVE_ALL | |
115 | flags described below. | |
efeece04 | 116 | .PP |
9f5682a8 MK |
117 | The |
118 | .I mode | |
119 | argument must specify one of | |
314093c9 MK |
120 | .BR MPOL_DEFAULT , |
121 | .BR MPOL_BIND , | |
12ccb8fc | 122 | .BR MPOL_INTERLEAVE , |
a2b94599 | 123 | .BR MPOL_PREFERRED , |
9f5682a8 | 124 | or |
8ca0c84d MK |
125 | .BR MPOL_LOCAL |
126 | (which are described in detail below). | |
9f5682a8 | 127 | All policy modes except |
314093c9 | 128 | .B MPOL_DEFAULT |
f5a936f4 MK |
129 | require the caller to specify the node or nodes to which the mode applies, |
130 | via the | |
c13182ef | 131 | .I nodemask |
f5a936f4 | 132 | argument. |
efeece04 | 133 | .PP |
4a459ba1 MK |
134 | The |
135 | .I mode | |
136 | argument may also include an optional | |
e3b2c608 | 137 | .IR "mode flag" . |
4a459ba1 MK |
138 | The supported |
139 | .I "mode flags" | |
140 | are: | |
141 | .TP | |
142 | .BR MPOL_F_STATIC_NODES " (since Linux-2.6.26)" | |
aa796481 | 143 | A nonempty |
4a459ba1 | 144 | .I nodemask |
b763062b | 145 | specifies physical node IDs. |