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-07-25, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
28 .\" Updated 2008-08-21, Akihiro MOTOKI, LDP v3.07
29 .\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.08
31 .TH MBIND 2 2008-08-15 Linux "Linux Programmer's Manual"
34 .\"O mbind \- Set memory policy for a memory range
35 mbind \- メモリ領域に対してメモリポリシーを設定する
39 .B "#include <numaif.h>"
41 .BI "int mbind(void *" addr ", unsigned long " len ", int " mode ,
42 .BI " unsigned long *" nodemask ", unsigned long " maxnode ,
43 .BI " unsigned " flags );
45 .\"O Link with \fI\-lnuma\fP.
51 .\"O sets the NUMA memory policy,
52 .\"O which consists of a policy mode and zero or more nodes,
53 .\"O for the memory range starting with
55 .\"O and continuing for
63 バイトの範囲のメモリに NUMA メモリポリシーを設定する。
64 NUMA ポリシーはポリシーモードと 0 個以上のノードから構成される。
65 .\"O The memory policy defines from which node memory is allocated.
66 メモリポリシーはどのノードからメモリを割り当てるかを決定する。
68 .\"O If the memory range specified by the
69 .\"O .IR addr " and " len
70 .\"O arguments includes an "anonymous" region of memory\(emthat is
71 .\"O a region of memory created using the
73 .\"O system call with the
74 .\"O .BR MAP_ANONYMOUS \(emor
75 .\"O a memory mapped file, mapped using the
77 .\"O system call with the
79 .\"O flag, pages will only be allocated according to the specified
80 .\"O policy when the application writes [stores] to the page.
89 システムコールを使って作成されたメモリ領域 \(em や
93 を使ってマップされたメモリマップ・ファイルが含まれている場合、
94 ページが指定されたポリシーに基づいて割り当てられるのは、アプリケーション
95 がそのページへの書き込み (データの格納) を行った時だけである。
96 .\"O For anonymous regions, an initial read access will use a shared
97 .\"O page in the kernel containing all zeros.
98 .\"O For a file mapped with
99 .\"O .BR MAP_PRIVATE ,
100 .\"O an initial read access will allocate pages according to the
101 .\"O process policy of the process that causes the page to be allocated.
102 .\"O This may not be the process that called
104 無名領域の場合、最初の読み出しアクセスの際には
105 カーネル内の全データが 0 である共有ページが使用される。
107 でマップされたファイルの場合、最初の読み出しアクセスがあると、
108 ページ割り当てが発生するきっかけとなったプロセスのデフォルトポリシー
110 ページ割り当てのきっかけとなったプロセスは、
114 .\"O The specified policy will be ignored for any
116 .\"O mappings in the specified memory range.
117 .\"O Rather the pages will be allocated according to the process policy
118 .\"O of the process that caused the page to be allocated.
119 .\"O Again, this may not be the process that called
123 のマッピングでは指定されたポリシーは無視され、
124 ページ割り当てが発生するきっかけとなったプロセスのデフォルトポリシーに
125 したがってページの割り当てが行われることになる。
126 繰り返しになるが、ページ割り当てのきっかけとなったプロセスは、
130 .\"O If the specified memory range includes a shared memory region
131 .\"O created using the
133 .\"O system call and attached using the
136 .\"O pages allocated for the anonymous or shared memory region will
137 .\"O be allocated according to the policy specified, regardless which
138 .\"O process attached to the shared memory segment causes the allocation.
139 .\"Omotoki: 訳に少しだけ自信がない。
144 システムコールを使って付加 (attach) されたりした共有メモリ領域が
145 含まれる場合、無名メモリ領域や共有メモリ領域に対するページ割り当ては、
146 共有メモリセグメントへポリシーの設定を行ったプロセスがページ割り当て
147 のきっかけとなったかに関わらず、指定されたポリシーにしたがって割り当て
149 .\"O If, however, the shared memory region was created with the
152 .\"O the huge pages will be allocated according to the policy specified
153 .\"O only if the page allocation is caused by the process that calls
155 .\"O for that region.
158 フラグを指定して作成された場合には、ヒュージページ (huge page) の割り当てが
159 指定されたポリシーにしたがって行われるのは、その領域に対して
161 を呼び出したプロセスがページ割り当てのきっかけとなった場合のみである。
165 .\"O only has an effect for new allocations; if the pages inside
166 .\"O the range have been already touched before setting the policy,
167 .\"O then the policy has no effect.
170 は新規のメモリ割り当てに対してのみ効果を持つ。
171 ポリシーが設定される前にすでに使用されている範囲内のページに対しては、
173 .\"O This default behavior may be overridden by the
176 .\"O .B MPOL_MF_MOVE_ALL
177 .\"O flags described below.
178 このデフォルトの動作は、以下で説明するフラグ
186 .\"O argument must specify one of
187 .\"O .BR MPOL_DEFAULT ,
189 .\"O .B MPOL_INTERLEAVE
191 .\"O .BR MPOL_PREFERRED .
192 .\"O All policy modes except
194 .\"O require the caller to specify via the
197 .\"O the node or nodes to which the mode applies.
202 .BR MPOL_INTERLEAVE ,
208 引き数でそのポリシーモードを適用するノードを指定する必要がある。
212 .\"O argument may also include an optional
213 .\"O .IR "mode flag ".
225 .\"O .BR MPOL_F_STATIC_NODES " (since Linux-2.6.26)"
226 .BR MPOL_F_STATIC_NODES " (Linux-2.6.26 以降)"
229 .\"O specifies physical node ids.
230 .\"O Linux does not remap the
232 .\"O when the process moves to a different cpuset context,
233 .\"O nor when the set of nodes allowed by the process's
234 .\"O current cpuset context changes.
238 Linux では、そのプロセスが異なる CPU 集合コンテキスト (cpuset context)
239 に移動した場合でも、そのプロセスの現在の CPU 集合コンテキストで
240 許可されているノード集合が変化した場合でも、
244 .\"O .BR MPOL_F_RELATIVE_NODES " (since Linux-2.6.26)"
245 .BR MPOL_F_RELATIVE_NODES " (Linux-2.6.26 以降)"
248 .\"O specifies node ids that are relative to the set of
249 .\"O node ids allowed by the process's current cpuset.
252 は、そのプロセスの現在の CPU 集合で許可されているノード ID 集合
256 .\"O points to a bitmask of nodes containing up to
259 .\"O The bit mask size is rounded to the next multiple of
260 .\"O .IR "sizeof(unsigned long)" ,
261 .\"O but the kernel will only use bits up to
266 ビットから構成されるノードのビットマスクを指す。
268 .I sizeof(unsigned long)
269 の倍数に切り上げられるが、カーネルが使用するのは
276 .\"O value of zero specifies the empty set of nodes.
282 .\"O argument is ignored.
294 .\"O is required, it must contain at least one node that is on-line,
295 .\"O allowed by the process's current cpuset context
297 .\"O .B MPOL_F_STATIC_NODES
298 .\"O mode flag is specified],
299 .\"O and contains memory.
303 に、オンラインで、そのプロセスの現在の CPU 集合コンテキストで
305 .RB ( MPOL_F_STATIC_NODES
306 モードフラグが指定されていない場合)、メモリがあるノードが
311 .\"O mode requests that any nondefault policy be removed,
312 .\"O restoring default behavior.
315 はデフォルトではないプロセスのメモリポリシーを削除し、
316 デフォルトの動作に戻すことを指定するものである。
317 .\"O When applied to a range of memory via
319 .\"O this means to use the process policy,
320 .\"O which may have been set with
321 .\"O .BR set_mempolicy (2).
325 が適用された場合、プロセスのデフォルトポリシーを使用することを意味する。
327 .BR set_mempolicy (2)
329 .\"O If the mode of the process policy is also
330 .\"O .BR MPOL_DEFAULT ,
331 .\"O the system-wide default policy will be used.
334 の場合、システム全体のデフォルトポリシーが使用される。
335 .\"O The system-wide default policy allocates
336 .\"O pages on the node of the CPU that triggers the allocation.
338 .\"O .BR MPOL_DEFAULT ,
343 .\"O arguments must be specify the empty set of nodes.
344 システム全体のデフォルトポリシーでは、割り当てのきっかけとなった
345 CPU のノードからページの割り当てを行う。
351 にノードの空集合を指定しなければならない。
355 .\"O mode specifies a strict policy that restricts memory allocation to
356 .\"O the nodes specified in
360 .\"O specifies more than one node, page allocations will come from
361 .\"O the node with the lowest numeric node ID first, until that node
362 .\"O contains no free memory.
363 .\"O Allocations will then come from the node with the next highest
364 .\"O node ID specified in
366 .\"O and so forth, until none of the specified nodes contain free memory.
367 .\"O Pages will not be allocated from any node not specified in the
375 に 2 個以上のノードが指定された場合、ページの割り当ては
376 ノード ID が数字として最小のノードから開始され、
377 そのノードに空きメモリがなくなるまでそのノードから
378 ページ割り当てが行われる。そのノードに空きメモリがなくなったら、
379 .\"motoki: the next highest は the next lowest の間違い?
380 次に小さなノード ID を持つノードからページ割り当てが行われる。
383 で指定された全てのノードで空きメモリがなくなるまで繰り返す。
385 で指定された以外のノードからはページの割り当ては行われない。
388 .\"O .B MPOL_INTERLEAVE
389 .\"O mode specifies that page allocations be interleaved across the
390 .\"O set of nodes specified in
392 .\"O This optimizes for bandwidth instead of latency
393 .\"O by spreading out pages and memory accesses to those pages across
395 .\"O To be effective the memory area should be fairly large,
396 .\"O at least 1MB or bigger with a fairly uniform access pattern.
397 .\"O Accesses to a single page of the area will still be limited to
398 .\"O the memory bandwidth of a single node.
402 に指定されたノード間で交互に行われることを指定するものである。
403 このポリシーでは、複数のノードにページを広げて配置し、これらのページへの
404 メモリアクセスを分散することで、遅延ではなく、帯域を最適化する。
405 効果を得るには、メモリ領域をある程度大きくすべきであり、
406 メモリアクセスのパターンがかなり均一な場合でも
408 このモードでも、一つのページへのアクセスに関しては
409 一つのノードのメモリ帯域が上限となることは変わりない。
411 .\"O .B MPOL_PREFERRED
412 .\"O sets the preferred node for allocation.
413 .\"O The kernel will try to allocate pages from this
414 .\"O node first and fall back to other nodes if the
415 .\"O preferred nodes is low on free memory.
418 .\"O specifies more than one node ID, the first node in the
419 .\"O mask will be selected as the preferred node.
424 .\"O arguments specify the empty set, then the memory is allocated on
425 .\"O the node of the CPU that triggered the allocation.
426 .\"O This is the only way to specify "local allocation" for a
427 .\"O range of memory via
430 は、割り当て時に優先されるノードを設定する。
431 カーネルはまず優先ノードにページ割り当てを行おうとし、
432 優先ノードに空きメモリが少ない場合に他のノードに割り当てを行う。
434 に複数のノード ID が指定された場合は、
436 内の最初のノードが優先ノードとして選択される。
440 で空集合が指定された場合は、割り当てのきっかけとなった CPU のノードに
443 で、あるメモリ領域に対して「ローカルからの割り当て (local allocation)」を
447 .\"O .B MPOL_MF_STRICT
453 .\"O .BR MPOL_DEFAULT ,
454 .\"O then the call will fail with the error
456 .\"O if the existing pages in the memory range don't follow the policy.
466 指定されたポリシーに従っていないメモリ領域にページが存在すると、
471 .\" According to the kernel code, the following is not true
472 .\" --Lee Schermerhorn
473 .\" .\"O In 2.6.16 or later the kernel will also try to move pages
474 .\" .\"O to the requested node with this flag.
475 .\" 2.6.16 以降のカーネルでは、このフラグで要求されたノードに
482 .\"O then the kernel will attempt to move all the existing pages
483 .\"O in the memory range so that they follow the policy.
484 .\"O Pages that are shared with other processes will not be moved.
486 .\"O .B MPOL_MF_STRICT
487 .\"O is also specified, then the call will fail with the error
489 .\"O if some pages could not be moved.
493 が指定されると、カーネルはそのメモリ領域内の既存の全てのページを移動し、
494 指定されたポリシーに従うようにしようとする。
495 他のプロセスと共有されているページは移動されない。
497 も指定された場合、移動できなかったページがあると、
504 .\"O .B MPOL_MF_MOVE_ALL
507 .\"O then the kernel will attempt to move all existing pages in the memory range
508 .\"O regardless of whether other processes use the pages.
509 .\"O The calling process must be privileged
510 .\"O .RB ( CAP_SYS_NICE )
511 .\"O to use this flag.
513 .\"O .B MPOL_MF_STRICT
514 .\"O is also specified, then the call will fail with the error
516 .\"O if some pages could not be moved.
520 が指定されると、カーネルはそのメモリ領域内の既存の全てのページを、
521 他のプロセスがページを使用しているかどうかに関わらず移動する。
522 このフラグを使用するには、呼び出し元のプロセスは特権
526 も指定された場合、移動できなかったページがあると、
531 .\" ---------------------------------------------------------------
532 .\"O .SH RETURN VALUE
537 .\"O on error, \-1 is returned and
539 .\"O is set to indicate the error.
542 は 0 を返す。エラーの場合、\-1 を返し、
545 .\" ---------------------------------------------------------------
548 .\" I think I got all of the error returns. --Lee Schermerhorn
551 .\"O Part or all of the memory range specified by
555 .\"O points outside your accessible address space.
556 .\"O Or, there was an unmapped hole in the specified memory range.
560 で指定されたメモリ領域の一部または全部が、
561 呼び出し元がアクセス可能なアドレス空間外を指している。
562 もしくは指定されたメモリ領域にマップされていない部分 (unmapped hole)
566 .\"O An invalid value was specified for
584 .\"O is not a multiple of the system page size.
591 .\"O specified a nonempty set;
593 がシステムのページサイズの倍数になっていない。
606 .\"O .B MPOL_INTERLEAVE
620 .\"O exceeds a kernel-imposed limit.
623 .\" As at 2.6.23, this limit is "a page worth of bits", e.g.,
624 .\" 8 * 4096 bits, assuming a 4kB page size.
627 .\"O specifies one or more node IDs that are
628 .\"O greater than the maximum supported node ID.
630 に、サポートされている最大ノード ID より大きいノードが指定された。
631 .\"O Or, none of the node IDs specified by
633 .\"O are on-line and allowed by the process's current cpuset context,
634 .\"O or none of the specified nodes contain memory.
636 に、オンラインで、かつそのプロセスの現在の CPU 集合コンテキストで
637 許可されているノードが一つも含まれていないか、
638 メモリを含むノードが一つも指定されていない。
641 .\"O argument specified both
642 .\"O .B MPOL_F_STATIC_NODES
644 .\"O .BR MPOL_F_RELATIVE_NODES .
647 .B MPOL_F_STATIC_NODES
649 .B MPOL_F_RELATIVE_NODES
653 .\"O .B MPOL_MF_STRICT
654 .\"O was specified and an existing page was already on a node
655 .\"O that does not follow the policy;
657 が指定されたが、このポリシーに従っていないノードに
662 .\"O .B MPOL_MF_MOVE_ALL
663 .\"O was specified and the kernel was unable to move all existing
664 .\"O pages in the range.
669 が指定されたが、カーネルが指定された領域内の既存の全てのページを
673 .\"O Insufficient kernel memory was available.
679 .\"O argument included the
680 .\"O .B MPOL_MF_MOVE_ALL
681 .\"O flag and the caller does not have the
690 .\" ---------------------------------------------------------------
695 .\"O system call was added to the Linux kernel in version 2.6.7.
697 システムコールはバージョン 2.6.7 で Linux カーネルに追加された。
698 .\"O .SH CONFORMING TO
700 .\"O This system call is Linux-specific.
701 このシステムコールは Linux 独自である。
704 .\"O For information on library support, see
710 .\"O NUMA policy is not supported on a memory mapped file range
711 .\"O that was mapped with the
716 フラグが指定されてマップされたメモリマップ・ファイルの領域では
721 .\"O mode can have different effects for
724 .\"O .BR set_mempolicy (2).
729 .BR set_mempolicy (2)
733 .\"O is specified for
734 .\"O .BR set_mempolicy (2),
735 .\"O the process's policy reverts to system default policy
736 .\"O or local allocation.
737 .BR set_mempolicy (2)
740 が指定された場合、そのプロセスのポリシーはシステムの
741 デフォルトポリシー、すなわちローカルからの割り当て、に戻る。
744 .\"O is specified for a range of memory using
746 .\"O any pages subsequently allocated for that range will use
747 .\"O the process's policy, as set by
748 .\"O .BR set_mempolicy (2).
752 が指定された場合、その範囲に対してそれ以降に行われるページの割り当てでは、
753 .BR set_mempolicy (2)
754 で設定したのと同じように、そのプロセスのポリシーが適用される。
755 .\"O This effectively removes the explicit policy from the
756 .\"O specified range, "falling back" to a possibly nondefault
758 .\"0motoki: possibly nondefault policy は default policy の間違い?
759 これにより、特定のメモリ領域についてだけ明示的なポリシーを削除し、
760 デフォルトのポリシーに「戻す」ことができる。
761 .\"O To select explicit "local allocation" for a memory range,
765 .\"O .B MPOL_PREFERRED
766 .\"O with an empty set of nodes.
767 .\"O This method will work for
768 .\"O .BR set_mempolicy (2),
770 あるメモリ領域に対して「ローカルからの割り当て」を明示的に設定するには、
778 .BR set_mempolicy (2)
781 .\"O Support for huge page policy was added with 2.6.16.
782 .\"O For interleave policy to be effective on huge page mappings the
783 .\"O policied memory needs to be tens of megabytes or larger.
784 2.6.16 でヒュージページ・ポリシーへの対応が追加された。
785 インターリーブ・ポリシーがヒュージページのマッピングで効果を持つには、
786 ポリシーが適用されるメモリが数十メガバイト以上である必要がある。
788 .\"O .B MPOL_MF_STRICT
789 .\"O is ignored on huge page mappings.
791 はヒュージページのマッピングでは無視される。
795 .\"O .B MPOL_MF_MOVE_ALL
796 .\"O are only available on Linux 2.6.16 and later.
800 は Linux 2.6.16 以降でのみ利用可能である。
803 .BR get_mempolicy (2),
806 .BR set_mempolicy (2),