From: bugzilla@dpdk.org
To: dev@dpdk.org
Subject: [Bug 882] ixgbe dirver may resue some unreleased mbufs
Date: Fri, 12 Nov 2021 16:20:09 +0000 [thread overview]
Message-ID: <bug-882-3@http.bugs.dpdk.org/> (raw)
https://bugs.dpdk.org/show_bug.cgi?id=882
Bug ID: 882
Summary: ixgbe dirver may resue some unreleased mbufs
Product: DPDK
Version: 20.11
Hardware: x86
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: ethdev
Assignee: dev@dpdk.org
Reporter: zhengbin.89740@bytedance.com
Target Milestone: ---
Created attachment 174
--> https://bugs.dpdk.org/attachment.cgi?id=174&action=edit
this demo can reproduce this bug
file: drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c:334
func: _recv_raw_pkts_vec()
This bug will appear when the following conditions are met:
1. arg `nb_pkts` is greater than the `RTE_IXGBE_RXQ_REARM_THRESH`
2. the application holds mbuf instead of releasing it immediately
On `_recv_raw_pkts_vec()`, if `nb_pkts` is greater than the
`RTE_IXGBE_RXQ_REARM_THRESH` and `rx_tail` wrap back to zero,
in this case `rx_tail` may advance faster than `rxrearm_start`, which may cause
some unreleased mbufs be reused.
e.g.
nb_rx_desc: 1024 RDH: 972 RDT: 991 rxrearm_nb: 991 rxrearm_start: 992 rx_tail:
959
nb_rx_desc: 1024 RDH: 1004 RDT: 1023 rxrearm_nb: 991 rxrearm_start: 0 rx_tail:
991
nb_rx_desc: 1024 RDH: 12 RDT: 31 rxrearm_nb: 991 rxrearm_start: 32 rx_tail:
1023
nb_rx_desc: 1024 RDH: 31 RDT: 63 rxrearm_nb: 960 rxrearm_start: 64 rx_tail: 0
nb_rx_desc: 1024 RDH: 95 RDT: 95 rxrearm_nb: 1016 rxrearm_start: 96 rx_tail: 88
nb_rx_desc: 1024 RDH: 95 RDT: 127 rxrearm_nb: 991 rxrearm_start: 128 rx_tail:
95
...
nb_rx_desc: 1024 RDH: 908 RDT: 927 rxrearm_nb: 991 rxrearm_start: 928 rx_tail:
895
nb_rx_desc: 1024 RDH: 940 RDT: 959 rxrearm_nb: 991 rxrearm_start: 960 rx_tail:
927
nb_rx_desc: 1024 RDH: 980 RDT: 991 rxrearm_nb: 991 rxrearm_start: 992 rx_tail:
959
nb_rx_desc: 1024 RDH: 991 RDT: 991 rxrearm_nb: 1026 rxrearm_start: 992 rx_tail:
994
when `rx_tail` catches up with `rxrearm_start`, 2(994 - 992) unreleased mbuf be
reused!
The simplest solution is to limit the size of `nb_pkts` to no more than
`RTE_IXGBE_RXQ_REARM_THRESH`.
However, this method may affect the packet receiving speed of the application.
Just like it.
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
index 1eed949495..648ad9eadd 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
@@ -364,6 +364,12 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct
rte_mbuf **rx_pkts,
uint8_t vlan_flags;
uint16_t udp_p_flag = 0; /* Rx Descriptor UDP header present */
+ /*
+ * If nb_pkts is greater than the threshold,
+ * it may cause some unreleased mbuf be reused.
+ */
+ nb_pkts = RTE_MIN(nb_pkts, RTE_IXGBE_RXQ_REARM_THRESH);
+
/* nb_pkts has to be floor-aligned to RTE_IXGBE_DESCS_PER_LOOP */
nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_IXGBE_DESCS_PER_LOOP);
The attachment has a corresponding demo to reproduce this bug.
Thanks!
--
You are receiving this mail because:
You are the assignee for the bug.
next reply other threads:[~2021-11-12 16:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 16:20 bugzilla [this message]
2022-02-02 14:45 ` [Bug 882] ixgbe dirver may cause some unreleased mbufs be reused by application bugzilla
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=bug-882-3@http.bugs.dpdk.org/ \
--to=bugzilla@dpdk.org \
--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).