From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 342051B172 for ; Thu, 18 Jan 2018 10:07:56 +0100 (CET) Received: from glumotte.dev.6wind.com. (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 5869D12388F; Thu, 18 Jan 2018 10:06:23 +0100 (CET) From: Olivier Matz To: dev@dpdk.org, Yuanhan Liu , Maxime Coquelin , Tiwei Bie Date: Thu, 18 Jan 2018 10:07:30 +0100 Message-Id: <20180118090733.12728-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH 0/3] net/virtio: fix memory leak when reinitializing device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jan 2018 09:07:56 -0000 When devops->configure() is called, the queues may be reallocated if the features flag changed, but the previous are not freed. This patchset fixes this issue. To really point out the issue, I instrumented rte_malloc, rte_memzone_reserve, rte_mbuf_alloc to track the allocations and frees. For reference, the patch is available here: https://www.droids-corp.org/~zer0/hidden/0001-debug-malloc.patch Iit conflicts a bit with the patchset, but it is quite easy to solve. To reproduce the issue: cd dpdk make config T=x86_64-native-linuxapp-gcc sed -i 's,CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_INIT=n,CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_INIT=y,' build/.config make -j4 mkdir -p /mnt/huge mount -t hugetlbfs nodev /mnt/huge echo 256 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages modprobe uio_pci_generic python usertools/dpdk-devbind.py -b uio_pci_generic 0000:00:02.0 ./build/app/testpmd -l 0,1 --log-level 8 -- --total-num-mbufs=16384 \ -i --port-topology=chained --disable-hw-vlan-filter \ --disable-hw-vlan-strip --enable-rx-cksum --enable-lro \ --txqflags=0 --no-lsc-interrupt # testpmd commands port stop 0 port config all rx-cksum off port start 0 quit Without the patchset, the debug patch displays a leak of mbufs allocated from virtio_dev_rx_queue_setup_finish() and a leak of rte_mallocs allocated from virtio_init_queue(). After the patchset, only one malloc is remaining after the device close, but this is normal, because this area is freed in dev_uninit(). Olivier Matz (3): net/virtio: fix typo in function name net/virtio: rationalize queue flushing net/virtio: fix memory leak when reinitializing device drivers/net/virtio/virtio_ethdev.c | 60 ++++++++++++++++++++------------------ drivers/net/virtio/virtqueue.c | 2 +- drivers/net/virtio/virtqueue.h | 2 +- 3 files changed, 33 insertions(+), 31 deletions(-) -- 2.11.0