From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id 771FA5947 for ; Fri, 18 Mar 2016 11:27:21 +0100 (CET) Received: by mail-wm0-f51.google.com with SMTP id p65so30381554wmp.0 for ; Fri, 18 Mar 2016 03:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=KIfic7sXAnbEm8Jw/UWBwMFbHLp7phKNULms1ABzkVY=; b=xyOuBBhs9sUtvb77Trqod/37PJeqi7zIzIodk3gz0M6Q38xLu6s26zjByyu9zQibBg Ga04vf1w9JK51lHfbxZQjQcQsxM/lIO2mToxZMzDtoP/QrNBBvbHDcY4Ca3gN74NoIPk CUqpNCgw9oIVHjNl8H6+JnAFhPbh8KC1m4lkKvN5CT/Rk7IeZIfMtBKhraAaC26wfOWq XmbEYK2xY0hDOh541eSPJXkiOxqtxKLtwoKhis4nnzieBGyrPtAjW0h5BhEhwaW0B1un 8gXcLSEkm4fJwui1X+u00QcD/jlO7IaLHAlkRiL3FfGKIooAIPqSoN53pMkpnZ0KmNfV qgsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=KIfic7sXAnbEm8Jw/UWBwMFbHLp7phKNULms1ABzkVY=; b=TbqVyaz98m+WtDPTLJV8Z026Kudh0Qo4CCfvpRLDjMn0rxd0P+uM+t501BXMClZHw/ 0ot7DMJSzClG9O+kF1MjgxlqzfHFKpAKFUtO6iP8NiVIy+xvL/0o3nbs+BDTg64OiEJ2 yl3sShm4X/+UFhSGtwrGOwzahPqZqTZ2z4Oipyu+npwipG6nbVZHum5esqGTD2kQ4svq 884pJ43Zvlhr1cchyE3E4YjE6HMWR/4gVQ6i7lt5j9ZxKtwei1xmGpFOmqoSjlb15noW Rse0oPLTiB4KeW/BDvwJnUH4QHqw9tXOGfzez1ABEXQF9YeQcu7pg/xMxV7ed3gQEozi mgdw== X-Gm-Message-State: AD7BkJLk4qrg9KS6GMpN8FsDlRd/5e3957VjTQs3quvwjv/yvXhQfrS3lIEaIhLY+OzzAJOz X-Received: by 10.194.133.101 with SMTP id pb5mr15206275wjb.106.1458296841342; Fri, 18 Mar 2016 03:27:21 -0700 (PDT) Received: from [192.168.0.10] (was59-1-82-226-113-214.fbx.proxad.net. [82.226.113.214]) by smtp.gmail.com with ESMTPSA id y62sm12061980wmg.12.2016.03.18.03.27.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Mar 2016 03:27:20 -0700 (PDT) To: Bruce Richardson , =?UTF-8?Q?Mauricio_V=c3=a1squez?= References: <1458229783-15547-1-git-send-email-l@nofutznetworks.com> <20160318101823.GC4848@bricha3-MOBL3> Cc: Lazaros Koromilas , dev@dpdk.org From: Olivier Matz Message-ID: <56EBD806.8010707@6wind.com> Date: Fri, 18 Mar 2016 11:27:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160318101823.GC4848@bricha3-MOBL3> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] ring: check for zero objects mc dequeue / mp enqueue 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: Fri, 18 Mar 2016 10:27:21 -0000 Hi, On 03/18/2016 11:18 AM, Bruce Richardson wrote: >>> diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h >>> index 943c97c..eb45e41 100644 >>> --- a/lib/librte_ring/rte_ring.h >>> +++ b/lib/librte_ring/rte_ring.h >>> @@ -431,6 +431,11 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * >>> const *obj_table, >>> uint32_t mask = r->prod.mask; >>> int ret; >>> >>> + /* Avoid the unnecessary cmpset operation below, which is also >>> + * potentially harmful when n equals 0. */ >>> + if (n == 0) >>> >> >> What about using unlikely here? >> > > Unless there is a measurable performance increase by adding in likely/unlikely > I'd suggest avoiding it's use. In general, likely/unlikely should only be used > for things like catestrophic errors because the penalty for taking the unlikely > leg of the code can be quite severe. For normal stuff, where the code nearly > always goes one way in the branch but occasionally goes the other, the hardware > branch predictors generally do a good enough job. Do you mean using likely/unlikely could be worst than not using it in this case? To me, using unlikely here is not a bad idea: it shows to the compiler and to the reader of the code that is case is not the usual case. Olivier