From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 6BA1F5A24 for ; Tue, 22 Dec 2015 02:58:53 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 21 Dec 2015 17:58:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,462,1444719600"; d="scan'208";a="621926761" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 21 Dec 2015 17:58:50 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 21 Dec 2015 17:58:50 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 21 Dec 2015 17:58:50 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.190]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.28]) with mapi id 14.03.0248.002; Tue, 22 Dec 2015 09:58:48 +0800 From: "Xie, Huawei" To: Thomas Monjalon Thread-Topic: [dpdk-dev] [PATCH v2 1/2] mbuf: provide rte_pktmbuf_alloc_bulk API Thread-Index: AdE8A0gB5k4AFZq3TfmHtb59BK82Zg== Date: Tue, 22 Dec 2015 01:58:48 +0000 Message-ID: References: <1450049754-33635-1-git-send-email-huawei.xie@intel.com> <868B1A38-37CB-4E19-B3FE-E9B74C35545B@intel.com> <53745737.WGjHJuKom7@xps13> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2 1/2] mbuf: provide rte_pktmbuf_alloc_bulk API 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: Tue, 22 Dec 2015 01:58:54 -0000 On 12/22/2015 5:32 AM, Thomas Monjalon wrote:=0A= > 2015-12-21 17:20, Wiles, Keith:=0A= >> On 12/21/15, 9:21 AM, "Xie, Huawei" wrote:=0A= >>> On 12/19/2015 3:27 AM, Wiles, Keith wrote:=0A= >>>> On 12/18/15, 11:32 AM, "dev on behalf of Stephen Hemminger" wrote:=0A= >>>>> On Fri, 18 Dec 2015 10:44:02 +0000=0A= >>>>> "Ananyev, Konstantin" wrote:=0A= >>>>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemming= er=0A= >>>>>>> On Mon, 14 Dec 2015 09:14:41 +0800=0A= >>>>>>> Huawei Xie wrote:=0A= >>>>>>>> + switch (count % 4) {=0A= >>>>>>>> + while (idx !=3D count) {=0A= >>>>>>>> + case 0:=0A= >>>>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) =3D=3D 0);=0A= >>>>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1);=0A= >>>>>>>> + rte_pktmbuf_reset(mbufs[idx]);=0A= >>>>>>>> + idx++;=0A= >>>>>>>> + case 3:=0A= >>>>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) =3D=3D 0);=0A= >>>>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1);=0A= >>>>>>>> + rte_pktmbuf_reset(mbufs[idx]);=0A= >>>>>>>> + idx++;=0A= >>>>>>>> + case 2:=0A= >>>>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) =3D=3D 0);=0A= >>>>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1);=0A= >>>>>>>> + rte_pktmbuf_reset(mbufs[idx]);=0A= >>>>>>>> + idx++;=0A= >>>>>>>> + case 1:=0A= >>>>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) =3D=3D 0);=0A= >>>>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1);=0A= >>>>>>>> + rte_pktmbuf_reset(mbufs[idx]);=0A= >>>>>>>> + idx++;=0A= >>>>>>>> + }=0A= >>>>>>>> + }=0A= >>>>>>>> + return 0;=0A= >>>>>>>> +}=0A= >>>>>>> This is weird. Why not just use Duff's device in a more normal mann= er.=0A= >>>>>> But it is a sort of Duff's method.=0A= >>>>>> Not sure what looks weird to you here?=0A= >>>>>> while () {} instead of do {} while();?=0A= >>>>>> Konstantin=0A= >>>>>>=0A= >>>>>>=0A= >>>>>>=0A= >>>>> It is unusual to have cases not associated with block of the switch.= =0A= >>>>> Unusual to me means, "not used commonly in most code".=0A= >>>>>=0A= >>>>> Since you are jumping into the loop, might make more sense as a do { = } while()=0A= >>>> I find this a very odd coding practice and I would suggest we not do t= his, unless it gives us some great performance gain.=0A= >>>>=0A= >>>> Keith=0A= >>> The loop unwinding could give performance gain. The only problem is the= =0A= >>> switch/loop combination makes people feel weird at the first glance but= =0A= >>> soon they will grasp this style. Since this is inherited from old famou= s=0A= >>> duff's device, i prefer to keep this style which saves lines of code.= =0A= >> Please add a comment to the code to reflex where this style came from an= d why you are using it, would be very handy here.=0A= > +1=0A= > At least the words "loop" and "unwinding" may be helpful to some readers.= =0A= OK. Will add more context. Probably the wiki page for duff's device=0A= should be updated on how to handle the case count is zero, using while()=0A= or add one line to check.=0A= =0A= > Thanks=0A= >=0A= =0A=