patch 'kni: fix possible starvation when mbufs are exhausted' has been queued to stable release 20.11.8

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Mar 15 23:46:12 CET 2023


Hi,

FYI, your patch has been queued to stable release 20.11.8

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/17/23. 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.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/5f3b9397db0710432b49e2c9cd709a84ac2e7265

Thanks.

Luca Boccassi

---
>From 5f3b9397db0710432b49e2c9cd709a84ac2e7265 Mon Sep 17 00:00:00 2001
From: Yangchao Zhou <zhouyates at gmail.com>
Date: Fri, 30 Dec 2022 12:23:38 +0800
Subject: [PATCH] kni: fix possible starvation when mbufs are exhausted

[ upstream commit 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a ]

In some scenarios, mbufs returned by rte_kni_rx_burst are not freed
immediately. So kni_allocate_mbufs may be failed, but we don't know.

Even worse, when alloc_q is completely exhausted, kni_net_tx in
rte_kni.ko will drop all tx packets. kni_allocate_mbufs is never
called again, even if the mbufs are eventually freed.

In this patch, we try to allocate mbufs for alloc_q when it is empty.

According to historical experience, the performance bottleneck of KNI
is offen the usleep_range of kni thread in rte_kni.ko.
The check of kni_fifo_count is trivial and the cost should be acceptable.

Fixes: 3e12a98fe397 ("kni: optimize Rx burst")

Signed-off-by: Yangchao Zhou <zhouyates at gmail.com>
Acked-by: Ferruh Yigit <ferruh.yigit at amd.com>
---
 lib/librte_kni/rte_kni.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 17e4487306..f86a11d829 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -635,8 +635,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num)
 {
 	unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num);
 
-	/* If buffers removed, allocate mbufs and then put them into alloc_q */
-	if (ret)
+	/* If buffers removed or alloc_q is empty, allocate mbufs and then put them into alloc_q */
+	if (ret || (kni_fifo_count(kni->alloc_q) == 0))
 		kni_allocate_mbufs(kni);
 
 	return ret;
-- 
2.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-03-15 22:44:50.839061593 +0000
+++ 0021-kni-fix-possible-starvation-when-mbufs-are-exhausted.patch	2023-03-15 22:44:49.579850177 +0000
@@ -1 +1 @@
-From 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a Mon Sep 17 00:00:00 2001
+From 5f3b9397db0710432b49e2c9cd709a84ac2e7265 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a ]
+
@@ -20 +21,0 @@
-Cc: stable at dpdk.org
@@ -25 +26 @@
- lib/kni/rte_kni.c | 4 ++--
+ lib/librte_kni/rte_kni.c | 4 ++--
@@ -28,5 +29,5 @@
-diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
-index 8ab6c47153..bfa6a001ff 100644
---- a/lib/kni/rte_kni.c
-+++ b/lib/kni/rte_kni.c
-@@ -634,8 +634,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num)
+diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
+index 17e4487306..f86a11d829 100644
+--- a/lib/librte_kni/rte_kni.c
++++ b/lib/librte_kni/rte_kni.c
+@@ -635,8 +635,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num)


More information about the stable mailing list