From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: Bit spinlocks in DPDK Date: Fri, 20 Dec 2013 16:39:05 +0100 Message-ID: <201312201639.05277.thomas.monjalon@6wind.com> References: <6895EAE0CA8DEE40B92D7CA88BB521F332BA572E6B@HQ1-EXCH02.corp.brocade.com> <4656219.tgqzelRNOJ@x220> <01d001cef375$7167e300$5437a900$@com> Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: dev-VfR2kkLFssw@public.gmane.org To: "=?iso-8859-1?q?Fran=E7ois-Fr=E9d=E9ric?= Ozog" Return-path: In-Reply-To: <01d001cef375$7167e300$5437a900$@com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Hello, 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. Using lock prefix is lighter than using memory barrier and have the same=20 effects. But you're right about the bug in spinlocks. I am going to send a patch for this. =2D-=20 Thomas