From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] spinlock: improve spin_is_locked() for recursive locks Date: Thu, 24 Mar 2016 05:30:44 -0600 Message-ID: <56F3DDF402000078000E008B@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF6C15EF4.1__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj3TT-0006RK-VI for xen-devel@lists.xenproject.org; Thu, 24 Mar 2016 11:30:48 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartF6C15EF4.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Recursive locks know their current owner, and since we use the function solely to determine whether a particular lock is being held by the current CPU (which so far has been an imprecise check), make actually check the owner for recusrively acquired locks. Signed-off-by: Jan Beulich --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -188,7 +188,9 @@ void _spin_unlock_irqrestore(spinlock_t int _spin_is_locked(spinlock_t *lock) { check_lock(&lock->debug); - return lock->tickets.head !=3D lock->tickets.tail; + return lock->recurse_cpu =3D=3D SPINLOCK_NO_CPU + ? lock->tickets.head !=3D lock->tickets.tail + : lock->recurse_cpu =3D=3D smp_processor_id(); } =20 int _spin_trylock(spinlock_t *lock) --=__PartF6C15EF4.1__= Content-Type: text/plain; name="spin-is-locked.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="spin-is-locked.patch" spinlock: improve spin_is_locked() for recursive locks=0A=0ARecursive = locks know their current owner, and since we use the function=0Asolely to = determine whether a particular lock is being held by the=0Acurrent CPU = (which so far has been an imprecise check), make actually=0Acheck the = owner for recusrively acquired locks.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/common/spinlock.c=0A+++ b/xen/common/spi= nlock.c=0A@@ -188,7 +188,9 @@ void _spin_unlock_irqrestore(spinlock_t=0A = int _spin_is_locked(spinlock_t *lock)=0A {=0A check_lock(&lock->debug);= =0A- return lock->tickets.head !=3D lock->tickets.tail;=0A+ return = lock->recurse_cpu =3D=3D SPINLOCK_NO_CPU=0A+ ? lock->tickets.head= !=3D lock->tickets.tail=0A+ : lock->recurse_cpu =3D=3D = smp_processor_id();=0A }=0A =0A int _spin_trylock(spinlock_t *lock)=0A --=__PartF6C15EF4.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__PartF6C15EF4.1__=--