From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68BF1A0093 for ; Tue, 19 May 2020 15:11:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5DF0A1D6A4; Tue, 19 May 2020 15:11:08 +0200 (CEST) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id E994C1D6FC for ; Tue, 19 May 2020 15:11:05 +0200 (CEST) Received: by mail-wm1-f66.google.com with SMTP id z4so3008024wmi.2 for ; Tue, 19 May 2020 06:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g0np12mlON6FmWQDHg3hzJeqCBB81yQbdXY66jEkCFM=; b=iq4uZRjKXakrmAHgCiXFu3GZNJ9iNcWIlVWPXwwUwOpwgOYRaDE2QiyQ/XvyuAzW1a YsF+9hcjMzBUzJDuLixFIpxaEaUe2uP/+bXHDZm3VmdbhZboACNmj+fOBPKNOl7M6iOw eV/qTjKtgsAENsVbJPtP84j//fSYY35XmvPGtRbTeGv+B+ZqtOQVdIj4MpSHIKpludN8 dIBsJd+jH+yA+mXuU9T3084XlaTVVZHb9wo3lezr2itvgJONxn554H8pOU1U1qmYc1ur Z1b1vEhyDg4j6bAstZPnow6fOeH+ZZSLdAPU4U23cVfDeN7cb7q9rsNWxyZflHAQXtfd J1uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g0np12mlON6FmWQDHg3hzJeqCBB81yQbdXY66jEkCFM=; b=rzx9Bp7c7m0Qo2Ox21JDjJoznoMOQJPvDGwrj8cM9XbPyo8quHCvHjJp/9Rd4NyYAx ibN78jMDywJyQVgAPh2Ie0oqybjTLA6iVGdU0YZ8bZ1aokq86Qs58tUSeqWAF2fs2FEW IJwSK2/Ph+nUcnCujNL8sKMgMg1oZG8CSinG6TtKw0kcXLkHRw1XQVSG9mPMgFD+WxaA k2Oot1k9XOjA5/c3qBbG4QIGL5Gp8Ydt3tN/Uj9wIibyPRjzda/gPhdMcqitJH8xclFo +FsLsuxtzezc/lZ+I+4GZVM1tjsMSiN95yRYI47hHbf9PegwiLwijui0o/+2SP/xOnOG dMAg== X-Gm-Message-State: AOAM531+94uAKcaOSa8OCzblf0zcytYnr7Zb25G5iZFjOesRTJlFJkuX DHx4IfPij8tdQWk9kUVyl69Umf3PVLJSU1ex X-Google-Smtp-Source: ABdhPJzT1qOhfoLcEeWtu5DOsNheZaKbbm6zSRw4VpOp0QZChl66OeptWsTVX4UmX3hkSwEfZEpK0A== X-Received: by 2002:a1c:9d50:: with SMTP id g77mr5546381wme.56.1589893865675; Tue, 19 May 2020 06:11:05 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id s11sm20507748wrp.79.2020.05.19.06.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:11:05 -0700 (PDT) From: luca.boccassi@gmail.com To: Marvin Liu Cc: Maxime Coquelin , dpdk stable Date: Tue, 19 May 2020 14:03:55 +0100 Message-Id: <20200519130549.112823-100-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'vhost: fix shadowed descriptors not flushed' has been queued to stable release 19.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 74a51ef091b2366b7c7751594da270eaa34187d6 Mon Sep 17 00:00:00 2001 From: Marvin Liu Date: Fri, 17 Apr 2020 09:16:09 +0800 Subject: [PATCH] vhost: fix shadowed descriptors not flushed [ upstream commit c7de6f9be56793a681964b2ff3ee234e9d1d551a ] When ring size or enqueue packets not aligned with batch number, it is possible that descs update still kept in shadowed used structure when batched enqueue. Fix this issue by flushing remained shadowed used descs before batch flush. Fixes: f41516c309d7 ("vhost: flush batched enqueue descs directly") Signed-off-by: Marvin Liu Reviewed-by: Maxime Coquelin --- lib/librte_vhost/virtio_net.c | 65 +++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 4c7ae29a36..22dcdf72bd 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -43,6 +43,36 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring) return (is_tx ^ (idx & 1)) == 0 && idx < nr_vring; } +static inline void +do_data_copy_enqueue(struct virtio_net *dev, struct vhost_virtqueue *vq) +{ + struct batch_copy_elem *elem = vq->batch_copy_elems; + uint16_t count = vq->batch_copy_nb_elems; + int i; + + for (i = 0; i < count; i++) { + rte_memcpy(elem[i].dst, elem[i].src, elem[i].len); + vhost_log_cache_write_iova(dev, vq, elem[i].log_addr, + elem[i].len); + PRINT_PACKET(dev, (uintptr_t)elem[i].dst, elem[i].len, 0); + } + + vq->batch_copy_nb_elems = 0; +} + +static inline void +do_data_copy_dequeue(struct vhost_virtqueue *vq) +{ + struct batch_copy_elem *elem = vq->batch_copy_elems; + uint16_t count = vq->batch_copy_nb_elems; + int i; + + for (i = 0; i < count; i++) + rte_memcpy(elem[i].dst, elem[i].src, elem[i].len); + + vq->batch_copy_nb_elems = 0; +} + static __rte_always_inline void do_flush_shadow_used_ring_split(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -186,6 +216,11 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev, uint16_t i; uint16_t flags; + if (vq->shadow_used_idx) { + do_data_copy_enqueue(dev, vq); + vhost_flush_enqueue_shadow_packed(dev, vq); + } + flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq->used_wrap_counter); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { @@ -325,36 +360,6 @@ vhost_shadow_dequeue_single_packed_inorder(struct vhost_virtqueue *vq, vq_inc_last_used_packed(vq, count); } -static inline void -do_data_copy_enqueue(struct virtio_net *dev, struct vhost_virtqueue *vq) -{ - struct batch_copy_elem *elem = vq->batch_copy_elems; - uint16_t count = vq->batch_copy_nb_elems; - int i; - - for (i = 0; i < count; i++) { - rte_memcpy(elem[i].dst, elem[i].src, elem[i].len); - vhost_log_cache_write_iova(dev, vq, elem[i].log_addr, - elem[i].len); - PRINT_PACKET(dev, (uintptr_t)elem[i].dst, elem[i].len, 0); - } - - vq->batch_copy_nb_elems = 0; -} - -static inline void -do_data_copy_dequeue(struct vhost_virtqueue *vq) -{ - struct batch_copy_elem *elem = vq->batch_copy_elems; - uint16_t count = vq->batch_copy_nb_elems; - int i; - - for (i = 0; i < count; i++) - rte_memcpy(elem[i].dst, elem[i].src, elem[i].len); - - vq->batch_copy_nb_elems = 0; -} - static __rte_always_inline void vhost_shadow_enqueue_single_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:48.535325259 +0100 +++ 0100-vhost-fix-shadowed-descriptors-not-flushed.patch 2020-05-19 14:04:44.312650112 +0100 @@ -1,15 +1,16 @@ -From c7de6f9be56793a681964b2ff3ee234e9d1d551a Mon Sep 17 00:00:00 2001 +From 74a51ef091b2366b7c7751594da270eaa34187d6 Mon Sep 17 00:00:00 2001 From: Marvin Liu Date: Fri, 17 Apr 2020 09:16:09 +0800 Subject: [PATCH] vhost: fix shadowed descriptors not flushed +[ upstream commit c7de6f9be56793a681964b2ff3ee234e9d1d551a ] + When ring size or enqueue packets not aligned with batch number, it is possible that descs update still kept in shadowed used structure when batched enqueue. Fix this issue by flushing remained shadowed used descs before batch flush. Fixes: f41516c309d7 ("vhost: flush batched enqueue descs directly") -Cc: stable@dpdk.org Signed-off-by: Marvin Liu Reviewed-by: Maxime Coquelin @@ -18,7 +19,7 @@ 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index 4a75319432..1fc30c6819 100644 +index 4c7ae29a36..22dcdf72bd 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -43,6 +43,36 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring)