From: Adrien Mazarguil <adrien.mazarguil-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] app: fix refcnt in mbuf allocation
Date: Mon, 6 May 2013 18:13:34 +0200 [thread overview]
Message-ID: <20130506161334.GO12221@6wind.com> (raw)
In-Reply-To: <1367856001-25036-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
On Mon, May 06, 2013 at 06:00:01PM +0200, Thomas Monjalon wrote:
> From: Dongsu Han <dongsuh-ETDLCGt7PQU3uPMLIKxrzw@public.gmane.org>
>
> 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.
> The dedicated function is rte_pktmbuf_alloc() but it is much slower because
> it does unnecessary initializations in rte_pktmbuf_reset().
> By using the internal API __rte_mbuf_raw_alloc(), refcnt is correctly handled
> without adding too much overload.
>
> Signed-off-by: Dongsu Han <dongsuh-ETDLCGt7PQU3uPMLIKxrzw@public.gmane.org>
> Signed-off-by: Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
> ---
> app/test-pmd/txonly.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
> index d7c8c31..e7c9a1a 100644
> --- a/app/test-pmd/txonly.c
> +++ b/app/test-pmd/txonly.c
> @@ -93,11 +93,8 @@ 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;
> + m = __rte_mbuf_raw_alloc(mp);
> __rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1);
> return m;
> }
> --
> 1.7.10.4
Looks good.
Acked-by: Adrien Mazarguil <adrien.mazarguil-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
--
Adrien Mazarguil
6WIND
next prev parent reply other threads:[~2013-05-06 16:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-02 14:24 suggested patch: testpmd txonly mbuf_alloc does not increment refcnt Han, Dongsu
[not found] ` <CAAYH+dW3RenDv9=dn0Mtdubp0443OWqAqPYfHjGKfQcjQHNgxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-06 12:47 ` [PATCH] app: fix refcnt in mbuf allocation Thomas Monjalon
[not found] ` <1367844470-15346-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-05-06 13:28 ` Han, Dongsu
[not found] ` <CAAYH+dX-n2vbZh8P-by0Vk-sPn-E+ZSTMx1HJnKiHXgh-5G+wQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-06 13:56 ` Adrien Mazarguil
[not found] ` <20130506135616.GN12221-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-05-06 15:47 ` Han, Dongsu
[not found] ` <CAAYH+dWnQ_eP-evFv2ABL8s==Oq1VB0secy1Dj4ZH9BA6ac9wA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-06 16:13 ` Thomas Monjalon
2013-05-06 16:00 ` [PATCH] " Thomas Monjalon
[not found] ` <1367856001-25036-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-05-06 16:13 ` Adrien Mazarguil [this message]
[not found] ` <20130506161334.GO12221-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
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=20130506161334.GO12221@6wind.com \
--to=adrien.mazarguil-pdr9zngts4eavxtiumwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.