From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH v2] ring: check for zero objects mc dequeue / mp enqueue Date: Fri, 18 Mar 2016 14:16:32 +0000 Message-ID: <20160318141632.GC12932@bricha3-MOBL3> References: <1458229783-15547-1-git-send-email-l@nofutznetworks.com> <20160318101823.GC4848@bricha3-MOBL3> <56EBD806.8010707@6wind.com> <17186869.jQBbCLbaVI@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Thomas Monjalon , dev@dpdk.org, Olivier Matz , Lazaros Koromilas To: Mauricio =?iso-8859-1?Q?V=E1squez?= Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A634F2C06 for ; Fri, 18 Mar 2016 15:16:36 +0100 (CET) Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Mar 18, 2016 at 01:47:29PM +0100, Mauricio V=E1squez wrote: > Hi, >=20 >=20 > On Fri, Mar 18, 2016 at 11:35 AM, Thomas Monjalon > wrote: >=20 > > 2016-03-18 11:27, Olivier Matz: > > > On 03/18/2016 11:18 AM, Bruce Richardson wrote: > > > >>> + /* Avoid the unnecessary cmpset operation below, which = is > > also > > > >>> + * potentially harmful when n equals 0. */ > > > >>> + if (n =3D=3D 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 takin= g 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 compi= ler > > > and to the reader of the code that is case is not the usual case. > > > > It would be nice to have a guideline section about likely/unlikely in > > doc/guides/contributing/design.rst > > > > Bruce gave a talk at Dublin about this kind of things. > > I'm sure he could contribute more design guidelines ;) > > >=20 > There is a small explanation in the section "Branch Prediction" of > doc/guides/contributing/coding_style.rst, but I do not know if that is > enough to understand when to use them. >=20 > I've made a fast check and there are many PMDs that use them to check i= f > number of packets is zero in the transmission function. Yeah, and I wonder how many of those are actually necessary too :-) It's not a big deal either way, I just think the patch is fine as-is with= out the extra macros. /Bruce