1 .\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
2 .\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.
18 .\" Formatted or processed versions of this manual, if unaccompanied by
19 .\" the source, must acknowledge the copyright and authors of this work.
21 .\" 2006-02-03, mtk, substantial wording changes and other improvements
22 .\" 2007-08-27, Lee Schermerhorn <Lee.Schermerhorn@hp.com>
23 .\" more precise specification of behavior.
25 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI
26 .\" all rights reserved.
27 .\" Translated 2006-08-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.39
28 .\" Updated 2008-02-13, Akihiro MOTOKI, LDP v2.77
29 .\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05
30 .\" Updated 2008-08-21, Akihiro MOTOKI, LDP v3.07
31 .\" Updated 2008-11-19, Akihiro MOTOKI, LDP v3.13
33 .TH GET_MEMPOLICY 2 2008-08-15 Linux "Linux Programmer's Manual"
36 .\"O get_mempolicy \- Retrieve NUMA memory policy for a process
37 get_mempolicy \- ¥×¥í¥»¥¹¤Î NUMA ¥á¥â¥ê¤Î¥Ý¥ê¥·¡¼¤ò¼èÆÀ¤¹¤ë
41 .B "#include <numaif.h>"
43 .BI "int get_mempolicy(int *" mode ", unsigned long *" nodemask ,
44 .BI " unsigned long " maxnode ", unsigned long " addr ,
45 .BI " unsigned long " flags );
47 .\"O Link with \fI\-lnuma\fP.
48 \fI\-lnuma\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
52 .\"O .BR get_mempolicy ()
53 .\"O retrieves the NUMA policy of the calling process or of a memory address,
54 .\"O depending on the setting of
57 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤â¤·¤¯¤Ï»ØÄꤵ¤ì¤¿¥á¥â¥ê¥¢¥É¥ì¥¹¤Î
60 ¤ÎÀßÄê¤Ë½¾¤Ã¤Æ¼èÆÀ¤¹¤ë¡£
62 .\"O A NUMA machine has different
63 .\"O memory controllers with different distances to specific CPUs.
64 .\"O The memory policy defines from which node memory is allocated for
66 NUMA (ÈóÂоΥá¥â¥ê¥¢¥¯¥»¥¹) ¥Þ¥·¥ó¤Ç¤Ï¡¢CPU ¤Ë¤è¤ê
67 ¥á¥â¥ê¥³¥ó¥È¥í¡¼¥é¤¬°Û¤Ê¤ê¡¢µ÷Î¥¤â°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
68 ¥á¥â¥ê¥Ý¥ê¥·¡¼¤Ï¡¢¤É¤Î¥Î¡¼¥É¤«¤é¥á¥â¥ê¤ò¤½¤Î¥×¥í¥»¥¹¤Ë
69 ³ä¤êÅö¤Æ¤ë¤«¤òÄê¤á¤ë¤â¤Î¤Ç¤¢¤ë¡£
73 .\"O is specified as 0,
74 .\"O then information about the calling process's default policy
76 .\"O .BR set_mempolicy (2))
79 ¤Ë 0 ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
80 .RB ( set_mempolicy (2)
82 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥Ç¥Õ¥©¥ë¥È¥Ý¥ê¥·¡¼¤Ë´Ø¤¹¤ë¾ðÊó¤òÊÖ¤¹¡£
83 .\"O The policy returned
87 .\"O may be used to restore the process's policy to its state at
88 .\"O the time of the call to
89 .\"O .BR get_mempolicy ()
91 .\"O .BR set_mempolicy (2).
98 ¤ËÅϤ¹¤³¤È¤Ç¡¢¤½¤Î¥×¥í¥»¥¹¤Î¥Ý¥ê¥·¡¼¤ò
100 ¤ò¸Æ¤Ó½Ð¤·¤¿»þÅÀ¤Î¾õÂÖ¤ËÌ᤹¤³¤È¤¬¤Ç¤¤ë¡£
105 .\"O .BR MPOL_F_MEMS_ALLOWED
106 .\"O (available since Linux 2.6.24), the
108 .\"O argument is ignored and the set of nodes [memories] that the
109 .\"O process is allowed to specify in subsequent calls to
112 .\"O .BR set_mempolicy (2)
113 .\"O [in the absense of any
114 .\"O .IR "mode flags" ]
117 .\"O It is not permitted to combine
118 .\"O .B MPOL_F_MEMS_ALLOWED
122 .\"O .BR MPOL_F_NODE .
125 .B MPOL_F_MEMS_ALLOWED
126 (Linux 2.6.24 °Ê¹ß¤ÇÍøÍѲÄǽ) ¤ò»ØÄꤹ¤ë¤È¡¢
129 ¤½¤Î¥×¥í¥»¥¹¤¬¤½¤Î¸å¤Î
132 .BR set_mempolicy (2)
135 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë ] »ØÄê¤Ç¤¤ë¥Î¡¼¥É (¥á¥â¥ê) ¤Î½¸¹ç¤¬
138 .B MPOL_F_MEMS_ALLOWED
143 ¤ÈƱ»þ¤Ë»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
148 .\"O .BR MPOL_F_ADDR ,
149 .\"O then information is returned about the policy governing the memory
150 .\"O address given in
152 .\"O This policy may be different from the process's default policy if
154 .\"O or one of the helper functions described in
156 .\"O has been used to establish a policy for the memory range containing
163 ¤Ç»ØÄꤵ¤ì¤¿¥á¥â¥ê¥¢¥É¥ì¥¹¤ËŬÍѤµ¤ì¤Æ¤¤¤ë¥Ý¥ê¥·¡¼¤Ë´Ø¤¹¤ë¾ðÊó¤òÊÖ¤¹¡£
167 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥Ø¥ë¥Ñ¡¼´Ø¿ô¤ò»È¤Ã¤Æ¡¢
169 ¤ò´Þ¤à¥á¥â¥êÎΰè¤ËÂФ¹¤ë¥Ý¥ê¥·¡¼¤¬ÀßÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¡¢
170 ÊÖ¤µ¤ì¤ë¥Ý¥ê¥·¡¼¤Ï¥×¥í¥»¥¹¤Î¥Ç¥Õ¥©¥ë¥È¥Ý¥ê¥·¡¼¤È°ã¤¦¤³¤È¤¬¤¢¤ë¡£
174 .\"O argument is not NULL, then
175 .\"O .BR get_mempolicy ()
176 .\"O will store the policy mode and any optional
178 .\"O of the requested NUMA policy in the location pointed to by this argument.
180 °ú¤¿ô¤¬ NULL ¤Ç¤Ê¤¤¾ì¹ç¡¢
182 ¤ÏÍ׵ᤵ¤ì¤¿ NUMA ¥Ý¥ê¥·¡¼¤Î¥â¡¼¥É¤ÈÄɲäÎ
186 ¤¬»Ø¤¹¾ì½ê¤Ë³ÊǼ¤¹¤ë¡£
189 .\"O is not NULL, then the nodemask associated with the policy will be stored
190 .\"O in the location pointed to by this argument.
192 .\"O specifies the number of node IDs
193 .\"O that can be stored into
194 .\"O .IR nodemask \(emthat
195 .\"O is, the maximum node ID plus one.
196 .\"O The value specified by
198 .\"O is always rounded to a multiple of
199 .\"O .IR "sizeof(unsigned long)" .
201 ¤¬ NULL °Ê³°¤Î¾ì¹ç¡¢¤½¤Î¥Ý¥ê¥·¡¼¤ËÂбþ¤¹¤ë¥Î¡¼¥É¥Þ¥¹¥¯¤ò
202 ¤³¤Î°ú¤¿ô¤¬»Ø¤¹¾ì½ê¤Ë³ÊǼ¤¹¤ë¡£
206 ¤Ë³ÊǼ¤Ç¤¤ë¥Î¡¼¥É ID ¤Î¿ô¡¢¤Ä¤Þ¤êºÇÂç¥Î¡¼¥É ID ¤Ë 1 ¤ò¤·¤¿Ãͤò»ØÄꤹ¤ë¡£
209 .I sizeof(unsigned long)
210 ¤ÎÇÜ¿ô¤ËÀÚ¤ê¾å¤²¤é¤ì¤ë¡£
217 .\"O .BR MPOL_F_ADDR ,
218 .\"O .BR get_mempolicy ()
219 .\"O will return the node ID of the node on which the address
221 .\"O is allocated into the location pointed to by
223 .\"O If no page has yet been allocated for the specified address,
224 .\"O .BR get_mempolicy ()
225 .\"O will allocate a page as if the process had performed a read
226 .\"O [load] access to that address, and return the ID of the node
227 .\"O where that page was allocated.
233 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
237 ¤¬³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¥Î¡¼¥É¤Î¥Î¡¼¥É ID ¤ò
239 ¤¬»Ø¤¹¾ì½ê¤ËÆþ¤ì¤ÆÊÖ¤¹¡£
240 »ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹¤Ë¤É¤Î¥Ú¡¼¥¸¤â¤Þ¤À³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
242 ¤Ï¡¢¤¢¤¿¤«¤â¤½¤Î¥×¥í¥»¥¹¤¬¤½¤Î¥¢¥É¥ì¥¹¤ËÂФ·¤ÆÆɤ߹þ¤ß¥¢¥¯¥»¥¹¤ò
243 ¼Â¹Ô¤·¤¿¤«¤Î¤è¤¦¤Ë¥Ú¡¼¥¸¤Î³ä¤êÅö¤Æ¤ò¹Ô¤¤¡¢¥Ú¡¼¥¸¤¬³ä¤êÅö¤Æ¤é¤ì¤¿
249 .\"O .BR MPOL_F_NODE ,
251 .\"O .BR MPOL_F_ADDR ,
252 .\"O and the process's current policy is
253 .\"O .BR MPOL_INTERLEAVE ,
255 .\"O .BR get_mempolicy ()
256 .\"O will return in the location pointed to by a non-NULL
259 .\"O the node ID of the next node that will be used for
260 .\"O interleaving of internal kernel pages allocated on behalf of the process.
266 ¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ç¡¢¤«¤Ä
267 ¤½¤Î¥×¥í¥»¥¹¤Î¸½ºß¤Î¥Ý¥ê¥·¡¼¤¬
271 ¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ³ä¤êÅö¤Æ¤é¤ì¤¿¥«¡¼¥Í¥ë¤ÎÆâÉô¥Ú¡¼¥¸¤Ç
272 ¼¡¤Ë¥¤¥ó¥¿¡¼¥ê¡¼¥ÖÍѤ˻ÈÍѤµ¤ì¤ë¥Î¡¼¥É¤Î¥Î¡¼¥É ID ¤ò¡¢
275 °ú¤¿ô¤¬»Ø¤¹¾ì½ê¤ËÆþ¤ì¤ÆÊÖ¤¹¡£
276 .\" Note: code returns next interleave node via 'mode' argument -Lee Schermerhorn
277 .\"O These allocations include pages for memory mapped files in
278 .\"O process memory ranges mapped using the
282 .\"O flag for read accesses, and in memory ranges mapped with the
284 .\"O flag for all accesses.
285 Æɤ߹þ¤ß¥¢¥¯¥»¥¹ÍѤȤ·¤Æ
289 ¤·¤¿¥×¥í¥»¥¹¥á¥â¥êÎΰè¤ä¡¢
290 Ǥ°Õ¤Î¥¢¥¯¥»¥¹ÍѤȤ·¤Æ
294 ¤·¤¿¥á¥â¥êÎΰè¤Î¡¢¥á¥â¥ê¥Þ¥Ã¥×¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥Ú¡¼¥¸¤â
295 ¾åµ¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ³ä¤êÅö¤Æ¤é¤ì¤¿¥Ú¡¼¥¸¤Ë´Þ¤Þ¤ì¤ë¡£
297 .\"O Other flag values are reserved.
298 ¾¤Î¥Õ¥é¥°¤ÏͽÌ󤵤ì¤Æ¤¤¤ë¡£
300 .\"O For an overview of the possible policies see
301 .\"O .BR set_mempolicy (2).
302 ÀßÄê²Äǽ¤Ê¥Ý¥ê¥·¡¼¤Î³µÍפˤĤ¤¤Æ¤Ï
303 .BR set_mempolicy (2)
305 .\"O .SH RETURN VALUE
308 .\"O .BR get_mempolicy ()
310 .\"O on error, \-1 is returned and
312 .\"O is set to indicate the error.
315 ¤Ï 0 ¤òÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
317 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
322 .\"O Part of all of the memory range specified by
326 .\"O points outside your accessible address space.
327 .\"motoki: Part of all of the memory ¤Ï Part or all .. ¤Î´Ö°ã¤¤¡©
331 ¤Ç»ØÄꤵ¤ì¤¿¥á¥â¥êÎΰè¤Î°ìÉô¤Þ¤¿¤ÏÁ´Éô¤¬¡¢
332 ¸Æ¤Ó½Ð¤·¸µ¤¬¥¢¥¯¥»¥¹²Äǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
335 .\"O The value specified by
337 .\"O is less than the number of node IDs supported by the system.
339 ¤Ç»ØÄꤵ¤ì¤¿Ãͤ¬¥·¥¹¥Æ¥à¤¬¥µ¥Ý¡¼¥È¤¹¤ë¥Î¡¼¥É ID ¤Î¿ô¤è¤ê¤â¾¯¤Ê¤¤¡£
342 .\"O specified values other than
345 .\"O .BR MPOL_F_ADDR ;
352 ¤Ç¤â¤Ê¤¤Ãͤ¬»ØÄꤵ¤ì¤¿¡£
387 .\"O and the current process policy is not
388 .\"O .BR MPOL_INTERLEAVE .
396 ¥×¥í¥»¥¹¤Î¸½ºß¤Î¥Ý¥ê¥·¡¼¤¬
402 .\"O .B MPOL_F_MEMS_ALLOWED
406 .\"O .BR MPOL_F_NODE .
410 .B MPOL_F_MEMS_ALLOWED
411 ¤¬»ØÄꤵ¤ì¤Æ¤ª¤ê¡¢¤µ¤é¤Ë
415 ¤Î¤¤¤º¤ì¤«¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¡£
416 .\"O (And there are other
425 .\"O .BR get_mempolicy ()
426 .\"O system call was added to the Linux kernel in version 2.6.7.
428 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥Ð¡¼¥¸¥ç¥ó 2.6.7 ¤Ç Linux ¥«¡¼¥Í¥ë¤ËÄɲ䵤줿¡£
429 .\"O .SH CONFORMING TO
431 .\"O This system call is Linux-specific.
432 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇͤǤ¢¤ë¡£
435 .\"O For information on library support, see
437 ¥é¥¤¥Ö¥é¥ê¤Ë¤è¤ë¥µ¥Ý¡¼¥È¤Ë¤Ä¤¤¤Æ¤Ï
445 .BR set_mempolicy (2),