From: ALeX Wang <ee07b291@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] possible kni bug and proposed fix
Date: Sat, 14 May 2016 21:48:11 -0700 [thread overview]
Message-ID: <CANmyKO6rKKCpZCD5aSTcSWBRKktX5Yrf+MF1Q4JUfa=mf2jkTQ@mail.gmail.com> (raw)
Hi,
When using the kni module to test my application inside
debian (virtualbox) VM (kernel version 4.4), I get the
"KNI: Out of memory"
from syslog every time I `tcpreply` packets through
the kni interface.
After checking source code, I saw that when I call
'rte_kni_rx_burst()', no matter how many packets
are actually retrieved, we always call 'kni_allocate_mbufs()'
and try allocate 'MAX_MBUF_BURST_NUM' more
mbufs... I fix the issue via using this patch below,
Could you confirm if this is an actual bug?
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index ea9baf4..5d7c1ce 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -129,6 +129,7 @@ struct rte_kni_memzone_pool {
static void kni_free_mbufs(struct rte_kni *kni);
static void kni_allocate_mbufs(struct rte_kni *kni);
+static void kni_allocate_n_mbufs(struct rte_kni *kni, int size);
static volatile int kni_fd = -1;
static struct rte_kni_memzone_pool kni_memzone_pool = {
@@ -556,7 +557,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf
**mbufs, unsigned num)
/* If buffers removed, allocate mbufs and then put them into
alloc_q */
if (ret)
- kni_allocate_mbufs(kni);
+ kni_allocate_n_mbufs(kni, (int)ret);
return ret;
}
@@ -577,6 +578,12 @@ kni_free_mbufs(struct rte_kni *kni)
static void
kni_allocate_mbufs(struct rte_kni *kni)
{
+ kni_allocate_n_mbufs(kni, MAX_MBUF_BURST_NUM);
+}
+
+static void
+kni_allocate_n_mbufs(struct rte_kni *kni, int size)
+{
int i, ret;
struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM];
@@ -595,13 +602,18 @@ kni_allocate_mbufs(struct rte_kni *kni)
RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
offsetof(struct rte_kni_mbuf, ol_flags));
+ if (size > MAX_MBUF_BURST_NUM) {
+ RTE_LOG(ERR, KNI, "Invalid mbufs size\n");
+ return;
+ }
+
/* Check if pktmbuf pool has been configured */
if (kni->pktmbuf_pool == NULL) {
RTE_LOG(ERR, KNI, "No valid mempool for allocating
mbufs\n");
return;
}
- for (i = 0; i < MAX_MBUF_BURST_NUM; i++) {
+ for (i = 0; i < size; i++) {
pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
if (unlikely(pkts[i] == NULL)) {
/* Out of memory */
Thanks,
--
Alex Wang,
next reply other threads:[~2016-05-15 4:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-15 4:48 ALeX Wang [this message]
2016-05-16 11:20 ` Ferruh Yigit
2016-05-16 15:31 ` ALeX Wang
2016-05-17 10:07 ` Ferruh Yigit
2016-05-17 17:09 ` ALeX Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANmyKO6rKKCpZCD5aSTcSWBRKktX5Yrf+MF1Q4JUfa=mf2jkTQ@mail.gmail.com' \
--to=ee07b291@gmail.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).