]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/mbind.2
Ready for 5.00
[thirdparty/man-pages.git] / man2 / mbind.2
CommitLineData
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 37mbind \- 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 46Link with \fI\-lnuma\fP.
521bf584 47.fi
314093c9
MK
48.SH DESCRIPTION
49.BR mbind ()
9f5682a8
MK
50sets the NUMA memory policy,
51which consists of a policy mode and zero or more nodes,
314093c9 52for the memory range starting with
14f5ae6d 53.I addr
314093c9 54and continuing for
0daa9e92 55.I len
c13182ef 56bytes.
9f5682a8 57The memory policy defines from which node memory is allocated.
efeece04 58.PP
9f5682a8 59If the memory range specified by the
14f5ae6d 60.IR addr " and " len
9f5682a8
MK
61arguments includes an "anonymous" region of memory\(emthat is
62a region of memory created using the
63.BR mmap (2)
64system call with the
65.BR MAP_ANONYMOUS \(emor
9a141bfb 66a memory-mapped file, mapped using the
9f5682a8
MK
67.BR mmap (2)
68system call with the
69.B MAP_PRIVATE
33a0ccb2 70flag, pages will be allocated only according to the specified
8831d464 71policy when the application writes (stores) to the page.
9f5682a8
MK
72For anonymous regions, an initial read access will use a shared
73page in the kernel containing all zeros.
74For a file mapped with
75.BR MAP_PRIVATE ,
76an initial read access will allocate pages according to the
db0afb54
MK
77memory policy of the thread that causes the page to be allocated.
78This may not be the thread that called
9f5682a8 79.BR mbind ().
efeece04 80.PP
9f5682a8
MK
81The specified policy will be ignored for any
82.B MAP_SHARED
83mappings in the specified memory range.
db0afb54
MK
84Rather the pages will be allocated according to the memory policy
85of the thread that caused the page to be allocated.
86Again, this may not be the thread that called
9f5682a8 87.BR mbind ().
efeece04 88.PP
9f5682a8
MK
89If the specified memory range includes a shared memory region
90created using the
91.BR shmget (2)
92system call and attached using the
93.BR shmat (2)
94system call,
95pages allocated for the anonymous or shared memory region will
70f4be2c 96be allocated according to the policy specified, regardless of which
9f5682a8
MK
97process attached to the shared memory segment causes the allocation.
98If, however, the shared memory region was created with the
99.B SHM_HUGETLB
100flag,
101the huge pages will be allocated according to the policy specified
a0c1c6f0 102only if the page allocation is caused by the process that calls
9f5682a8
MK
103.BR mbind ()
104for that region.
efeece04 105.PP
9f5682a8 106By default,
314093c9 107.BR mbind ()
33a0ccb2 108has an effect only for new allocations; if the pages inside
314093c9
MK
109the range have been already touched before setting the policy,
110then the policy has no effect.
9f5682a8 111This default behavior may be overridden by the
0daa9e92 112.B MPOL_MF_MOVE
9f5682a8
MK
113and
114.B MPOL_MF_MOVE_ALL
115flags described below.
efeece04 116.PP
9f5682a8
MK
117The
118.I mode
119argument 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 124or
8ca0c84d
MK
125.BR MPOL_LOCAL
126(which are described in detail below).
9f5682a8 127All policy modes except
314093c9 128.B MPOL_DEFAULT
f5a936f4
MK
129require the caller to specify the node or nodes to which the mode applies,
130via the
c13182ef 131.I nodemask
f5a936f4 132argument.
efeece04 133.PP
4a459ba1
MK
134The
135.I mode
136argument may also include an optional
e3b2c608 137.IR "mode flag" .
4a459ba1
MK
138The supported
139.I "mode flags"
140are:
141.TP
142.BR MPOL_F_STATIC_NODES " (since Linux-2.6.26)"
aa796481 143A nonempty
4a459ba1 144.I nodemask
b763062b 145specifies physical node IDs.