【问题标题】:How to address the error "MBUF: error setting mempool handler" seen with DPDK 20.11如何解决 DPDK 20.11 中出现的错误“MBUF: error setting mempool handler”
【发布时间】:2026-01-05 01:40:01
【问题描述】:

我将 libdpdk 静态链接到我的应用程序,当我启动应用程序时,EAL 初始化失败。

日志:

EAL: Detected 80 lcore(s)
EAL: Detected 2 NUMA nodes
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: Probing VFIO support...
EAL: VFIO support initialized
EAL: No legacy callbacks, legacy socket not created
MBUF: error setting mempool handler
EAL: Error - exiting with code: 1
  Cause: Cannot init packet mbuf pool Invalid argument

我使用以下命令在我的测试服务器中安装了 DPDK-20.11。

# meson build
#cd build
#ninja ; ninja install

我以 l2fwd Makefile 为例构建了我的应用程序 Makefile,不确定我缺少什么。

寻找建议。

[编辑-1]

int main(int argc, char **argv)
{ 

int ret; unsigned lcore_id; 

ret = rte_eal_init(argc, argv); 
if (ret < 0) 
rte_panic("Cannot init EAL\n"); 

struct rte_mempool *mp = 
rte_pktmbuf_pool_create("packet_pool", 8192, 64, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); 

return 0;
}

如何构建

  1. 将 makefile 从 l2fwd 复制到自定义应用文件夹
  2. 执行make static
  3. 运行应用程序sudo ./a.out

【问题讨论】:

  • 能否请您提供以下信息1) have you used make or make static for l2fwd examples? 2) can you perform ls -lal [dpdk root folder]/examples/l2fwd/build? 3) can you share the cmd line used? 4) can you update ticket with running --log-level=8
  • Vipin,我的意思是我的应用程序我以 l2fwd 的 makefile 为例。
  • 我会谦虚地请您分享您的简单代码 sn-p 以重现错误。这是为了重现错误并隔离它是否来自 Makefile 或您的自定义应用程序。
  • Vipin ,为之前的简短回复道歉,(在我完成回复之前,我误击了输入)。我使用 make static 构建。使用日志级别 8,我看不到任何新日志 EAL: Detected 80 lcore(s) EAL: Detected 2 NUMA nodes EAL: Detected static linkage of DPDK EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Selected IOVA mode 'VA' EAL: Probing VFIO support... EAL: VFIO support initialized EAL: No legacy callbacks, legacy socket not created MBUF: error setting mempool handler EAL: Error - exiting with code: 1
  • 代码 sn-p ``` int main(int argc, char **argv) { int ret;无符号 lcore_id; ret = rte_eal_init(argc, argv); if (ret

标签: dpdk


【解决方案1】:

[EDIT-1] 实时调试更新

目标操作系统:CENTOS 7 DPDK版本:20.11.1

导致错误的原因有多种

  1. 安装 Mellanox libverbs 会影响 dpdk libdpdk.pc 的 cflags 和 ldflags
  2. DPDK 21.11.1 介子构建 (meson -Dexamples=l2fwd build; ninja -C install) 不匹配 l2fwd Makefile option of make static
  3. 从已安装的目标中使用 pkg-config 也是不正确的。

为了修复错误,我们编辑了 /usr/local/lib64/pkgconfig/libdpdk.pc 以包含 -Wl,--whole-archive-Wl,--no-whole-archive 下的静态库

有效

#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_lcore.h>
#include <rte_per_lcore.h>
#include <rte_branch_prediction.h>
#include <rte_interrupts.h>
#include <rte_random.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_string_fns.h>


int main(int argc, char **argv)
{

int ret; unsigned lcore_id;

ret = rte_eal_init(argc, argv);
if (ret < 0)
rte_panic("Cannot init EAL\n");

struct rte_mempool *mp =
rte_pktmbuf_pool_create("packet_pool", 8192, 64, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
if (mp == NULL)
        rte_panic("Cannot init EAL\n");

printf("done!!!!!!!!!!!!");

return 0;
}

构建:sudo make static

输出

$ sudo ./build/l2fwd
EAL: Detected 32 lcore(s)
EAL: Detected 2 NUMA nodes
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: Probing VFIO support...
done!!!!!!!!!!!!

【讨论】:

    最近更新 更多