get_mempolicy

Section: System Calls (2)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

get_mempolicy - スレッドの NUMA メモリーのポリシーを取得する  

ライブラリ

NUMA (Non-Uniform Memory Access) ポリシーライブラリ (libnuma,~-lnuma)  

書式

#include <numaif.h>

long get_mempolicy(unsigned long maxnode;
                   int *mode,
                   unsigned long nodemask[(maxnode + ULONG_WIDTH - 1)
/ ULONG_WIDTH],
                   unsigned long maxnode, void *addr,
                   unsigned long flags);
 

説明

get_mempolicy() は、呼び出し元スレッドもしくは指定されたメモリーアドレスの NUMA ポリシーを flags の設定に従って取得する。

NUMA (非対称メモリーアクセス) マシンでは、CPU により メモリーコントローラーが異なり、距離も異なっている。 メモリーポリシーは、どのノードからメモリーをそのスレッドに 割り当てるかを定めるものである。

If flags is specified as 0, then information about the calling thread's default policy (as set by set_mempolicy(2)) is returned, in the buffers pointed to by mode and nodemask. The value returned in these arguments may be used to restore the thread's policy to its state at the time of the call to get_mempolicy() using set_mempolicy(2). When flags is 0, addr must be specified as NULL.

flags に MPOL_F_MEMS_ALLOWED (Linux 2.6.24 以降で利用可能) を指定すると、 mode 引数は無視され、 そのスレッドがその後の mbind(2) や set_mempolicy(2) で (モードフラグ が指定されていない場合に) 指定できるノード (メモリー) の集合が nodemask に返される。 MPOL_F_MEMS_ALLOWED を、 MPOL_F_ADDR や MPOL_F_NODE と同時に指定することはできない。

flags に MPOL_F_ADDR が指定された場合、 addr で指定されたメモリーアドレスに適用されているポリシーに関する情報を返す。 mbind(2) や numa(3) で説明されているヘルパー関数を使って、 addr を含むメモリー領域に対するポリシーが設定されていた場合には、 返されるポリシーはスレッドのデフォルトポリシーと違うことがある。

If the mode argument is not NULL, then get_mempolicy() will store the policy mode and any optional mode flags of the requested NUMA policy in the location pointed to by this argument. If nodemask is not NULL, then the nodemask associated with the policy will be stored in the location pointed to by this argument. maxnode specifies the number of node IDs that can be stored into nodemask---that is, the maximum node ID plus one. The value specified by maxnode is always rounded to a multiple of sizeof(unsigned long)*8.

flags で MPOL_F_NODE と MPOL_F_ADDR の両方が指定された場合、 get_mempolicy() はアドレス addr が割り当てられているノードのノード ID を mode が指す場所に入れて返す。 指定されたアドレスにどのページもまだ割り当てられていない場合、 get_mempolicy() は、あたかもそのスレッドがそのアドレスに対して読み込みアクセスを 実行したかのようにページの割り当てを行い、ページが割り当てられた ノードの ID を返す。

If flags specifies MPOL_F_NODE, but not MPOL_F_ADDR, and the thread's current policy is MPOL_INTERLEAVE or MPOL_WEIGHTED_INTERLEAVE, then get_mempolicy() will return in the location pointed to by a non-NULL mode argument, the node ID of the next node that will be used for interleaving of internal kernel pages allocated on behalf of the thread. These allocations include pages for memory-mapped files in process memory ranges mapped using the mmap(2) call with the MAP_PRIVATE flag for read accesses, and in memory ranges mapped with the MAP_SHARED flag for all accesses.

他のフラグは予約されている。

設定可能なポリシーの概要については set_mempolicy(2) を参照。  

返り値

成功すると、 get_mempolicy() は 0 を返す。エラーの場合、-1 を返し、 errno にエラーを示す値を設定する。  

エラー

EFAULT
nodemask と maxnode で指定されたメモリー領域の一部または全部が、 呼び出し元がアクセス可能なアドレス空間外を指している。
EINVAL
The value specified by maxnode is less than the number of node IDs supported by the system. Or flags specified values other than MPOL_F_NODE or MPOL_F_ADDR; or flags specified MPOL_F_ADDR and addr is NULL, or flags did not specify MPOL_F_ADDR and addr is not NULL. Or, flags specified MPOL_F_NODE but not MPOL_F_ADDR and the current thread policy is neither MPOL_INTERLEAVE nor MPOL_WEIGHTED_INTERLEAVE. Or, flags specified MPOL_F_MEMS_ALLOWED with either MPOL_F_ADDR or MPOL_F_NODE. (And there are other EINVAL cases.)
 

標準規格

Linux.  

歴史

Linux 2.6.7.  

注意

ライブラリによるサポートについては numa(7) を参照。  

関連項目

getcpu(2), mbind(2), mmap(2), set_mempolicy(2), numa(3), numa(7), numactl(8)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
標準規格
歴史
注意
関連項目

This document was created by man2html, using the manual pages.