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);
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) を参照。