From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0128.outbound.protection.outlook.com [65.55.169.128]) by dpdk.org (Postfix) with ESMTP id 01B1E9A97 for ; Wed, 25 Feb 2015 13:24:36 +0100 (CET) Received: from BY2PR0301MB0693.namprd03.prod.outlook.com (25.160.63.148) by BY2PR0301MB0694.namprd03.prod.outlook.com (25.160.63.149) with Microsoft SMTP Server (TLS) id 15.1.93.16; Wed, 25 Feb 2015 12:24:35 +0000 Received: from BY2PR0301MB0693.namprd03.prod.outlook.com ([25.160.63.148]) by BY2PR0301MB0693.namprd03.prod.outlook.com ([25.160.63.148]) with mapi id 15.01.0093.004; Wed, 25 Feb 2015 12:24:35 +0000 From: "Hemant@freescale.com" To: Olivier Deme , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst Thread-Index: AQHQUPDsBDAVtRfAwUq3yuBnQ7MxpZ0BRxsAgAAAtNA= Date: Wed, 25 Feb 2015 12:24:34 +0000 Message-ID: References: <14248648813214-git-send-email-Hemant@freescale.com> <54EDBC76.2050507@druidsoftware.com> In-Reply-To: <54EDBC76.2050507@druidsoftware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.88.169.1] authentication-results: spf=none (sender IP is ) smtp.mailfrom=Hemant@freescale.com; x-microsoft-antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0694; x-bulk-sender: Mark as legitimate x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB0694; x-forefront-prvs: 049897979A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(51704005)(24454002)(377454003)(479174004)(252514010)(199003)(189002)(13464003)(64706001)(66066001)(92566002)(102836002)(15975445007)(33656002)(2501003)(40100003)(122556002)(74316001)(97736003)(76576001)(77156002)(19580405001)(2656002)(99286002)(50986999)(54356999)(76176999)(19580395003)(86362001)(62966003)(2900100001)(2950100001)(101416001)(46102003)(68736005)(107886001)(105586002)(106356001)(87936001)(106116001)(80792004); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB0694; H:BY2PR0301MB0693.namprd03.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: freescale.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Feb 2015 12:24:34.9440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB0694 Subject: Re: [dpdk-dev] [PATCH] kni:optimization of 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, 25 Feb 2015 12:24:37 -0000 Hi OIivier Comments inline. Regards, Hemant > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Deme > Sent: 25/Feb/2015 5:44 PM > To: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst >=20 > Thank you Hemant, I think there might be one issue left with the patch th= ough. > The alloc_q must initially be filled with mbufs before getting mbuf back = on the > tx_q. >=20 > So the patch should allow rte_kni_rx_burst to check if alloc_q is empty. > If so, it should invoke kni_allocate_mbufs(kni, 0) (to fill the alloc_q w= ith > MAX_MBUF_BURST_NUM mbufs) >=20 > The patch for rte_kni_rx_burst would then look like: >=20 > @@ -575,7 +575,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf > **mbufs, unsigned num) >=20 > /* If buffers removed, allocate mbufs and then put them into alloc_= q */ > if (ret) > - kni_allocate_mbufs(kni); > + kni_allocate_mbufs(kni, ret); > + else if (unlikely(kni->alloc_q->write =3D=3D kni->alloc_q->read)) > + kni_allocate_mbufs(kni, 0); >=20 [hemant] This will introduce a run-time check. I missed to include the other change in the patch.=20 I am doing it in kni_alloc i.e. initiate the alloc_q with default burst si= ze.=20 kni_allocate_mbufs(ctx, 0); In a way, we are now suggesting to reduce the size of alloc_q to only defau= lt burst size.=20 Can we reach is situation, when the kernel is adding packets faster in tx_q= than the application is able to dequeue? alloc_q can be empty in this case and kernel will be striving.=20 >=20 > Olivier. >=20 > On 25/02/15 11:48, Hemant Agrawal wrote: > > From: Hemant Agrawal > > > > if any buffer is read from the tx_q, MAX_BURST buffers will be allocate= d and > attempted to be added to to the alloc_q. > > This seems terribly inefficient and it also looks like the alloc_q will= quickly fill > to its maximum capacity. If the system buffers are low in number, it will= reach > "out of memory" situation. > > > > This patch allocates the number of buffers as many dequeued from tx_q. > > > > Signed-off-by: Hemant Agrawal > > --- > > lib/librte_kni/rte_kni.c | 13 ++++++++----- > > 1 file changed, 8 insertions(+), 5 deletions(-) > > > > diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index > > 4e70fa0..4cf8e30 100644 > > --- a/lib/librte_kni/rte_kni.c > > +++ b/lib/librte_kni/rte_kni.c > > @@ -128,7 +128,7 @@ struct rte_kni_memzone_pool { > > > > > > static void kni_free_mbufs(struct rte_kni *kni); -static void > > kni_allocate_mbufs(struct rte_kni *kni); > > +static void kni_allocate_mbufs(struct rte_kni *kni, int num); > > > > static volatile int kni_fd =3D -1; > > static struct rte_kni_memzone_pool kni_memzone_pool =3D { @@ -575,7 > > +575,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf > > **mbufs, unsigned num) > > > > /* If buffers removed, allocate mbufs and then put them into alloc_q > */ > > if (ret) > > - kni_allocate_mbufs(kni); > > + kni_allocate_mbufs(kni, ret); > > > > return ret; > > } > > @@ -594,7 +594,7 @@ kni_free_mbufs(struct rte_kni *kni) > > } > > > > static void > > -kni_allocate_mbufs(struct rte_kni *kni) > > +kni_allocate_mbufs(struct rte_kni *kni, int num) > > { > > int i, ret; > > struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM]; @@ -620,7 +620,10 > @@ > > kni_allocate_mbufs(struct rte_kni *kni) > > return; > > } > > > > - for (i =3D 0; i < MAX_MBUF_BURST_NUM; i++) { > > + if (num =3D=3D 0 || num > MAX_MBUF_BURST_NUM) > > + num =3D MAX_MBUF_BURST_NUM; > > + > > + for (i =3D 0; i < num; i++) { > > pkts[i] =3D rte_pktmbuf_alloc(kni->pktmbuf_pool); > > if (unlikely(pkts[i] =3D=3D NULL)) { > > /* Out of memory */ > > @@ -636,7 +639,7 @@ kni_allocate_mbufs(struct rte_kni *kni) > > ret =3D kni_fifo_put(kni->alloc_q, (void **)pkts, i); > > > > /* Check if any mbufs not put into alloc_q, and then free them */ > > - if (ret >=3D 0 && ret < i && ret < MAX_MBUF_BURST_NUM) > {MAX_MBUF_BURST_NUM > > > > + if (ret >=3D 0 && ret < i && ret < num) { > > int j; > > > > for (j =3D ret; j < i; j++) >=20 > -- > *Olivier Dem=E9* > *Druid Software Ltd.* > *Tel: +353 1 202 1831* > *Email: odeme@druidsoftware.com * > *URL: http://www.druidsoftware.com* > *Hall 7, stand 7F70.* > Druid Software: Monetising enterprise small cells solutions.