From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 7236E1B488 for ; Thu, 22 Nov 2018 17:52:34 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE27B30001EA; Thu, 22 Nov 2018 16:52:33 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 487D060FD9; Thu, 22 Nov 2018 16:52:30 +0000 (UTC) From: Kevin Traynor To: Phil Yang Cc: Honnappa Nagarahalli , Gavin Hu , Ola Liljedahl , Jerin Jacob , Ferruh Yigit , dpdk stable Date: Thu, 22 Nov 2018 16:49:29 +0000 Message-Id: <20181122164957.13003-37-ktraynor@redhat.com> In-Reply-To: <20181122164957.13003-1-ktraynor@redhat.com> References: <20181122164957.13003-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 22 Nov 2018 16:52:33 +0000 (UTC) Subject: [dpdk-stable] patch 'kni: fix FIFO synchronization' has been queued to stable release 18.08.1 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: , X-List-Received-Date: Thu, 22 Nov 2018 16:52:34 -0000 Hi, FYI, your patch has been queued to stable release 18.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/28/18. 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. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From 765313ff6695245477370492511ead09e20a2f6e Mon Sep 17 00:00:00 2001 From: Phil Yang Date: Mon, 8 Oct 2018 17:11:44 +0800 Subject: [PATCH] kni: fix FIFO synchronization [ upstream commit 0b05abe7bf9a46915bc1823753fc29c0a7b99ed1 ] With existing code in kni_fifo_put, rx_q values are not being updated before updating fifo_write. While reading rx_q in kni_net_rx_normal, This is causing the sync issue on other core. The same situation happens in kni_fifo_get as well. So syncing the values by adding memory barriers to make sure the values being synced before updating fifo_write and fifo_read. Fixes: 3fc5ca2f6352 ("kni: initial import") Signed-off-by: Phil Yang Reviewed-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu Reviewed-by: Ola Liljedahl Reviewed-by: Jerin Jacob Reviewed-by: Ferruh Yigit --- lib/librte_kni/rte_kni_fifo.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/librte_kni/rte_kni_fifo.h b/lib/librte_kni/rte_kni_fifo.h index ac26a8c0b..70ac14eec 100644 --- a/lib/librte_kni/rte_kni_fifo.h +++ b/lib/librte_kni/rte_kni_fifo.h @@ -29,6 +29,7 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num) unsigned i = 0; unsigned fifo_write = fifo->write; - unsigned fifo_read = fifo->read; unsigned new_write = fifo_write; + rte_smp_rmb(); + unsigned fifo_read = fifo->read; for (i = 0; i < num; i++) { @@ -40,4 +41,5 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num) fifo_write = new_write; } + rte_smp_wmb(); fifo->write = fifo_write; return i; @@ -52,5 +54,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num) unsigned i = 0; unsigned new_read = fifo->read; + rte_smp_rmb(); unsigned fifo_write = fifo->write; + for (i = 0; i < num; i++) { if (new_read == fifo_write) @@ -60,4 +64,5 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num) new_read = (new_read + 1) & (fifo->len - 1); } + rte_smp_rmb(); fifo->read = new_read; return i; @@ -70,4 +75,7 @@ static inline uint32_t kni_fifo_count(struct rte_kni_fifo *fifo) { - return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1); + unsigned fifo_write = fifo->write; + rte_smp_rmb(); + unsigned fifo_read = fifo->read; + return (fifo->len + fifo_write - fifo_read) & (fifo->len - 1); } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-22 16:47:33.221649524 +0000 +++ 0037-kni-fix-FIFO-synchronization.patch 2018-11-22 16:47:32.000000000 +0000 @@ -1,8 +1,10 @@ -From 0b05abe7bf9a46915bc1823753fc29c0a7b99ed1 Mon Sep 17 00:00:00 2001 +From 765313ff6695245477370492511ead09e20a2f6e Mon Sep 17 00:00:00 2001 From: Phil Yang Date: Mon, 8 Oct 2018 17:11:44 +0800 Subject: [PATCH] kni: fix FIFO synchronization +[ upstream commit 0b05abe7bf9a46915bc1823753fc29c0a7b99ed1 ] + With existing code in kni_fifo_put, rx_q values are not being updated before updating fifo_write. While reading rx_q in kni_net_rx_normal, This is causing the sync issue on other core. The same situation happens @@ -12,7 +14,6 @@ being synced before updating fifo_write and fifo_read. Fixes: 3fc5ca2f6352 ("kni: initial import") -Cc: stable@dpdk.org Signed-off-by: Phil Yang Reviewed-by: Honnappa Nagarahalli