1 .\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.
17 .\" Formatted or processed versions of this manual, if unaccompanied by
18 .\" the source, must acknowledge the copyright and authors of this work.
20 .\" 2006-02-03, mtk, substantial wording changes and other improvements
22 .TH MBIND 2 2006-02-07 "Linux" "Linux Programmer's Manual"
24 mbind \- Set memory policy for a memory range
27 .B "#include <numaif.h>"
29 .BI "int mbind(void *" start ", unsigned long " len ", int " policy ,
30 .BI " unsigned long *" nodemask ", unsigned long " maxnode ,
31 .BI " unsigned " flags );
39 for the memory range starting with
44 The memory of a NUMA machine is divided into multiple nodes.
45 The memory policy defines in which node memory is allocated.
47 only has an effect for new allocations; if the pages inside
48 the range have been already touched before setting the policy,
49 then the policy has no effect.
51 Available policies are
59 require the caller to specify the nodes to which the policy applies in the
63 is a bitmask of nodes containing up to
66 The actual number of bytes transferred via this argument
67 is rounded up to the next multiple of
68 .IR "sizeof(unsigned long)" ,
69 but the kernel will only use bits up to
71 A NULL argument means an empty set of nodes.
75 policy is the default and means to use the underlying process policy
76 (which can be modified with
77 .BR set_mempolicy (2)).
78 Unless the process policy has been changed this means to allocate
79 memory on the node of the CPU that triggered the allocation.
81 should be specified as NULL.
85 policy is a strict policy that restricts memory allocation to the
88 There won't be allocations on other nodes.
91 interleaves allocations to the nodes specified in
93 This optimizes for bandwidth instead of latency.
94 To be effective the memory area should be fairly large,
95 at least 1MB or bigger.
98 sets the preferred node for allocation.
99 The kernel will try to allocate in this
100 node first and fall back to other nodes if the
101 preferred nodes is low on free memory.
102 Only the first node in the
105 If no node is set in the mask, then the memory is allocated on
106 the node of the CPU that triggered the allocation allocation).
116 then the call will fail with the error
118 if the existing pages in the mapping don't follow the policy.
119 In 2.6.16 or later the kernel will also try to move pages
120 to the requested node with this flag.
126 then an attempt will be made to
127 move all the pages in the mapping so that they follow the policy.
128 Pages that are shared with other processes are not moved.
131 is also specified, then the call will fail with the error
133 if some pages could not be moved.
139 then all pages in the mapping will be moved regardless of whether
140 other processes use the pages.
141 The calling process must be privileged
146 is also specified, then the call will fail with the error
148 if some pages could not be moved.
153 on error, \-1 is returned and
155 is set to indicate the error.
159 There was a unmapped hole in the specified memory range
160 or a passed pointer was not valid.
163 An invalid value was specified for
177 pointed to a non-empty set;
186 pointed to an empty set,
189 System out of memory.
193 was specified and an existing page was already on a node
194 that does not follow the policy.
196 This system call is Linux specific.
198 NUMA policy is not supported on file mappings.
201 is ignored on huge page mappings right now.
203 It is unfortunate that the same flag,
205 has different effects for
208 .BR set_mempolicy (2).
209 To select "allocation on the node of the CPU that
210 triggered the allocation" (like
211 .BR set_mempolicy (2)
221 .SS "Versions and Library Support"
224 .BR get_mempolicy (2),
226 .BR set_mempolicy (2)
227 system calls were added to the Linux kernel with version 2.6.7.
228 They are only available on kernels compiled with
231 Support for huge page policy was added with 2.6.16.
232 For interleave policy to be effective on huge page mappings the
233 policied memory needs to be tens of megabytes or larger.
238 are only available on Linux 2.6.16 and later.
240 These system calls should not be used directly.
241 Instead, the higher level interface provided by the
245 package is recommended.
248 package is available at
249 .IR ftp://ftp.suse.com/pub/people/ak/numa/ .
253 to get system call definitions.
258 This package also has the
264 .BR set_mempolicy (2),
265 .BR get_mempolicy (2),