Is there any example of using mbind in C/C++ code? -
i trying use mbind() in c++ code in order rearrange virtual pages across 4 numa domains, unfortunately new function:
long mbind(void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags);
currently, have this:
mbind(0x0,4611686018424767488,mpol_bind,nodemask,maxnode,mpol_mf_move);
from specs it's still unclear me put , how put nodemask
, maxnode
.
nodemask
pointer bitmask of allowed numa nodes. bitmask array of unsigned long
elements each array element holding many bits size of unsigned long int
on particular architecture allows. unless program running on big numa system, single unsigned long
variable should suffice.
maxnode
gives number of significant bits in nodemask
. kernel rounds internally size multiple of sizeof(unsigned long)
uses maxnode
bits.
there many examples , libraries around allow create , conveniently manipulate bitmasks without having fiddle bit operations yourself. can utilise libnuma
. doesn't allow set mpol_mf_move
policy includes functions creation , manipulation of nodemasks.
a terrible , unportable linux pro-tip: existing macros deal cpu affinity masks, namely cpu_zero
/ cpu_set
/ cpu_clr
, associated data structure cpu_set_t
can used numa nodemasks. reason (1) both implemented arrays of unsigned long
, (2) there less numa nodes logical cpus, therefore cpu_set_t
should have enough bits able represent numa nodes on system.
side note: 4611686018424767488
should suffixed ll
.
Comments
Post a Comment