From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id F2377F72 for ; Mon, 21 Dec 2015 22:32:12 +0100 (CET) Received: by mail-wm0-f50.google.com with SMTP id p187so84750068wmp.0 for ; Mon, 21 Dec 2015 13:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :in-reply-to:references:mime-version:content-transfer-encoding :content-type; bh=rHJT+NCmsMxkPqGU/L+7UnZF9tOZmTPBPeUdf6uGX7s=; b=VZwffQLRhsx46MAEtz3CPKZAxyXOLn+6wGCKb6GsDYUhY7D0z4ya5vpxa+mcjK+hD6 7G3uIXTxk2ePMBS7Jr6rdy62BcOEokV86TL4ZX56kKkqH7LhELiHmarMQhD3LMQybJb0 QJKjI90VGreazoXCTJLxTUyEhIOc/P/1G8INavykj7r0PsAcyTmshlm0oxy7yA9FRwjE g5A4tiRFAZo0UY7sDKGt2rETm6LTdgZgbI2ZLk6Y0PxzeC098xt0NxQ4qTidoVSDtKkn iCaS8s7qthNcbH+oo6ELqHuS7geHsykok0A9v7brlueLi6hO2HJsZwQWm847pplpo8It 24Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=rHJT+NCmsMxkPqGU/L+7UnZF9tOZmTPBPeUdf6uGX7s=; b=HpjUZkAHKFOIQS1cGzDfjEsKKfxrOqXOg8nWtvy+bAzys8o7LDYrlhhTtY22w957/X ZzD/Dm2K1q6p/J1i/voW8DRxgiogw6iXENrOFTHmz+S/b8r6IyJIxkWdjfP6xK9FHDFE Ejf12wPy77QcpI9t1SGLqz5VFfJDicZbx2rJRm1djb01vtq4Mr19KLqxRwAEd1mXjTB6 tNZtxc9L+X/ez7INQ6qr+5mDW299nMpbj3/vhS1ykaLGcsx5koGdZkkGHDEe+yXwmhm9 14mz+OJA3Y3esvIx086K8HRxu3Df0KydT+G9XpWx7OWXyVe9Hzz9mEtoMEWERz13mJb5 x/UQ== X-Gm-Message-State: ALoCoQkJjVM1BKEgDRFKBkLy+ip9kJLVvdEWRTpEOaSYN2Z29ykFXhB3Wrzk26NclXXq6vIe9vt87FJjB4Y4zQ1T9sGHH+yfVA== X-Received: by 10.194.238.231 with SMTP id vn7mr26535704wjc.109.1450733532800; Mon, 21 Dec 2015 13:32:12 -0800 (PST) Received: from xps13.localnet (APoitiers-658-1-20-121.w86-213.abo.wanadoo.fr. [86.213.59.121]) by smtp.gmail.com with ESMTPSA id kb5sm29868119wjc.20.2015.12.21.13.32.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 Dec 2015 13:32:12 -0800 (PST) From: Thomas Monjalon To: "Xie, Huawei" Date: Mon, 21 Dec 2015 22:30:39 +0100 Message-ID: <53745737.WGjHJuKom7@xps13> Organization: 6WIND User-Agent: KMail/4.14.10 (Linux/4.1.6-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <868B1A38-37CB-4E19-B3FE-E9B74C35545B@intel.com> References: <1450049754-33635-1-git-send-email-huawei.xie@intel.com> <868B1A38-37CB-4E19-B3FE-E9B74C35545B@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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: Mon, 21 Dec 2015 21:32:13 -0000 2015-12-21 17:20, Wiles, Keith: > On 12/21/15, 9:21 AM, "Xie, Huawei" wrote: > >On 12/19/2015 3:27 AM, Wiles, Keith wrote: > >> On 12/18/15, 11:32 AM, "dev on behalf of Stephen Hemminger" wrote: > >>> On Fri, 18 Dec 2015 10:44:02 +0000 > >>> "Ananyev, Konstantin" wrote: > >>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > >>>>> On Mon, 14 Dec 2015 09:14:41 +0800 > >>>>> Huawei Xie wrote: > >>>>>> + switch (count % 4) { > >>>>>> + while (idx != count) { > >>>>>> + case 0: > >>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > >>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1); > >>>>>> + rte_pktmbuf_reset(mbufs[idx]); > >>>>>> + idx++; > >>>>>> + case 3: > >>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > >>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1); > >>>>>> + rte_pktmbuf_reset(mbufs[idx]); > >>>>>> + idx++; > >>>>>> + case 2: > >>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > >>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1); > >>>>>> + rte_pktmbuf_reset(mbufs[idx]); > >>>>>> + idx++; > >>>>>> + case 1: > >>>>>> + RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > >>>>>> + rte_mbuf_refcnt_set(mbufs[idx], 1); > >>>>>> + rte_pktmbuf_reset(mbufs[idx]); > >>>>>> + idx++; > >>>>>> + } > >>>>>> + } > >>>>>> + return 0; > >>>>>> +} > >>>>> This is weird. Why not just use Duff's device in a more normal manner. > >>>> But it is a sort of Duff's method. > >>>> Not sure what looks weird to you here? > >>>> while () {} instead of do {} while();? > >>>> Konstantin > >>>> > >>>> > >>>> > >>> It is unusual to have cases not associated with block of the switch. > >>> Unusual to me means, "not used commonly in most code". > >>> > >>> Since you are jumping into the loop, might make more sense as a do { } while() > >> I find this a very odd coding practice and I would suggest we not do this, unless it gives us some great performance gain. > >> > >> Keith > >The loop unwinding could give performance gain. The only problem is the > >switch/loop combination makes people feel weird at the first glance but > >soon they will grasp this style. Since this is inherited from old famous > >duff's device, i prefer to keep this style which saves lines of code. > > Please add a comment to the code to reflex where this style came from and why you are using it, would be very handy here. +1 At least the words "loop" and "unwinding" may be helpful to some readers. Thanks