From: "Han, Dongsu" <dongsuh@cs.cmu.edu>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] app: fix refcnt in mbuf allocation
Date: Mon, 6 May 2013 09:28:33 -0400 [thread overview]
Message-ID: <CAAYH+dX-n2vbZh8P-by0Vk-sPn-E+ZSTMx1HJnKiHXgh-5G+wQ@mail.gmail.com> (raw)
In-Reply-To: <1367844470-15346-1-git-send-email-thomas.monjalon@6wind.com>
[-- Attachment #1: Type: text/plain, Size: 3121 bytes --]
Sounds good. With the two bug fixes I submitted txonly now runs perfectly.
Thanks!
-Dongsu
On May 6, 2013 8:47 AM, "Thomas Monjalon" <thomas.monjalon@6wind.com> wrote:
> Hi Dongsu Han,
>
> I think your fix is right.
> I've just removed tx_mbuf_alloc() and directly called rte_pktmbuf_alloc()
> instead.
> Is it OK for you ?
> Could you also review this (modified) description ?
>
> Thank you
>
> ---
>
> From: Dongsu Han <dongsuh at cs.cmu.edu>
>
> test-pmd txonly leaks mbuf from the pool.
> The function tx_mbuf_alloc() does not change the refcnt
> and the refcnt is 0 when it is first allocated.
> However, rte_pktmbuf_free_seg called by the driver's xmit code decrements
> reference count to -1. So mbuf never goes back to the pool.
> As a result, txonly can't send packets after it exhausts the mempool.
>
> The function tx_mbuf_alloc() was getting mbuf directly from mempool and so
> was bypassing mbuf API.
> By using the right API, refcnt is correctly handled among other
> initializations.
>
> Signed-off-by: Dongsu Han <dongsuh@cs.cmu.edu>
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> ---
> app/test-pmd/txonly.c | 17 ++---------------
> 1 file changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
> index d7c8c31..53f7138 100644
> --- a/app/test-pmd/txonly.c
> +++ b/app/test-pmd/txonly.c
> @@ -89,19 +89,6 @@
> static struct ipv4_hdr pkt_ip_hdr; /**< IP header of transmitted
> packets. */
> static struct udp_hdr pkt_udp_hdr; /**< UDP header of transmitted
> packets. */
>
> -static inline struct rte_mbuf *
> -tx_mbuf_alloc(struct rte_mempool *mp)
> -{
> - struct rte_mbuf *m;
> - void *mb;
> -
> - if (rte_mempool_get(mp, &mb) < 0)
> - return NULL;
> - m = (struct rte_mbuf *)mb;
> - __rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1);
> - return m;
> -}
> -
> static void
> copy_buf_to_pkt_segs(void* buf, unsigned len, struct rte_mbuf *pkt,
> unsigned offset)
> @@ -223,7 +210,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
> vlan_tci = ports[fs->tx_port].tx_vlan_id;
> ol_flags = ports[fs->tx_port].tx_ol_flags;
> for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
> - pkt = tx_mbuf_alloc(mbp);
> + pkt = rte_pktmbuf_alloc(mbp);
> if (pkt == NULL) {
> nomore_mbuf:
> if (nb_pkt == 0)
> @@ -233,7 +220,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
> pkt->pkt.data_len = tx_pkt_seg_lengths[0];
> pkt_seg = pkt;
> for (i = 1; i < tx_pkt_nb_segs; i++) {
> - pkt_seg->pkt.next = tx_mbuf_alloc(mbp);
> + pkt_seg->pkt.next = rte_pktmbuf_alloc(mbp);
> if (pkt_seg->pkt.next == NULL) {
> pkt->pkt.nb_segs = i;
> rte_pktmbuf_free(pkt);
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev@dpdk.org
> http://dpdk.org/ml/listinfo/dev
>
[-- Attachment #2: Type: text/html, Size: 3927 bytes --]
next prev parent reply other threads:[~2013-05-06 13:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-02 14:24 [dpdk-dev] suggested patch: testpmd txonly mbuf_alloc does not increment refcnt Han, Dongsu
2013-05-06 12:47 ` [dpdk-dev] [PATCH] app: fix refcnt in mbuf allocation Thomas Monjalon
2013-05-06 13:28 ` Han, Dongsu [this message]
2013-05-06 13:56 ` Adrien Mazarguil
2013-05-06 15:47 ` Han, Dongsu
2013-05-06 16:13 ` [dpdk-dev] " Thomas Monjalon
2013-05-06 16:00 ` [dpdk-dev] [PATCH] " Thomas Monjalon
2013-05-06 16:13 ` Adrien Mazarguil
2013-05-06 16:33 ` Thomas Monjalon
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=CAAYH+dX-n2vbZh8P-by0Vk-sPn-E+ZSTMx1HJnKiHXgh-5G+wQ@mail.gmail.com \
--to=dongsuh@cs.cmu.edu \
--cc=dev@dpdk.org \
--cc=thomas.monjalon@6wind.com \
/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).