我可以从一个指针地址(在C在Linux上)的NUMA节点? [英] Can I get the NUMA node from a pointer address (in C on Linux)?

查看:255
本文介绍了我可以从一个指针地址(在C在Linux上)的NUMA节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的NUMA系统上设置我的code认真加载和处理本地数据。我认为。也就是说,用于调试目的,我真的希望能够使用特定的功能,这已被许多其他功能设置里面被访问的指针地址,直接识别的内存指着NUMA节点(S)是居住,所以我可以检查,一切都位于它应设。这可能吗?

I've set up my code to carefully load and process data locally on my NUMA system. I think. That is, for debugging purposes I'd really like to be able to use the pointer addresses being accessed inside a particular function, which have been set up by many other functions, to directly identify the NUMA node(s) that the memory pointed at is residing on, so I can check that everything is located where it should be located. Is this possible?

我发现在MSDN上这个请求<一个href=\"http://social.msdn.microsoft.com/Forums/en-US/parallelcppnative/thread/37a02e17-e160-48d9-8625-871ff6b21f72\">http://social.msdn.microsoft.com/Forums/en-US/parallelcppnative/thread/37a02e17-e160-48d9-8625-871ff6b21f72同样的事情,但得到的答复使用QueryWorkingSetEx()这似乎是Windows专用。可以这样在Linux上做了什么?我在Debian的挤压,为precise。

I found this request on msdn http://social.msdn.microsoft.com/Forums/en-US/parallelcppnative/thread/37a02e17-e160-48d9-8625-871ff6b21f72 for the same thing, but the answer uses QueryWorkingSetEx() which appears to be Windows specific. Can this be done on Linux? I'm on Debian Squeeze, to be precise.

感谢。

推荐答案

有在 -lnuma move_pages 功能>: http://linux.die.net/man/2/move_pages

There is an move_pages function in -lnuma: http://linux.die.net/man/2/move_pages

这可以举报地址(页)的当前状态到节点的映射:

which can report current state of address(page) to node mappings:

节点也可以为空,在这种情况下move_pages()不将任何网页,而是会返回每个页面目前所在的节点,状态数组中为止。获得每个页的状态可能是必要的,以确定需要被移动网页。

nodes can also be NULL, in which case move_pages() does not move any pages but instead will return the node where each page currently resides, in the status array. Obtaining the status of each page may be necessary to determine pages that need to be moved.

所以,呼叫可能是这样:

So, call may be like:

 void * ptr_to_check = your_address;
 /*here you should align ptr_to_check to page boundary */
 int status[1];
 int ret_code;
 status[0]=-1;
 ret_code=move_pages(0 /*self memory */, 1, &ptr_to_check,
    NULL, status, 0);
 printf("Memory at %p is at %d node (retcode %d)\n", ptr_to_check, status[0], ret_code);

这篇关于我可以从一个指针地址(在C在Linux上)的NUMA节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆