From: Olivier Matz <olivier.matz@6wind.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: tiwei.bie@intel.com, yliu@fridaylinux.org,
ferruh.yigit@intel.com, victork@redhat.com, dev@dpdk.org,
stable@dpdk.org, zhihong.wang@intel.com, qian.q.xu@intel.com,
lei.a.yao@intel.com
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH 1/2] virtio: fix resuming traffic with rx vector path
Date: Mon, 12 Feb 2018 14:18:27 +0100 [thread overview]
Message-ID: <20180212131827.ko5crddn2haihzac@platinum> (raw)
In-Reply-To: <20180209142654.29409-2-maxime.coquelin@redhat.com>
On Fri, Feb 09, 2018 at 03:26:53PM +0100, Maxime Coquelin wrote:
> This patch fixes traffic resuming issue seen when using
> Rx vector path.
>
> Fixes: efc83a1e7fc3 ("net/virtio: fix queue setup consistency")
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Proposed change for a more detailed commit log (thanks Tiwei for
the explanation):
Since commit efc83a1e7fc3 ("net/virtio: fix queue setup consistency"),
when resuming a virtio port, the rx rings are refilled with new mbufs
until they are full (vq->vq_free_cnt == 0). This is done without
ensuring that the descriptor index remains a multiple of
RTE_VIRTIO_VPMD_RX_REARM_THRESH, which is a prerequisite when using the
vector mode. This can cause an out of bound access in the rx ring.
This commit changes the vector refill method from
virtqueue_enqueue_recv_refill_simple() to virtio_rxq_rearm_vec(), which
properly checks that the refill is done by batch of
RTE_VIRTIO_VPMD_RX_REARM_THRESH.
> ---
> drivers/net/virtio/virtio_rxtx.c | 34 ++++++++++++++++++---------------
> drivers/net/virtio/virtio_rxtx_simple.c | 2 +-
> drivers/net/virtio/virtio_rxtx_simple.h | 2 +-
> 3 files changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
> index 854af399e..505283edd 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -30,6 +30,7 @@
> #include "virtio_pci.h"
> #include "virtqueue.h"
> #include "virtio_rxtx.h"
> +#include "virtio_rxtx_simple.h"
>
> #ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP
> #define VIRTIO_DUMP_PACKET(m, len) rte_pktmbuf_dump(stdout, m, len)
> @@ -446,25 +447,28 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx)
> &rxvq->fake_mbuf;
> }
>
> - while (!virtqueue_full(vq)) {
> - m = rte_mbuf_raw_alloc(rxvq->mpool);
> - if (m == NULL)
> - break;
> + if (hw->use_simple_rx) {
> + while (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> + virtio_rxq_rearm_vec(rxvq);
> + nbufs += RTE_VIRTIO_VPMD_RX_REARM_THRESH;
> + }
> + } else {
> + while (!virtqueue_full(vq)) {
> + m = rte_mbuf_raw_alloc(rxvq->mpool);
> + if (m == NULL)
> + break;
>
> - /* Enqueue allocated buffers */
> - if (hw->use_simple_rx)
> - error = virtqueue_enqueue_recv_refill_simple(vq, m);
> - else
It looks that virtqueue_enqueue_recv_refill_simple() is not used anymore.
We may want to remove it.
It means this patch also fixes the issue related to the patch I've just
submitted [1]. To ease backport process, I think the patch [1] is still
relevant because it fixes an older commit.
[1] http://dpdk.org/dev/patchwork/patch/35130/
> + /* Enqueue allocated buffers */
> error = virtqueue_enqueue_recv_refill(vq, m);
> -
> - if (error) {
> - rte_pktmbuf_free(m);
> - break;
> + if (error) {
> + rte_pktmbuf_free(m);
> + break;
> + }
> + nbufs++;
> }
> - nbufs++;
> - }
>
> - vq_update_avail_idx(vq);
> + vq_update_avail_idx(vq);
> + }
>
> PMD_INIT_LOG(DEBUG, "Allocated %d bufs", nbufs);
>
> virtio_rxq_vec_setup(rxvq);
Another thing seen by Tiwei: virtio_rxq_vec_setup() should be called
before virtio_rxq_rearm_vec() because it initializes the mbuf
initializer.
Thanks,
Olivier
next prev parent reply other threads:[~2018-02-12 13:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-09 14:26 [dpdk-stable] [PATCH 0/2] Vhost & Virtio fixes for -rc4 Maxime Coquelin
2018-02-09 14:26 ` [dpdk-stable] [PATCH 1/2] virtio: fix resuming traffic with rx vector path Maxime Coquelin
2018-02-11 8:02 ` Yao, Lei A
2018-02-12 13:18 ` Olivier Matz [this message]
2018-02-09 14:26 ` [dpdk-stable] [PATCH 2/2] vhost: don't take access_lock on VHOST_USER_RESET_OWNER Maxime Coquelin
2018-02-12 9:40 ` Tiwei Bie
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=20180212131827.ko5crddn2haihzac@platinum \
--to=olivier.matz@6wind.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=lei.a.yao@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=qian.q.xu@intel.com \
--cc=stable@dpdk.org \
--cc=tiwei.bie@intel.com \
--cc=victork@redhat.com \
--cc=yliu@fridaylinux.org \
--cc=zhihong.wang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).