Linux mbind呼叫在Hugetlb内存上失败
我正在尝试使用MBIND将内存绑定到特定的NUMA节点。我注意到,如果使用map_hugetlb分配了我的内存,则失败,但是如果我不尝试映射augeTlb,mbind会成功。
我绝对想要大型页面,并将内存映射到特定的NUMA节点。 Ami做错了什么,还是不支持?
在CentOS7编辑上运行
//mbind fails on this
void * buf = mmap( NULL, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB, 0, 0 );
//works on this
void * buf2 = mmap( NULL, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0 );
int numaNode = 1;
unsigned long nodemask = 0;
nodemask |= 1 << numaNode;
if( mbind( buf, sz, MPOL_BIND, &nodemask, sizeof(nodemask) * 8, 0 ) < 0 )
printf( "mbind buf failed: %s\n", strerror(errno) );
if( mbind( buf2, sz, MPOL_BIND, &nodemask, sizeof(nodemask) * 8, 0 ) < 0 )
printf( "mbind buf2 failed: %s\n", strerror(errno) );
:要清楚,MMAP工作正常,我的机器配置了大型页面。我没有在此处检查MMAP返回代码是否简洁
I'm trying to use mbind to bind my memory to a specific NUMA node. I noticed it fails if my memory is allocated with mmap using MAP_HUGETLB, but mbind succeeds if I dont try to MAP_HUGETLB.
I definitely want both HUGE pages and to map the memory to a specific NUMA node.
AmI doing something wrong, or is this not supported?
Running on CentOS7
//mbind fails on this
void * buf = mmap( NULL, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB, 0, 0 );
//works on this
void * buf2 = mmap( NULL, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0 );
int numaNode = 1;
unsigned long nodemask = 0;
nodemask |= 1 << numaNode;
if( mbind( buf, sz, MPOL_BIND, &nodemask, sizeof(nodemask) * 8, 0 ) < 0 )
printf( "mbind buf failed: %s\n", strerror(errno) );
if( mbind( buf2, sz, MPOL_BIND, &nodemask, sizeof(nodemask) * 8, 0 ) < 0 )
printf( "mbind buf2 failed: %s\n", strerror(errno) );
Edit: to be clear the mmap works fine and my machine is configured with huge pages. I didn’t check the mmap return code here for brevity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不检查
MMAP
返回错误值。除非您首先保留它们,否则它无法分配大型页面。保留
hugeadm
,例如:另一个选项是使用透明的巨大页面,而无需将任何额外标志传递给
mmap
。参见 nofollow noreferrer“> transparrent巨大页面支持 提供全部详细信息。You don't check
mmap
return value for error. It fails to allocate huge pages unless you reserve them first.Reserve huge pages with
hugeadm
, for example:Another option is to use transparent huge pages without having to pass any extra flags to
mmap
. See Transparent Hugepage Support for full details.我认为这种Arlreadre已经解决了,请检查一下。
link
I think this artilcle arlready solved under, please check for it.
link