All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org, Yuanhan Liu <yliu@fridaylinux.org>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Tiwei Bie <tiwei.bie@intel.com>
Subject: [PATCH v2 0/4] net/virtio: fix memory leak when reinitializing device
Date: Fri, 19 Jan 2018 16:55:52 +0100	[thread overview]
Message-ID: <20180119155556.32597-1-olivier.matz@6wind.com> (raw)
In-Reply-To: <20180118090733.12728-1-olivier.matz@6wind.com>

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().

v1 -> v2:
- move the vq != NULL check from the refactor patch to the memory
  leak fix patch (Yuanhan)
- new patch to fix queue flushing with vector Rx enabled (Tiwei)
- move the backportable fixes at the beginning of the patchset (Yuanhan)
- remove Cc stable on the typo fix (Yuanhan)
  note: I finally kept it in the patchset


Olivier Matz (4):
  net/virtio: fix queue flushing with vector Rx enabled
  net/virtio: fix memory leak when reinitializing device
  net/virtio: rationalize queue flushing
  net/virtio: fix typo in function name

 drivers/net/virtio/virtio_ethdev.c | 71 +++++++++++++++++---------------------
 drivers/net/virtio/virtqueue.c     | 19 ++++++++--
 drivers/net/virtio/virtqueue.h     | 13 ++++++-
 3 files changed, 59 insertions(+), 44 deletions(-)

-- 
2.11.0

  parent reply	other threads:[~2018-01-19 15:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18  9:07 [PATCH 0/3] net/virtio: fix memory leak when reinitializing device Olivier Matz
2018-01-18  9:07 ` [PATCH 1/3] net/virtio: fix typo in function name Olivier Matz
2018-01-18 13:27   ` Yuanhan Liu
2018-01-18 13:45     ` Olivier Matz
2018-01-18 14:06       ` Yuanhan Liu
2018-01-18  9:07 ` [PATCH 2/3] net/virtio: rationalize queue flushing Olivier Matz
2018-01-18 13:26   ` Yuanhan Liu
2018-01-18 13:55     ` Olivier Matz
2018-01-18 14:04       ` Yuanhan Liu
2018-01-18 14:05   ` Tiwei Bie
2018-01-18 14:55     ` Olivier Matz
2018-01-18 15:48       ` Tiwei Bie
2018-01-18 15:56         ` Olivier Matz
2018-01-18  9:07 ` [PATCH 3/3] net/virtio: fix memory leak when reinitializing device Olivier Matz
2018-01-19 15:55 ` Olivier Matz [this message]
2018-01-19 15:55   ` [PATCH v2 1/4] net/virtio: fix queue flushing with vector Rx enabled Olivier Matz
2018-01-22  2:56     ` Tiwei Bie
2018-01-22 10:38       ` Olivier Matz
2018-01-23  2:05         ` Tiwei Bie
2018-01-19 15:55   ` [PATCH v2 2/4] net/virtio: fix memory leak when reinitializing device Olivier Matz
2018-01-19 15:55   ` [PATCH v2 3/4] net/virtio: rationalize queue flushing Olivier Matz
2018-01-19 15:55   ` [PATCH v2 4/4] net/virtio: fix typo in function name Olivier Matz
2018-01-23 15:54   ` [PATCH v3 0/4] net/virtio: fix memory leak when reinitializing device Olivier Matz
2018-01-23 15:54     ` [PATCH v3 1/4] net/virtio: fix queue flushing with vector Rx enabled Olivier Matz
2018-01-23 15:54     ` [PATCH v3 2/4] net/virtio: fix memory leak when reinitializing device Olivier Matz
2018-01-23 15:54     ` [PATCH v3 3/4] net/virtio: rationalize queue flushing Olivier Matz
2018-01-23 15:54     ` [PATCH v3 4/4] net/virtio: fix typo in function name Olivier Matz
2018-01-26 15:34     ` [PATCH v3 0/4] net/virtio: fix memory leak when reinitializing device Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180119155556.32597-1-olivier.matz@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=tiwei.bie@intel.com \
    --cc=yliu@fridaylinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.