From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 3A7B77CC9 for ; Thu, 4 May 2017 16:22:21 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 04 May 2017 07:22:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,287,1491289200"; d="scan'208";a="95541631" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.81]) ([10.237.220.81]) by orsmga005.jf.intel.com with ESMTP; 04 May 2017 07:22:20 -0700 To: gowrishankar muthukrishnan Cc: dev@dpdk.org References: <20170503161037.3763-1-ferruh.yigit@intel.com> <688b9c6b-ecc8-49fd-d6de-ecc46a728f75@linux.vnet.ibm.com> From: Ferruh Yigit Message-ID: <328d773b-6e34-0742-1ccc-aab9770244a6@intel.com> Date: Thu, 4 May 2017 15:22:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <688b9c6b-ecc8-49fd-d6de-ecc46a728f75@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] kni: fix unit test segfault X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2017 14:22:22 -0000 On 5/4/2017 6:23 AM, gowrishankar muthukrishnan wrote: > 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 ?. Hi Gowrishankar, KNI module should be inserted with one of the loopback options [1] for the unit test. [1] There are two loopback options supported, both loopbacks Rx/Tx path in kernel side, this is easy way to test KNI. options are: lo_mode_fifo and lo_mode_fifo_skb usage: insmod build/kmod/rte_kni.ko lo_mode=lo_mode_fifo or insmod build/kmod/rte_kni.ko lo_mode=lo_mode_fifo_skb Regards, ferruh > > 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 >> --- >> 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) >> { > >