From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 05F232BD7 for ; Fri, 18 Mar 2016 11:37:18 +0100 (CET) Received: by mail-wm0-f53.google.com with SMTP id l68so30731427wml.1 for ; Fri, 18 Mar 2016 03:37:18 -0700 (PDT) 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; bh=bSJeqwDPzRB6BDsuos+YTD4At49DTcNfGmjpKYWHN6s=; b=jNwhQjUDcGpeNrQ8+JNPoYcDVbyKtjkIOEYqZSo4L/mXg+MPZyMENQpqpNLZeqSl61 REU7BY/OhIvd7jAMmKaeKki4ssFh4v2KjXUGQxrg3Lnusf5ynv6iskjlzHApoNKH9QZn KmRq/hrszbEBqfzhQq+lrrgx4gntaZRzSHoGeBN9gM8DDnAA23uqmk1eBM8R+wSzK4Cl bR1agg3aR8yF95OvWH+INBX76LHC2XH0m7B8GRt6erRbLGHCecNR/JRHaqxHazEZg9ac acBQNDr+uavHkL0zOvKmMazLZfv4bgBmDwOMqhbXA522b4lW/6/9yVSLl3c1Lzo4fPl6 QMvQ== 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; bh=bSJeqwDPzRB6BDsuos+YTD4At49DTcNfGmjpKYWHN6s=; b=MdzB+Ta+7rfCRH6ZdudN/bBnJw1vzlcI629eWxyK5KdurwtJY4kdGCWGF4JUQ9XBuR qADvcU2qhMVfYZpH69S5/r+y0IrAZ6ramkso/XctxDxLttkKvOQqa+DHoj2Yy7DeQQd4 kYV9zMiKUaBovpW7bEtgTiBbAYmgo79+moluSD74K5yz5N1ryQ0XyMzUXP3v8sYMqfMk vW6gxmqn4rT8C0Nwuepw3JDGM7NozMBDYXFiX0xdq/JKZd0lxYESGHuhVBiFbc81AYWX uvvesF3ZkJgrbTaQ1Rhpp9jMFXd0fQBfoQWZ9F0N+sJLslIjv+3Ntp4Px6hKIxao+OXh 8zGg== X-Gm-Message-State: AD7BkJJVHjDcxID5RoMq1srWJLjZgiG5MOUD6w8egFgLQIvqhaSRnuNZiNgRK8y8pI9qRkQf X-Received: by 10.28.173.143 with SMTP id w137mr17001984wme.101.1458297437865; Fri, 18 Mar 2016 03:37:17 -0700 (PDT) Received: from xps13.localnet (91.111.75.86.rev.sfr.net. [86.75.111.91]) by smtp.gmail.com with ESMTPSA id o16sm11668413wjr.9.2016.03.18.03.37.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Mar 2016 03:37:17 -0700 (PDT) From: Thomas Monjalon To: dev@dpdk.org, Bruce Richardson Cc: Olivier Matz , Mauricio =?ISO-8859-1?Q?V=E1squez?= , Lazaros Koromilas Date: Fri, 18 Mar 2016 11:35:46 +0100 Message-ID: <17186869.jQBbCLbaVI@xps13> Organization: 6WIND User-Agent: KMail/4.14.10 (Linux/4.1.6-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <56EBD806.8010707@6wind.com> References: <1458229783-15547-1-git-send-email-l@nofutznetworks.com> <20160318101823.GC4848@bricha3-MOBL3> <56EBD806.8010707@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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:37:18 -0000 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 == 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. 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 ;)