hash - DPDK Hash 无法从辅助进程中查找数据

标签 hash dpdk

无法使用来自辅助进程的现有 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 (&params);
    }
  // 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创建哈希 testCMD-1: ./build/basicfwd -l 5 -w 0000:08:00.1 --vdev=net_tap0 --socket-limit=2048,1 --file-prefix=test二进制 2:modified helloworld查找哈希 test , 否则 assertCMD-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/

相关文章:

iphone - 我真的必须重写哈希只是因为我重写了 isEqual : for my subclass?

java - 简单哈希函数(字符串输入输出 1 个字节)

ruby - 从 Ruby Hash 中获取独特的内容

c++ - 动态哈希->类标签

linux - 如何使用DPDK编写DNS服务器?

java - 有什么方法可以在 Java 中生成与在 C# 中生成的 UUID 相同的 UUID?

c - 如何在DPDK代码中解释这段C代码

c - 如何在基于 dpdk 的应用程序中启用 Debug模式?

linux - DPDK错误: "Cause: No Ethernet ports - bye"

dpdk - DPDK中Reorder Library和IP分片的目的