From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0F14C312 for ; Mon, 29 Sep 2014 00:18:47 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 28 Sep 2014 15:25:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,616,1406617200"; d="scan'208";a="606715417" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga002.fm.intel.com with ESMTP; 28 Sep 2014 15:25:19 -0700 Received: from irsmsx107.ger.corp.intel.com (163.33.3.99) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sun, 28 Sep 2014 23:25:18 +0100 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.248]) by IRSMSX107.ger.corp.intel.com ([169.254.10.68]) with mapi id 14.03.0195.001; Sun, 28 Sep 2014 23:25:18 +0100 From: "Ananyev, Konstantin" To: "Wiles, Roger Keith (Wind River)" , "" Thread-Topic: [dpdk-dev] [PATCH] Function __mempool_get_bulk() returns wrong count. Thread-Index: AQHP2oKtLICv7vWhf0Wg0zJjkh9qrZwXHE1w Date: Sun, 28 Sep 2014 22:25:17 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213851AC@IRSMSX104.ger.corp.intel.com> References: <82107A2E-6373-4A8E-9CDA-10FE18EDEFB6@windriver.com> In-Reply-To: <82107A2E-6373-4A8E-9CDA-10FE18EDEFB6@windriver.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] Function __mempool_get_bulk() returns wrong count. 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: Sun, 28 Sep 2014 22:18:48 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wiles, Roger Keith > Sent: Saturday, September 27, 2014 7:42 PM > To: > Subject: [dpdk-dev] [PATCH] Function __mempool_get_bulk() returns wrong c= ount. >=20 >=20 > When __mempool_get_bulk() grabs entries from the cache it > returns zero instead of the number of entries obtained. Plus > the stats were increased by the wrong count of objects. >=20 > Signed-off-by: Keith Wiles > --- > lib/librte_mempool/rte_mempool.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_me= mpool.h > index 299d4d7..6750e78 100644 > --- a/lib/librte_mempool/rte_mempool.h > +++ b/lib/librte_mempool/rte_mempool.h > @@ -988,9 +988,9 @@ __mempool_get_bulk(struct rte_mempool *mp, void **obj= _table, >=20 > cache->len -=3D n; >=20 > - __MEMPOOL_STAT_ADD(mp, get_success, n_orig); > + __MEMPOOL_STAT_ADD(mp, get_success, n); As I can see n =3D=3D n_orig. We can completely remove n_orig, but from other side - I don't see any harm= here.=20 >=20 > - return 0; > + return n; As I can see, __mempool_get_bulk supposed to return 0, if all n objects were allocated from mbuf, or a negative error code otherwi= se. Check all usages of __mempool_get_bulk(), plus the fact that it does below: ret =3D rte_ring_mc_dequeue_bulk(mp->ring, obj_table, n); and rte_ring_mc_dequeue_bulk() is just wrapper for __rte_ring_mc_do_dequeue= (..., n, RTE_RING_QUEUE_FIXED); I.e. - either allocate all n objects, or return with failure. So, yes we should return 0 here. The only thing that probably needs to be done here: fix the comments. Instead of: - >=3D0: Success; number of objects supplied. Something like: - 0: Success; n objects supplied. >=20 > ring_dequeue: > #endif /* RTE_MEMPOOL_CACHE_MAX_SIZE > 0 */ > @@ -1004,7 +1004,7 @@ ring_dequeue: > if (ret < 0) > __MEMPOOL_STAT_ADD(mp, get_fail, n_orig); > else > - __MEMPOOL_STAT_ADD(mp, get_success, n_orig); > + __MEMPOOL_STAT_ADD(mp, get_success, ret); That seems incorrect tom me. ret would be either 0 on success, or negative error value. Konstantin >=20 > return ret; > } > -- > 2.1.0Keith Wiles, Principal Technologist with CTO office, Wind River mobi= le 972-213-5533 As I can see=20