From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id 5406E5906 for ; Fri, 20 Dec 2013 17:35:11 +0100 (CET) Received: by mail-pa0-f45.google.com with SMTP id fb1so2837288pad.18 for ; Fri, 20 Dec 2013 08:36:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=zgrwH9ms00nBRihEfOydrNvZHeVkVWe505QwtHTSC7s=; b=dwWUnksqxnoEQioEoELqVKoOL2j4rASDx5AAqxfESJNDfB0XeLjmMxRYjAHEhI7twP cx2Py2cKQSZADy4t2h373p+zO8PcCsoVXflddrVfnZnlczgNlABL9QInVB2kw3Srnff3 wdrEJuCtiJOTYfkP4mBy/W1jGEJ3SfKkCia0NRcbyNl5zE6mwCYGbasYpNs190Twrmlu jkFM7eS0/7J6LT6DD0u9ob1A7jih2aJs8OGDAXnKYDeIHBEqFLCG/eXQSUmDud2/Ikre ZMdY3T46ji1k2CcfhDUS42RC5ojaRrw4XDXAbn2U36f6kkzvntJibly/CZTtii/R8vI6 LTNA== X-Gm-Message-State: ALoCoQk1wy/3OpD0jvAP0IteyHn5asRwkucC43UoVi+hxVZF04nBHESRmRCOwm+DIOEEQGwV9wV/ X-Received: by 10.68.198.97 with SMTP id jb1mr9674537pbc.104.1387557377843; Fri, 20 Dec 2013 08:36:17 -0800 (PST) Received: from nehalam.linuxnetplumber.net (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id nl7sm15560436pbc.6.2013.12.20.08.36.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 20 Dec 2013 08:36:17 -0800 (PST) Date: Fri, 20 Dec 2013 08:36:14 -0800 From: Stephen Hemminger To: =?ISO-8859-1?B?RnJhbudvaXMtRnLpZOlyaWM=?= Ozog Message-ID: <20131220083614.2a996421@nehalam.linuxnetplumber.net> In-Reply-To: <04be01cefd9c$a3c36460$eb4a2d20$@com> References: <6895EAE0CA8DEE40B92D7CA88BB521F332BA572E6B@HQ1-EXCH02.corp.brocade.com> <4656219.tgqzelRNOJ@x220> <01d001cef375$7167e300$5437a900$@com> <201312201639.05277.thomas.monjalon@6wind.com> <04be01cefd9c$a3c36460$eb4a2d20$@com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org Subject: Re: [dpdk-dev] Bit spinlocks in DPDK 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, 20 Dec 2013 16:35:11 -0000 On Fri, 20 Dec 2013 17:00:43 +0100 Fran=E7ois-Fr=E9d=E9ric Ozog wrote: >=20 >=20 > > -----Message d'origine----- > > De=A0: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > > Envoy=E9=A0: vendredi 20 d=E9cembre 2013 16:39 > > =C0=A0: Fran=E7ois-Fr=E9d=E9ric Ozog > > Cc=A0: dev@dpdk.org > > Objet=A0: Re: [dpdk-dev] Bit spinlocks in DPDK > >=20 > > Hello, > >=20 > > 07/12/2013 18:54, Fran=E7ois-Fr=E9d=E9ric Ozog : > > > 1) If the critical section deals with weakly ordered loads then > > > explicit fencing MUST be used: if not, out of order execution will > > > just kill your idea of critical section. > > [...] > > > So use rte_mb() or rte_wmb() or rte_rmb() where appropriate. I > > > recommend the rte_unlock code and documentation explains the out of > > > order execution issues and the conditions they have to be mitigated > > > with rte*mb(). I wonder if having an explicit mfence in > > > rte_sinlock_unlock wouldn't be just necessary to avoid "hairy" bugs. > > > In addition, we would have rte_sinlock_unlock_no_mb used internally > > > for performance reasons, and usable externally by advanced users. > >=20 > > Using lock prefix is lighter than using memory barrier and have the same > > effects. >=20 > Well, in general yes BUT Intel states "../.. locked operations serialize = all > outstanding load and store operations ../.. with one exception. Load > operations that reference weakly ordered memory types (such as the WC mem= ory > type) may *not* be serialized" in 8.1.2.2 Software Controlled Bus Locking; > particularly if streaming loads are used (may happen on certain devices > memory mapped I/O accesses and the compiler generating streaming loads). >=20 > So this comment is essentially for the PMD writers: use the fencing where > appropriate, even if the lock prefix is there. As I will be the one > forgetting the rule, I like to have that in the documentation/comments as > reminders to keep things neat. >=20 > Fran=E7ois-Fr=E9d=E9ric I recommend anyone who needs more information read: Documentation/memory-barriers.txt in the Linux kernel source.