Hash DPDK哈希无法从辅助进程查找数据
无法使用辅助进程中的现有rte哈希:Hash DPDK哈希无法从辅助进程查找数据,hash,dpdk,Hash,Dpdk,无法使用辅助进程中的现有rte哈希: h = rte_hash_find_existing("some_hash"); if (h) { // this will work, in case we re-create //rte_hash_free(h); } else { h = rte_hash_create (¶ms); } // using the hash will
h = rte_hash_find_existing("some_hash");
if (h) {
// this will work, in case we re-create
//rte_hash_free(h);
}
else {
h = rte_hash_create (¶ms);
}
// using the hash will crash the process with:
// Program received signal SIGSEGV, Segmentation fault.
ret = rte_hash_lookup_data (h,name,&data);
DPDK版本:DPDK-19.02
构建模式静态:CONFIG_RTE_Build_SHARED_LIB=n
主进程和辅助进程是不同的二进制文件,但链接到同一个DPDK库
该键被添加到primary中,如下所示
struct cdev_key {
uint64_t len;
};
struct cdev_key key = { 0 };
if (rte_hash_add_key_data (testptr, &key,(void *) &test) < 0) {
fprintf (stderr,"add failed errno: %s\n", rte_strerror(rte_errno));
}
使用DPDK版本
19.02
,我可以运行两个独立的二进制文件而不会出现问题
[EDIT-1]根据票据中的更新,我可以在辅助进程中查找从主进程添加的哈希条目
Priamry log:
rte_hash_count 1 ret:val 0x0:0x0
Secondary log:
0x17fd61380 rte_hash_count 1
rte_hash_count 1 key:val 0:0
注意:如果使用rte_hash_lookup
请记住通过echo 0 | tee/proc/sys/kernel/randomize_va_空间
禁用Linux ASLR
二进制1:修改了示例/骨架
以创建哈希测试
CMD-1:/build/basicfwd-l 5-w 0000:08:00.1--vdev=net\u tap0--socket limit=2048,1--file prefix=test
二进制代码2:修改helloworld
以查找哈希测试
,否则断言
CMD-2:{1..20000}中i的;do du-kh/var/run/dpdk//build/helloworld-l6--proc type=secondary--log level=3--file prefix=test;完成
更改或删除文件前缀
会导致命中断言逻辑
注意:DPDK 19.02有一个固有的bug,它不会清除/var/run/DPDK/
;因此建议使用19.11.2 LTS
代码-1:
struct rte_hash_parameters test = {0};
test.name = "test";
test.entries = 32;
test.key_len = sizeof(uint64_t);
test.hash_func = rte_jhash;
test.hash_func_init_val = 0;
test.socket_id = 0;
struct rte_hash *testptr = rte_hash_create(&test);
if (testptr == NULL) {
rte_panic("Failed to create test hash, errno = %d\n", rte_errno);
}
代码-2:
assert(rte_hash_find_existing("test"));
printf("hello from core %u::%p\n", lcore_id, rte_hash_find_existing("test"));
printf("hello from core %u::%p\n", lcore_id, rte_hash_find_existing("test1"));
使用DPDK版本
19.02
,我可以运行两个独立的二进制文件而不会出现问题
[EDIT-1]根据票据中的更新,我可以在辅助进程中查找从主进程添加的哈希条目
Priamry log:
rte_hash_count 1 ret:val 0x0:0x0
Secondary log:
0x17fd61380 rte_hash_count 1
rte_hash_count 1 key:val 0:0
注意:如果使用rte_hash_lookup
请记住通过echo 0 | tee/proc/sys/kernel/randomize_va_空间
禁用Linux ASLR
二进制1:修改了示例/骨架
以创建哈希测试
CMD-1:/build/basicfwd-l 5-w 0000:08:00.1--vdev=net\u tap0--socket limit=2048,1--file prefix=test
二进制代码2:修改helloworld
以查找哈希测试
,否则断言
CMD-2:{1..20000}中i的;do du-kh/var/run/dpdk//build/helloworld-l6--proc type=secondary--log level=3--file prefix=test;完成
更改或删除文件前缀
会导致命中断言逻辑
注意:DPDK 19.02有一个固有的bug,它不会清除/var/run/DPDK/
;因此建议使用19.11.2 LTS
代码-1:
struct rte_hash_parameters test = {0};
test.name = "test";
test.entries = 32;
test.key_len = sizeof(uint64_t);
test.hash_func = rte_jhash;
test.hash_func_init_val = 0;
test.socket_id = 0;
struct rte_hash *testptr = rte_hash_create(&test);
if (testptr == NULL) {
rte_panic("Failed to create test hash, errno = %d\n", rte_errno);
}
代码-2:
assert(rte_hash_find_existing("test"));
printf("hello from core %u::%p\n", lcore_id, rte_hash_find_existing("test"));
printf("hello from core %u::%p\n", lcore_id, rte_hash_find_existing("test1"));
正如DPDK程序员指南中提到的,使用多处理器功能有一些限制。其中之一是指向函数的指针不能在进程之间共享。因此,哈希函数在辅助进程上不可用。建议的解决方法是使用散列值(而不是键)访问哈希表的主进程和次进程中的散列部分 来自DPDK指南: 为了解决此问题,建议多进程应用程序执行哈希计算,方法是直接从代码中调用哈希函数,然后使用rte_hash_add_with_hash()/rte_hash_lookup_with_hash()函数,而不是内部执行哈希的函数,如rte_hash_add()/rte_hash_lookup() 有关更多信息,请参阅指南[36.3.多进程限制] 链接:
在撰写本答案时,本指南针对的是DPDK程序员指南中提到的
DPDK 20.08
,使用多处理器功能有一些限制。其中之一是指向函数的指针不能在进程之间共享。因此,哈希函数在辅助进程上不可用。建议的解决方法是使用散列值(而不是键)访问哈希表的主进程和次进程中的散列部分
来自DPDK指南:
为了解决此问题,建议多进程应用程序执行哈希计算,方法是直接从代码中调用哈希函数,然后使用rte_hash_add_with_hash()/rte_hash_lookup_with_hash()函数,而不是内部执行哈希的函数,如rte_hash_add()/rte_hash_lookup()
有关更多信息,请参阅指南[36.3.多进程限制]
链接:
在撰写此答案时,指南是针对
DPDK 20.08
的,请添加以下详细信息DPDK版本构建模式是静态的或共享的主应用程序,辅助应用程序是单个应用程序如果主应用程序和辅助应用程序不同,它们是否具有不同的功能。so或dlopen已通过使用确保这不是pmap问题base virtaddr???@VipinVarghese感谢您的回复,有没有简单的方法检查base virtaddr?顺便说一句,我检查了散列指针(h),它在两个进程中都是相同的。您可以使用pmap-x
并交叉检查rte_映射virt地址。如果您觉得可疑,请使用--base virtaddr 0x3000000000000
@VipinVarghese两个rte_地图相同,但是pmap中的fbarray_memseg-*地址和我们自己的动态DPDK库的地址有什么变化吗?请添加以下详细信息DPDK版本构建模式是静态的或共享的主应用程序,辅助应用程序是单个应用程序如果主应用程序和辅助应用程序不同,它们是否具有不同的地址。so或dlopen已确保没有使用base virtaddr发布pmap???@VipinVarghese感谢您的回复,有没有简单的方法检查base virtaddr?顺便说一句,我检查了散列指针(h),它在两个进程中都是相同的。您可以使用pmap-x
并交叉检查rte_映射virt地址。如果您觉得可疑,请使用--base virtaddr 0x300000000
@VipinVarghese两个rte_映射都是相同的,但pmap中的更改是fbarray_memseg-*地址和ou的地址