无法使用来自辅助进程的现有 rte Hash:
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
Primary 和 Secondary 进程是不同的二进制文件,但链接到同一个 DPDK 库
主键添加如下
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));
}
并在二级中使用如下: printf("Looking for data\n");
struct cdev_key key = { 0 };
int ret = rte_hash_lookup_data (h,&key,&data);
最佳答案
使用 DPDK 版本 19.02
,我可以毫无问题地运行 2 个单独的二进制文件。
[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_space
禁用 Linux ASLR .二进制 1:
modified example/skeleton
创建哈希 test
CMD-1: ./build/basicfwd -l 5 -w 0000:08:00.1 --vdev=net_tap0 --socket-limit=2048,1 --file-prefix=test
二进制 2:modified helloworld
查找哈希 test
, 否则 assert
CMD-2:for i in {1..20000}; do du -kh /var/run/dpdk/; ./build/helloworld -l 6 --proc-type=secondary --log-level=3 --file-prefix=test; done
更改或删除 file-prefix
导致断言逻辑被击中。注意:DPDK 19.02 具有无法清理
/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"));
关于hash - DPDK Hash 无法从辅助进程中查找数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62174832/