OSDN Git Service

5c9951ccbf67730245f0acfaa8a38b7d9abb0556
[linuxjm/LDP_man-pages.git] / draft / man2 / set_mempolicy.2
1 .\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
2 .\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
3 .\"
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.
7 .\"
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.
12 .\"
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.
17 .\"
18 .\" Formatted or processed versions of this manual, if unaccompanied by
19 .\" the source, must acknowledge the copyright and authors of this work.
20 .\"
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.
24 .\"
25 .\" Translated 2006-08-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.39
26 .\" Updated 2007-01-07, Akihiro MOTOKI, LDP v2.43
27 .\" Updated 2008-02-13, Akihiro MOTOKI, LDP v2.77
28 .\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05
29 .\" Updated 2008-08-21, Akihiro MOTOKI, LDP v3.07
30 .\" Updated 2008-09-02, Akihiro MOTOKI, LDP v3.08
31 .\" Updated 2008-11-19, Akihiro MOTOKI, LDP v3.13
32 .\"
33 .\"WORD:        anonymous memory        無名メモリ
34 .\"
35 .TH SET_MEMPOLICY 2 2008-08-15 Linux "Linux Programmer's Manual"
36 .\"O .SH NAME
37 .SH 名前
38 .\"O set_mempolicy \- set default NUMA memory policy for a process and its children
39 set_mempolicy \- プロセスとその子プロセスの NUMA メモリの
40 デフォルトポリシーを設定する
41 .\"O .SH SYNOPSIS
42 .SH 書式
43 .nf
44 .B "#include <numaif.h>"
45 .sp
46 .BI "int set_mempolicy(int " mode ", unsigned long *" nodemask ,
47 .BI "                  unsigned long " maxnode );
48 .sp
49 .\"O Link with \fI\-lnuma\fP.
50 \fI\-lnuma\fP でリンクする。
51 .fi
52 .\"O .SH DESCRIPTION
53 .SH 説明
54 .\"O .BR set_mempolicy ()
55 .\"O sets the NUMA memory policy of the calling process,
56 .\"O which consists of a policy mode and zero or more nodes,
57 .\"O to the values specified by the
58 .\"O .IR mode ,
59 .\"O .I nodemask
60 .\"O and
61 .\"O .I maxnode
62 .\"O arguments.
63 .BR set_mempolicy ()
64 は、呼び出し元プロセスの NUMA ポリシーを
65 .I policy
66 に設定する。
67 NUMA ポリシーはポリシーモードと 0 個以上のノードから構成され、
68 設定内容は引き数
69 .IR mode ,
70 .IR nodemask ,
71 .I maxnode
72 により指定される。
73
74 .\"O A NUMA machine has different
75 .\"O memory controllers with different distances to specific CPUs.
76 .\"O The memory policy defines from which node memory is allocated for
77 .\"O the process.
78 NUMA (非対称メモリアクセス) マシンでは、CPU により
79 メモリコントローラが異なり、距離も異なっている。
80 メモリポリシーは、どのノードからメモリをそのプロセスに
81 割り当てられるかを定めるものである。
82
83 .\"O This system call defines the default policy for the process.
84 .\"O The process policy governs allocation of pages in the process's
85 .\"O address space outside of memory ranges
86 .\"O controlled by a more specific policy set by
87 .\"O .BR mbind (2).
88 .BR set_mempolicy ()
89 は、プロセスのデフォルトポリシーを定める。
90 プロセスのポリシーは、
91 .BR mbind (2)
92 で設定される特定のポリシーにより制御されるメモリ領域以外の
93 プロセスのアドレス空間におけるページの割り当てに適用される。
94 .\"O The process default policy also controls allocation of any pages for
95 .\"O memory mapped files mapped using the
96 .\"O .BR mmap (2)
97 .\"O call with the
98 .\"O .B MAP_PRIVATE
99 .\"O flag and that are only read [loaded] from by the process
100 .\"O and of memory mapped files mapped using the
101 .\"O .BR mmap (2)
102 .\"O call with the
103 .\"O .B MAP_SHARED
104 .\"O flag, regardless of the access type.
105 プロセスのデフォルトポリシーは、
106 .B MAP_PRIVATE
107 フラグを指定した
108 .BR mmap (2)
109 を使ってマップされたメモリマップ・ファイルに対する読み出し専用
110 (ロードされるだけ) のページの割り当てにも適用される。
111 また、
112 .B MAP_SHARED
113 フラグを指定した
114 .BR mmap (2)
115 を使ってマップされたメモリマップ・ファイルに対するページの割り当てにも
116 適用される (この場合はページのアクセス種別に関わらず適用される) 。
117 .\"O The policy is only applied when a new page is allocated
118 .\"O for the process.
119 .\"O For anonymous memory this is when the page is first
120 .\"O touched by the application.
121 設定したポリシーは、プロセスに新規のページが割り当てられるときにのみ
122 適用される。無名メモリ (anonymous memory) の場合、新規ページの割り当ては
123 アプリケーションが初めてページにアクセスした際に行われる。
124
125 .\"O The
126 .\"O .I mode
127 .\"O argument must specify one of
128 .\"O .BR MPOL_DEFAULT ,
129 .\"O .BR MPOL_BIND ,
130 .\"O .B MPOL_INTERLEAVE
131 .\"O or
132 .\"O .BR MPOL_PREFERRED .
133 .\"O All modes except
134 .\"O .B MPOL_DEFAULT
135 .\"O require the caller to specify via the
136 .\"O .I nodemask
137 .\"O argument one or more nodes.
138 .I mode
139 引き数には
140 .BR MPOL_DEFAULT ,
141 .BR MPOL_BIND ,
142 .BR MPOL_INTERLEAVE ,
143 .B MPOL_PREFERRED
144 のいずれか一つを指定してしなければならない。
145 .B MPOL_DEFAULT
146 以外のポリシーの場合、呼び出し元は
147 .I nodemask
148 引き数で一つ以上のノードを指定する必要がある。
149
150 .\"O The
151 .\"O .I mode
152 .\"O argument may also include an optional
153 .\"O .IR "mode flag" .
154 .\"O The supported
155 .\"O .I "mode flags"
156 .\"O are:
157 .I mode
158 引き数には、追加で
159 .I "モードフラグ"
160 を含めることもできる。
161 サポートされている
162 .I "モードフラグ"
163 は以下の通りである。
164 .TP
165 .\"O .BR MPOL_F_STATIC_NODES " (since Linux 2.6.26)"
166 .BR MPOL_F_STATIC_NODES " (Linux 2.6.26 以降)"
167 .\"O A nonempty
168 .\"O .I nodemask
169 .\"O specifies physical node ids.
170 .\"O Linux does will not remap the
171 .\"O .I nodemask
172 .\"O when the process moves to a different cpuset context,
173 .\"O nor when the set of nodes allowed by the process's
174 .\"O current cpuset context changes.
175 空でない
176 .I nodemask
177 は、物理ノード ID である。
178 Linux では、そのプロセスが異なる CPU 集合コンテキスト (cpuset context)
179 に移動した場合でも、そのプロセスの現在の CPU 集合コンテキストで
180 許可されているノード集合が変化した場合でも、
181 .I nodemask
182 をマッピングし直すことはない。
183 .TP
184 .\"O .BR MPOL_F_RELATIVE_NODES " (since Linux 2.6.26)"
185 .BR MPOL_F_RELATIVE_NODES " (Linux 2.6.26 以降)"
186 .\"O A nonempty
187 .\"O .I nodemask
188 .\"O specifies node ids that are relative to the set of
189 .\"O node ids allowed by the process's current cpuset.
190 空でない
191 .I nodemask
192 は、そのプロセスの現在の CPU 集合で許可されているノード ID 集合
193 における相対的なノード ID である。
194 .PP
195 .\"O .I nodemask
196 .\"O points to a bit mask of node IDs that contains up to
197 .\"O .I maxnode
198 .\"O bits.
199 .\"O The bit mask size is rounded to the next multiple of
200 .\"O .IR "sizeof(unsigned long)" ,
201 .\"O but the kernel will only use bits up to
202 .\"O .IR maxnode .
203 .I nodemask
204 は、最大で
205 .I maxnode
206 ビットから構成されるノード ID のビットマスクを指す。
207 ビットマスクの大きさは、直近の
208 .I sizeof(unsigned long)
209 の倍数に切り上げられるが、カーネルが使用するのは
210 .I maxnode
211 個までのビットだけである。
212 .\"O A NULL value of
213 .\"O .I nodemask
214 .\"O or a
215 .\"O .I maxnode
216 .\"O value of zero specifies the empty set of nodes.
217 .\"O If the value of
218 .\"O .I maxnode
219 .\"O is zero,
220 .\"O the
221 .\"O .I nodemask
222 .\"O argument is ignored.
223 NULL 値の
224 .I nodemask
225 もしくは値が 0 の
226 .I maxnode
227 はノードの空集合を表す。
228 .I maxnode
229 の値が 0 の場合、
230 .I nodemask
231 引き数は無視される。
232
233 .\"O Where a
234 .\"O .I nodemask
235 .\"O is required, it must contain at least one node that is on-line,
236 .\"O allowed by the process's current cpuset context,
237 .\"O [unless the
238 .\"O .B MPOL_F_STATIC_NODES
239 .\"O mode flag is specified],
240 .\"O and contains memory.
241 .I nodemask
242 が必須の場面では、
243 .I nodemask
244 に、オンラインで、そのプロセスの現在の CPU 集合コンテキストで
245 許可されており
246 .RB ( MPOL_F_STATIC_NODES
247 モードフラグが指定されていない場合)、メモリがあるノードが
248 少なくとも一つ入っていなければならない。
249 .\"O If the
250 .\"O .B MPOL_F_STATIC_NODES
251 .\"O is set in
252 .\"O .I mode
253 .\"O and a required
254 .\"O .I nodemask
255 .\"O contains no nodes that are allowed by the process's current cpuset context,
256 .\"O the memory policy reverts to
257 .\"O .IR "local allocation" .
258 .\"O This effectively overrides the specified policy until the process's
259 .\"O cpuset context includes one or more of the nodes specified by
260 .\"O .IR nodemask .
261 .I mode
262
263 .B MPOL_F_STATIC_NODES
264 がセットされ、
265 .I nodemask
266 が必須の場面で、
267 .I nodemask
268 に、そのプロセスの現在の CPU 集合コンテキストで許可されたノードが
269 一つも含まれていない場合には、メモリのポリシーとしてデフォルトの
270 「ローカルから割り当て (local allocation)」が適用される。
271 そのプロセスの CPU 集合コンテキストが
272 .I nodemask
273 で指定されたノードを少なくとも一つ含むようになるまでは、
274 結果的に指定された動作が上書きされることになる。
275
276 .\"O The
277 .\"O .B MPOL_DEFAULT
278 .\"O mode specifies that any nondefault process memory policy be removed,
279 .\"O so that the memory policy "falls back" to the system default policy.
280 .\"O The system default policy is "local allocation"--
281 .\"O i.e., allocate memory on the node of the CPU that triggered the allocation.
282 .\"O .I nodemask
283 .\"O must be specified as NULL.
284 .\"O If the "local node" contains no free memory, the system will
285 .\"O attempt to allocate memory from a "near by" node.
286 .B MPOL_DEFAULT
287 モードは、デフォルトではないプロセスのメモリポリシーを削除することを
288 指定するものである。これにより、メモリポリシーはシステムの
289 デフォルトポリシーに「戻る」ことになる。
290 システムのデフォルトポリシーは「ローカルからの割り当て (local allocation)」、
291 つまりメモリ割り当てのきっかけとなった CPU のノードのメモリが割り当てられる。
292 .I nodemask
293 には NULL を指定しなければならない。
294 「自ノード (local node)」に空きメモリが全くない場合、システムは
295 「近くの (near by) ノード」からメモリを割り当てようと試みる。
296
297 .\"O The
298 .\"O .B MPOL_BIND
299 .\"O mode defines a strict policy that restricts memory allocation to the
300 .\"O nodes specified in
301 .\"O .IR nodemask .
302 .\"O If
303 .\"O .I nodemask
304 .\"O specifies more than one node, page allocations will come from
305 .\"O the node with the lowest numeric node ID first, until that node
306 .\"O contains no free memory.
307 .\"O Allocations will then come from the node with the next highest
308 .\"O node ID specified in
309 .\"O .I nodemask
310 .\"O and so forth, until none of the specified nodes contain free memory.
311 .\"O Pages will not be allocated from any node not specified in the
312 .\"O .IR nodemask .
313 .B MPOL_BIND
314 モードは厳密なポリシーで、メモリ割り当ては
315 .I nodemask
316 に指定されたノードに限定される。
317 .I nodemask
318 に 2 個以上のノードが指定された場合、ページの割り当ては
319 ノード ID が数字として最小のノードから開始され、
320 そのノードに空きメモリがなくなるまでそのノードから
321 ページ割り当てが行われる。そのノードに空きメモリがなくなったら、
322 .\"motoki: the next highest は the next lowest の間違い?
323 次に小さなノード ID を持つノードからページ割り当てが行われる。
324 これを、
325 .I nodemask
326 で指定された全てのノードで空きメモリがなくなるまで繰り返す。
327 .I nodemask
328 で指定された以外のノードからはページの割り当ては行われない。
329
330 .\"O .B MPOL_INTERLEAVE
331 .\"O interleaves page allocations across the nodes specified in
332 .\"O .I nodemask
333 .\"O in numeric node ID order.
334 .\"O This optimizes for bandwidth instead of latency
335 .\"O by spreading out pages and memory accesses to those pages across
336 .\"O multiple nodes.
337 .\"O However, accesses to a single page will still be limited to
338 .\"O the memory bandwidth of a single node.
339 .B MPOL_INTERLEAVE
340 では、ページ割り当てを
341 .I nodemask
342 に指定されたノードの間でノード ID の数字順で交互に行う。
343 このポリシーでは、複数のノードにページを広げて配置し、これらのページへのメモリ
344 アクセスを分散することで、遅延ではなく、帯域を最適化する。
345 ただし、一つのページへのアクセスに関しては依然として一つのノードのメモリ帯域
346 が上限となる。
347 .\" NOTE:  the following sentence doesn't make sense in the context
348 .\" of set_mempolicy() -- no memory area specified.
349 .\" To be effective the memory area should be fairly large,
350 .\" at least 1MB or bigger.
351
352 .\"O .B MPOL_PREFERRED
353 .\"O sets the preferred node for allocation.
354 .\"O The kernel will try to allocate pages from this node first
355 .\"O and fall back to "near by" nodes if the preferred node is low on free
356 .\"O memory.
357 .\"O If
358 .\"O .I nodemask
359 .\"O specifies more than one node ID, the first node in the
360 .\"O mask will be selected as the preferred node.
361 .\"O If the
362 .\"O .I nodemask
363 .\"O and
364 .\"O .I maxnode
365 .\"O arguments specify the empty set, then the policy
366 .\"O specifies "local allocation"
367 .\"O (like the system default policy discussed above).
368 .B MPOL_PREFERRED
369 は、割り当て時に優先されるノード (preferred node) を設定する。
370 カーネルはまず優先ノードからページ割り当てを行おうとし、
371 優先ノードに空きメモリが少ない場合に「近くの (near by)」ノードから
372 割り当てを行う。
373 .I nodemask
374 に複数のノード ID が指定された場合は、
375 .I nodemask
376 内の最初のノードが優先ノードとして選択される。
377 引き数
378 .IR nodemask ,
379 .I maxnode
380 で空集合が指定された場合は、ポリシーは (上述のシステムの
381 デフォルトポリシーと同様に) 「ローカルからの割り当て」となる。
382
383 .\"O The process memory policy is preserved across an
384 .\"O .BR execve (2),
385 .\"O and is inherited by child processes created using
386 .\"O .BR fork (2)
387 .\"O or
388 .\"O .BR clone (2).
389 プロセスのメモリポリシーは
390 .BR execve (2)
391 の前後で保持され、
392 .BR fork (2)
393
394 .BR clone (2)
395 を使って作成された子プロセスに継承される。
396 .\"O .SH RETURN VALUE
397 .SH 返り値
398 .\"O On success,
399 .\"O .BR set_mempolicy ()
400 .\"O returns 0;
401 .\"O on error, \-1 is returned and
402 .\"O .I errno
403 .\"O is set to indicate the error.
404 成功すると、
405 .BR set_mempolicy ()
406 は 0 を返す。エラーの場合、\-1 を返し、
407 .I errno
408 にエラーを示す値を設定する。
409 .\"O .SH ERRORS
410 .SH エラー
411 .TP
412 .B EFAULT
413 .\"O Part of all of the memory range specified by
414 .\"O .I nodemask
415 .\"O and
416 .\"O .I maxnode
417 .\"O points outside your accessible address space.
418 .\"motoki: Part of all of the memory は Part or all .. の間違い?
419 .I nodemask
420
421 .I maxnode
422 で指定されたメモリ領域の一部または全部が、
423 呼び出し元がアクセス可能なアドレス空間外を指している。
424 .TP
425 .B EINVAL
426 .\"O .I mode
427 .\"O is invalid.
428 .I mode
429 が不正である。
430 .\"O Or,
431 .\"O .I mode
432 .\"O is
433 .\"O .B MPOL_DEFAULT
434 .\"O and
435 .\"O .I nodemask
436 .\"O is nonempty,
437 .I mode
438
439 .B MPOL_DEFAULT
440 で、
441 .I nodemask
442 が空ではない。
443 .\"O or
444 .\"O .I mode
445 .\"O is
446 .\"O .B MPOL_BIND
447 .\"O or
448 .\"O .B MPOL_INTERLEAVE
449 .\"O and
450 .\"O .I nodemask
451 .\"O is empty.
452 .I mode
453
454 .B MPOL_BIND
455
456 .B MPOL_INTERLEAVE
457 で、
458 .I nodemask
459 が空である。
460 .\"O Or,
461 .\"O .I maxnode
462 .\"O specifies more than a page worth of bits.
463 .I maxnode
464 で実際に意味があるビット数より多くのビット数が指定された。
465 .\"O Or,
466 .\"O .I nodemask
467 .\"O specifies one or more node IDs that are
468 .\"O greater than the maximum supported node ID.
469 .I nodemask
470 に、サポートされている最大ノード ID より大きいノードが指定された。
471 .\"O Or, none of the node IDs specified by
472 .\"O .I nodemask
473 .\"O are on-line and allowed by the process's current cpuset context,
474 .\"O or none of the specified nodes contain memory.
475 .I nodemask
476 に、オンラインで、かつそのプロセスの現在の CPU 集合コンテキストで
477 許可されているノードが一つも含まれていないか、
478 メモリを含むノードが一つも指定されていない。
479 .\"O Or, the
480 .\"O .I mode
481 .\"O argument specified both
482 .\"O .B MPOL_F_STATIC_NODES
483 .\"O and
484 .\"O .BR MPOL_F_RELATIVE_NODES .
485 .I mode
486 引き数に
487 .B MPOL_F_STATIC_NODES
488
489 .B MPOL_F_RELATIVE_NODES
490 の両方が指定された。
491 .TP
492 .B ENOMEM
493 .\"O Insufficient kernel memory was available.
494 利用可能なカーネルメモリが十分でなかった。
495 .\"O .SH VERSIONS
496 .SH バージョン
497 .\"O The
498 .\"O .BR set_mempolicy (),
499 .\"O system call was added to the Linux kernel in version 2.6.7.
500 .BR set_mempolicy ()
501 システムコールはバージョン 2.6.7 で Linux カーネルに追加された。
502 .\"O .SH CONFORMING TO
503 .SH 準拠
504 .\"O This system call is Linux-specific.
505 このシステムコールは Linux 独自である。
506 .\"O .SH NOTES
507 .SH 注意
508 .\"O Process policy is not remembered if the page is swapped out.
509 ページがスワップ・アウトされる場合には、
510 プロセスポリシーの設定は推奨されない。
511 .\"O When such a page is paged back in, it will use the policy of
512 .\"O the process or memory range that is in effect at the time the
513 .\"O page is allocated.
514 スワップ・アウトされたページがページ・インする際にも、
515 ページ割り当て時に適用されるプロセスポリシーやメモリ領域ポリシーが
516 使用される。
517
518 .\"O For information on library support, see
519 .\"O .BR numa (7).
520 ライブラリによるサポートについては
521 .BR numa (7)
522 を参照。
523 .\"O .SH SEE ALSO
524 .SH 関連項目
525 .BR get_mempolicy (2),
526 .BR getcpu (2),
527 .BR mbind (2),
528 .BR mmap (2),
529 .BR numa (3),
530 .BR cpuset (7),
531 .BR numa (7),
532 .BR numactl (8)