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

Xueming Li xuemingl at nvidia.com
Sun Apr 9 17:24:15 CEST 2023


Hi,

FYI, your patch has been queued to stable release 22.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 04/11/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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/09b626852e51df9bb11dc300e9aaa9b2a49ef77a

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 09b626852e51df9bb11dc300e9aaa9b2a49ef77a 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
Cc: Xueming Li <xuemingl at nvidia.com>

[ 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/kni/rte_kni.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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)
 {
 	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.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-04-09 21:45:40.495984800 +0800
+++ 0067-kni-fix-possible-starvation-when-mbufs-are-exhausted.patch	2023-04-09 21:45:38.679042200 +0800
@@ -1 +1 @@
-From 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a Mon Sep 17 00:00:00 2001
+From 09b626852e51df9bb11dc300e9aaa9b2a49ef77a Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a ]
@@ -20 +22,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list