From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mo1.mail-out.ovh.net (7.mo1.mail-out.ovh.net [87.98.158.110]) by dpdk.org (Postfix) with ESMTP id EB96458D6 for ; Fri, 20 Dec 2013 17:01:37 +0100 (CET) Received: from mail195.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo1.mail-out.ovh.net (Postfix) with SMTP id 9A54F10040FB for ; Fri, 20 Dec 2013 17:06:29 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 20 Dec 2013 17:59:09 +0200 Received: from lneuilly-152-23-9-75.w193-252.abo.wanadoo.fr (HELO pcdeff) (ff@ozog.com@193.252.40.75) by ns0.ovh.net with SMTP; 20 Dec 2013 17:59:06 +0200 From: =?iso-8859-1?Q?Fran=E7ois-Fr=E9d=E9ric_Ozog?= To: "'Thomas Monjalon'" References: <6895EAE0CA8DEE40B92D7CA88BB521F332BA572E6B@HQ1-EXCH02.corp.brocade.com> <4656219.tgqzelRNOJ@x220> <01d001cef375$7167e300$5437a900$@com> <201312201639.05277.thomas.monjalon@6wind.com> In-Reply-To: <201312201639.05277.thomas.monjalon@6wind.com> Date: Fri, 20 Dec 2013 17:00:43 +0100 Message-ID: <04be01cefd9c$a3c36460$eb4a2d20$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac79maA13vs6vYEvTvGwfFNs60IP1QAAcpzw Content-Language: fr X-Ovh-Tracer-Id: 7586876522915289305 X-Ovh-Remote: 193.252.40.75 (lneuilly-152-23-9-75.w193-252.abo.wanadoo.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrtdegucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrtdehucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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:01:38 -0000 > -----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. 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 = memory 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). 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. Fran=E7ois-Fr=E9d=E9ric > But you're right about the bug in spinlocks. > I am going to send a patch for this. >=20 > -- > Thomas