From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by dpdk.org (Postfix) with ESMTP id DC3752C60 for ; Thu, 4 May 2017 07:24:53 +0200 (CEST) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v445ORLV055998 for ; Thu, 4 May 2017 01:24:53 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a7rcwkqq6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 04 May 2017 01:24:52 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 May 2017 15:24:48 +1000 Received: from d23relay06.au.ibm.com (202.81.31.225) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 4 May 2017 15:24:46 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v445Ob1f62062666 for ; Thu, 4 May 2017 15:24:45 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v445OCir001716 for ; Thu, 4 May 2017 15:24:12 +1000 Received: from [9.109.223.120] ([9.109.223.120]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v445OBEo001033; Thu, 4 May 2017 15:24:11 +1000 To: Ferruh Yigit References: <20170503161037.3763-1-ferruh.yigit@intel.com> Cc: dev@dpdk.org From: gowrishankar muthukrishnan Date: Thu, 4 May 2017 10:53:56 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170503161037.3763-1-ferruh.yigit@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17050405-1617-0000-0000-000001C9A62E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050405-1618-0000-0000-0000480A7F56 Message-Id: <688b9c6b-ecc8-49fd-d6de-ecc46a728f75@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-04_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705040091 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 05:24:54 -0000 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 > --- > 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) > {