在 dpdk 示例应用程序(示例:dpdk-testpmd)中使用 valgrind 时,它会在启动时卡住,如下所示:
[root@node1 app]# valgrind --leak-check=yes ./dpdk-testpmd -a 0000:af:00.3
==322313== Memcheck, a memory error detector
==322313== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==322313== Using Valgrind-3.21.0.GIT and LibVEX; rerun with -h for copyright info
==322313== Command: ./dpdk-testpmd -a 0000:af:00.3
==322313==
EAL: Detected CPU lcores: 96
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: No available 2048 kB hugepages reported
EAL: VFIO support initialized
==322313== Warning: set address range perms: large range [0x140000000, 0x980000000) (noaccess)
==322313== Warning: set address range perms: large range [0x940000000, 0x980000000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
==322313== Warning: set address range perms: large range [0x100b967000, 0x184b967000) (noaccess)
EAL: WARNING! Base virtual address hint (0xa80001000 != 0x1040000000) not respected!
EAL: This may cause issues with mapping memory into secondary processes
==322313== Warning: set address range perms: large range [0x100b967000, 0x1040000000) (noaccess)
在没有 valgrind 的情况下运行时它工作正常:
[root@node1 app]# ./dpdk-testpmd -a 0000:af:00.3
EAL: Detected CPU lcores: 96
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: No available 2048 kB hugepages reported
EAL: VFIO support initialized
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ice (8086:1593) device: 0000:af:00.3 (socket 1)
ice_load_pkg_type(): Active package is: 1.3.28.0, ICE OS Default Package (double VLAN mode)
TELEMETRY: No legacy callbacks, legacy socket not created
testpmd: create a new mbuf pool <mb_pool_0>: n=203456, size=2176, socket=0
testpmd: preferred mempool ops selected: ring_mp_mc
testpmd: create a new mbuf pool <mb_pool_1>: n=203456, size=2176, socket=1
testpmd: preferred mempool ops selected: ring_mp_mc
Warning! port-topology=paired and odd forward ports number, the last port will pair with itself.
Configuring Port 0 (socket 1)
ice_set_rx_function(): Using AVX2 Vector Rx (port 0).
Port 0: B4:96:91:A7:66:57
Checking link statuses...
Done
No commandline core given, start packet forwarding
io packet forwarding - ports=1 - cores=1 - streams=1 - NUMA support enabled, MP allocation mode: native
Logical Core 1 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 1) -> TX P=0/Q=0 (socket 1) peer=02:00:00:00:00:00
io packet forwarding packets/burst=32
nb forwarding cores=1 - nb forwarding ports=1
port 0: RX queue number: 1 Tx queue number: 1
Rx offloads=0x0 Tx offloads=0x10000
RX queue: 0
RX desc=1024 - RX free threshold=32
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
RX Offloads=0x0
TX queue: 0
TX desc=1024 - TX free threshold=32
TX threshold registers: pthresh=32 hthresh=0 wthresh=0
TX offloads=0x10000 - TX RS bit threshold=32
Press enter to exit
看来我需要在 valgrind 源代码中放置一个 gdb 并进行分析。然而,在这样做之前,我想检查一下是否有人遇到过类似的问题并找到了解决方案。
请注意,我的意图不是调试内存泄漏/由 rte_* 调用分配/管理的内存区域的损坏。相反,我希望使用 valgrind 调试应用程序使用常规 malloc 调用分配的内存区域中的泄漏/损坏。此应用程序链接到 dpdk 库。