From nobody Tue Feb 10 00:39:35 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1584086761; cv=none; d=zohomail.com; s=zohoarc; b=bSrEbbheMb3odl2+D5bJKlRDMjUytqMLb2x1x8IW6Z3kaWbzSFj3cpvGqWsV4x3DZALLp2yA6CvTFZ4b8l66Q4IEGYzM8SPhIKiOLeGqEYUryM6VcS8nnra4dh6To5WHbdQLq5dhJuKrDDxl6lrRrvbztQZJ9j1gSC+jLAfDnwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584086761; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N1oikvhnnPBqtuEY6sPzJNBYUcyfD7f9LxCZHYKti1U=; b=kgyhdyPc2zhZH6ndGx3QNsYys0/4g0MA6r5qhBi0IIOGiIz2CxljPNZvC6p+rc8tCaJpSDjQDDBeP8bgB2ezHaCQsDVMGqfBQZcrh+6p0EWD8xKSXW5ma1vxkTnypWGEtkDjWFA4pgcqeKqyIRpTxlId7lpNmW9SjuqdWcZi7Iw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 15840867615131022.3596994171135; Fri, 13 Mar 2020 01:06:01 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCfJw-0002PQ-Fd; Fri, 13 Mar 2020 08:05:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCfJv-0002P5-0F for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 08:05:27 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 621a4456-6501-11ea-bec1-bc764e2007e4; Fri, 13 Mar 2020 08:05:20 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0456CAD03; Fri, 13 Mar 2020 08:05:20 +0000 (UTC) X-Inumbo-ID: 621a4456-6501-11ea-bec1-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Fri, 13 Mar 2020 09:05:17 +0100 Message-Id: <20200313080517.28728-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200313080517.28728-1-jgross@suse.com> References: <20200313080517.28728-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 2/2] xen/spinlocks: fix placement of preempt_[dis|en]able() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In case Xen ever gains preemption support the spinlock coding's placement of preempt_disable() and preempt_enable() should be outside of the locked section. Signed-off-by: Juergen Gross --- xen/common/spinlock.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index 344981c54a..f05fb068cd 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -160,6 +160,7 @@ void inline _spin_lock_cb(spinlock_t *lock, void (*cb)(= void *), void *data) LOCK_PROFILE_VAR; =20 check_lock(&lock->debug); + preempt_disable(); tickets.head_tail =3D arch_fetch_and_add(&lock->tickets.head_tail, tickets.head_tail); while ( tickets.tail !=3D observe_head(&lock->tickets) ) @@ -171,7 +172,6 @@ void inline _spin_lock_cb(spinlock_t *lock, void (*cb)(= void *), void *data) } got_lock(&lock->debug); LOCK_PROFILE_GOT; - preempt_disable(); arch_lock_acquire_barrier(); } =20 @@ -199,10 +199,10 @@ unsigned long _spin_lock_irqsave(spinlock_t *lock) void _spin_unlock(spinlock_t *lock) { arch_lock_release_barrier(); - preempt_enable(); LOCK_PROFILE_REL; rel_lock(&lock->debug); add_sized(&lock->tickets.head, 1); + preempt_enable(); arch_lock_signal(); } =20 @@ -242,15 +242,18 @@ int _spin_trylock(spinlock_t *lock) return 0; new =3D old; new.tail++; + preempt_disable(); if ( cmpxchg(&lock->tickets.head_tail, old.head_tail, new.head_tail) !=3D old.head_tail ) + { + preempt_enable(); return 0; + } got_lock(&lock->debug); #ifdef CONFIG_DEBUG_LOCK_PROFILE if (lock->profile) lock->profile->time_locked =3D NOW(); #endif - preempt_disable(); /* * cmpxchg() is a full barrier so no need for an * arch_lock_acquire_barrier(). --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel