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 SET_MEMPOLICY 2 2006-02-07 "Linux" "Linux Programmer's Manual"
24 set_mempolicy \- set default NUMA memory policy for a process and its children.
27 .B "#include <numaif.h>"
29 .BI "int set_mempolicy(int " policy ", unsigned long *" nodemask ,
30 .BI " unsigned long " maxnode );
34 sets the NUMA memory policy of the calling process to
37 A NUMA machine has different
38 memory controllers with different distances to specific CPUs.
39 The memory policy defines in which node memory is allocated for
42 This system call defines the default policy for the process;
43 in addition a policy can be set for specific memory ranges using
45 The policy is only applied when a new page is allocated
47 For anonymous memory this is when the page is first
48 touched by the application.
50 Available policies are
57 require the caller to specify the nodes to which the policy applies in the
61 is pointer to a bit field of nodes that contains up to
64 The bit field size is rounded to the next multiple of
65 .IR "sizeof(unsigned long)" ,
66 but the kernel will only use bits up to
71 policy is the default and means to allocate memory locally,
72 i.e., on the node of the CPU that triggered the allocation.
74 should be specified as NULL.
78 policy is a strict policy that restricts memory allocation to the
81 There won't be allocations on other nodes.
84 interleaves allocations to the nodes specified in
86 This optimizes for bandwidth instead of latency.
87 To be effective the memory area should be fairly large,
88 at least 1MB or bigger.
91 sets the preferred node for allocation.
92 The kernel will try to allocate in this
93 node first and fall back to other nodes if the preferred node is low on free
95 Only the first node in the
98 If no node is set in the mask, then the memory is allocated on
99 the node of the CPU that triggered the allocation allocation (like
102 The memory policy is preserved across an
104 and is inherited by child processes created using
112 on error, \-1 is returned and
114 is set to indicate the error.
116 .\" FIXME writeme -- no errors are listed on this page
120 .\" .I mode is invalid.
121 .SS "Versions and Library Support"
125 This system call is Linux specific.
127 Process policy is not remembered if the page is swapped out.
130 .BR get_mempolicy (2),