[dpdk-stable] patch 'kni: fix FIFO synchronization' has been queued to stable release 18.08.1

Kevin Traynor ktraynor at redhat.com
Thu Nov 22 17:49:29 CET 2018


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 <phil.yang at arm.com>
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 <phil.yang at arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
Reviewed-by: Gavin Hu <gavin.hu at arm.com>
Reviewed-by: Ola Liljedahl <ola.liljedahl at arm.com>
Reviewed-by: Jerin Jacob <jerin.jacob at caviumnetworks.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 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 <phil.yang at arm.com>
 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 at dpdk.org
 
 Signed-off-by: Phil Yang <phil.yang at arm.com>
 Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>


More information about the stable mailing list