From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2lp0209.outbound.protection.outlook.com [207.46.163.209]) by dpdk.org (Postfix) with ESMTP id 746D0594D for ; Wed, 23 Jul 2014 08:43:59 +0200 (CEST) Received: from BY2PR03CA072.namprd03.prod.outlook.com (10.141.249.45) by BN1PR0301MB0691.namprd03.prod.outlook.com (25.160.171.28) with Microsoft SMTP Server (TLS) id 15.0.990.7; Wed, 23 Jul 2014 06:45:20 +0000 Received: from BN1BFFO11FD014.protection.gbl (2a01:111:f400:7c10::1:141) by BY2PR03CA072.outlook.office365.com (2a01:111:e400:2c5d::45) with Microsoft SMTP Server (TLS) id 15.0.990.7 via Frontend Transport; Wed, 23 Jul 2014 06:45:19 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD014.mail.protection.outlook.com (10.58.144.77) with Microsoft SMTP Server (TLS) id 15.0.980.11 via Frontend Transport; Wed, 23 Jul 2014 06:45:18 +0000 Received: from nmglablinux18.freescale.com (nmglablinux18.zin33.ap.freescale.net [10.232.20.240]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s6N6jGbI011738; Tue, 22 Jul 2014 23:45:17 -0700 Received: by nmglablinux18.freescale.com (Postfix, from userid 5043) id F28783DD9CCF; Wed, 23 Jul 2014 12:15:12 +0530 (IST) From: Hemant Agrawal To: Date: Wed, 23 Jul 2014 12:15:12 +0530 Message-ID: <14060979121185-git-send-email-Hemant@freescale.com> X-Mailer: git-send-email 1.5.2.4 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6039001)(6009001)(428002)(189002)(199002)(77096002)(84676001)(77982001)(74502001)(85852003)(103686003)(104166001)(26826002)(19580395003)(95666004)(68736004)(83072002)(83322001)(93916002)(86372001)(92566001)(20776003)(50986999)(44976005)(89996001)(62966002)(81542001)(92726001)(50466002)(6806004)(87286001)(42186005)(74662001)(21056001)(101416001)(99396002)(31966008)(77156001)(46386002)(87936001)(2351001)(79102001)(229853001)(4396001)(110136001)(97736001)(48376002)(107046002)(16796002)(81342001)(19580405001)(106466001)(45336002)(88136002)(102836001)(52956003)(64706001)(85306003)(36756003)(76482001)(50226001)(46102001)(47776003)(80022001)(105586002)(90966001); DIR:OUT; SFP:; SCL:1; SRVR:BN1PR0301MB0691; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 028166BF91 Received-SPF: None (: nmglablinux18.freescale.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.mailfrom=b10814@nmglablinux18.freescale.com; X-OriginatorOrg: freescale.com Subject: [dpdk-dev] [PATCH] kni: optimizing the rte_kni_rx_burst X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2014 06:43:59 -0000 The current implementation of rte_kni_rx_burst polls the fifo for buffers. Irrespective of success or failure, it allocates the mbuf and try to put them into the alloc_q if the buffers are not added to alloc_q, it frees them. This waste lots of cpu cycles in allocating and freeing the buffers if alloc_q is full. The logic has been changed to: 1. Initially allocand add buffer(burstsize) to alloc_q 2. Add buffers to alloc_q only when you are pulling out the buffers. Signed-off-by: Hemant Agrawal --- lib/librte_kni/rte_kni.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 76feef4..01e85f8 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -263,6 +263,9 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, ctx->in_use = 1; + /* Allocate mbufs and then put them into alloc_q */ + kni_allocate_mbufs(ctx); + return ctx; fail: @@ -369,8 +372,9 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num) { unsigned ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); - /* Allocate mbufs and then put them into alloc_q */ - kni_allocate_mbufs(kni); + /* If buffers removed, allocate mbufs and then put them into alloc_q */ + if(ret) + kni_allocate_mbufs(kni); return ret; } -- 1.7.9.6