All of lore.kernel.org
 help / color / mirror / Atom feed
From: gowrishankar muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH] kni: fix unit test segfault
Date: Thu, 4 May 2017 10:53:56 +0530	[thread overview]
Message-ID: <688b9c6b-ecc8-49fd-d6de-ecc46a728f75@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170503161037.3763-1-ferruh.yigit@intel.com>

Hi Ferruh,
Even w/o this patch, I mostly find mbufs returned by rte_kni_rx_burst() 
always 0
(or sometimes 1) where as more than 32000 mbufs approx created in 
ingress side
for this test.

   dpdk/test/test $ ./test -l 0,1,2 --socket-mem 1024

Am I missing something required for this unit test ?.

Thanks,
Gowrishankar

On Wednesday 03 May 2017 09:40 PM, Ferruh Yigit wrote:
> To clean alloc_q, which has physicall addresses of the mbufs, kni lib
> free the pkt_mempool, but this leads a crash in kni unit test.
>
> KNI library shouldn't free the pkt_mempool.
>
> Implementation updated to find the mbufs in the alloc_q and return them
> back to mempool.
>
> Fixes: 8eba5ebd1811 ("kni: fix possible memory leak")
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>   lib/librte_kni/rte_kni.c | 34 ++++++++++++++++++++++------------
>   1 file changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
> index 52fcd4b..c3f9208 100644
> --- a/lib/librte_kni/rte_kni.c
> +++ b/lib/librte_kni/rte_kni.c
> @@ -451,17 +451,35 @@ kni_free_fifo(struct rte_kni_fifo *fifo)
>   	} while (ret);
>   }
>
> +static void *
> +va2pa(struct rte_mbuf *m)
> +{
> +	return (void *)((unsigned long)m -
> +			((unsigned long)m->buf_addr -
> +			 (unsigned long)m->buf_physaddr));
> +}
> +
>   static void
> -kni_free_fifo_phy(struct rte_mempool *pktmbuf_pool, struct rte_kni_fifo *fifo)
> +obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj,
> +		unsigned obj_idx __rte_unused)
> +{
> +	struct rte_mbuf *m = obj;
> +	void *mbuf_phys = opaque;
> +
> +	if (va2pa(m) == mbuf_phys)
> +		rte_pktmbuf_free(m);
> +}
> +
> +static void
> +kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo)
>   {
>   	void *mbuf_phys;
>   	int ret;
>
> -	rte_mempool_free(pktmbuf_pool);
> -
> -	/* All mbufs alredy freed with rte_mempoll_free, just free the fifo */
>   	do {
>   		ret = kni_fifo_get(fifo, &mbuf_phys, 1);
> +		if (ret)
> +			rte_mempool_obj_iter(mp, obj_free, mbuf_phys);
>   	} while (ret);
>   }
>
> @@ -557,14 +575,6 @@ rte_kni_handle_request(struct rte_kni *kni)
>   	return 0;
>   }
>
> -static void *
> -va2pa(struct rte_mbuf *m)
> -{
> -	return (void *)((unsigned long)m -
> -			((unsigned long)m->buf_addr -
> -			 (unsigned long)m->buf_physaddr));
> -}
> -
>   unsigned
>   rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num)
>   {

  reply	other threads:[~2017-05-04  5:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 16:10 [PATCH] kni: fix unit test segfault Ferruh Yigit
2017-05-04  5:23 ` gowrishankar muthukrishnan [this message]
2017-05-04 14:22   ` Ferruh Yigit
2017-05-05 13:55 ` 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=688b9c6b-ecc8-49fd-d6de-ecc46a728f75@linux.vnet.ibm.com \
    --to=gowrishankar.m@linux.vnet.ibm.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.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 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.