[dpdk-stable] patch 'kni: fix mbuf allocation for kernel side use' has been queued to stable release 20.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Jul 12 15:04:26 CEST 2021


Hi,

FYI, your patch has been queued to stable release 20.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 07/14/21. 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/172846607c0f9c19fc730e436788cbf94dedb1cb

Thanks.

Luca Boccassi

---
>From 172846607c0f9c19fc730e436788cbf94dedb1cb Mon Sep 17 00:00:00 2001
From: Yunjian Wang <wangyunjian at huawei.com>
Date: Tue, 22 Jun 2021 20:44:29 +0800
Subject: [PATCH] kni: fix mbuf allocation for kernel side use

[ upstream commit 0db3d5551abe94bb8a7030c1b90496b290ddb7f4 ]

In kni_allocate_mbufs(), we alloc mbuf for alloc_q as this code.
allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \
		& (MAX_MBUF_BURST_NUM - 1);
The value of allocq_free maybe zero, for example :
The ring size is 1024. After init, write = read = 0. Then we fill
kni->alloc_q to full. At this time, write = 1023, read = 0.

Then the kernel send 32 packets to userspace. At this time, write
= 1023, read = 32. And then the userspace receive this 32 packets.
Then fill the kni->alloc_q, (32 - 1023 - 1) & 31 = 0, fill nothing.
...
Then the kernel send 32 packets to userspace. At this time, write
= 1023, read = 992. And then the userspace receive this 32 packets.
Then fill the kni->alloc_q, (992 - 1023 - 1) & 31 = 0, fill nothing.

Then the kernel send 32 packets to userspace. The kni->alloc_q only
has 31 mbufs and will drop one packet.

Absolutely, this is a special scene. Normally, it will fill some
mbufs everytime, but may not enough for the kernel to use.

In this patch, we always keep the kni->alloc_q to full for the kernel
to use.

Fixes: 49da4e82cf94 ("kni: allocate no more mbuf than empty slots in queue")

Signed-off-by: Cheng Liu <liucheng11 at huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit at intel.com>
Acked-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
---
 lib/librte_kni/rte_kni.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 9dae6a8d7c..eb24b0d0ae 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -677,8 +677,9 @@ kni_allocate_mbufs(struct rte_kni *kni)
 		return;
 	}
 
-	allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1)
-			& (MAX_MBUF_BURST_NUM - 1);
+	allocq_free = kni_fifo_free_count(kni->alloc_q);
+	allocq_free = (allocq_free > MAX_MBUF_BURST_NUM) ?
+		MAX_MBUF_BURST_NUM : allocq_free;
 	for (i = 0; i < allocq_free; i++) {
 		pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
 		if (unlikely(pkts[i] == NULL)) {
-- 
2.30.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-07-12 13:41:38.351906477 +0100
+++ 0031-kni-fix-mbuf-allocation-for-kernel-side-use.patch	2021-07-12 13:41:36.294118528 +0100
@@ -1 +1 @@
-From 0db3d5551abe94bb8a7030c1b90496b290ddb7f4 Mon Sep 17 00:00:00 2001
+From 172846607c0f9c19fc730e436788cbf94dedb1cb Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 0db3d5551abe94bb8a7030c1b90496b290ddb7f4 ]
+
@@ -31 +32,0 @@
-Cc: stable at dpdk.org
@@ -38 +39 @@
- lib/kni/rte_kni.c | 5 +++--
+ lib/librte_kni/rte_kni.c | 5 +++--
@@ -41 +42 @@
-diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
+diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
@@ -43,2 +44,2 @@
---- a/lib/kni/rte_kni.c
-+++ b/lib/kni/rte_kni.c
+--- a/lib/librte_kni/rte_kni.c
++++ b/lib/librte_kni/rte_kni.c


More information about the stable mailing list