From nobody Tue Feb 10 06:26:06 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=1583303591; cv=none; d=zohomail.com; s=zohoarc; b=PLFkXP6hYnerXWBHd0mKGRA3nWnwXwYHwJs58q0QZVaXYXdv35kdSqKFE3lKucaFD+Ci2S53CTn5re8c600BGmDWJ5uBdFTrxCQDr+KwGn++P9Yh91G/wP6Zbk8mPU+KLMjgz/k4e1Labno5vu2rNPX48fm9INTz7kKWvXID7gU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583303591; 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=V+bU861sEY0YBb8GAYT73OJ9HUtGADtpEXrJsN3ivHw=; b=ViWNedkFZtJhVkMDHUS0+nyg+xVi3dDWlGh+AlM2mAbU+DzvEghUqlTXBsFdEfqMz646ouK8L/Vdab8MuS5wiMZwQG+dqc/0YYuIXfIGblUGZiWai328cNNkcjPaVzG2zRpW/xSRlJaDmVey8TRD/MivtNIv4Weey69qma2qnSg= 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 1583303591245914.304454057511; Tue, 3 Mar 2020 22:33:11 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9Na9-0001yf-NS; Wed, 04 Mar 2020 06:32:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9Na9-0001yV-6i for xen-devel@lists.xenproject.org; Wed, 04 Mar 2020 06:32:37 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e4a16732-5de1-11ea-90c4-bc764e2007e4; Wed, 04 Mar 2020 06:32:17 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1F326B265; Wed, 4 Mar 2020 06:32:16 +0000 (UTC) X-Inumbo-ID: e4a16732-5de1-11ea-90c4-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 4 Mar 2020 07:32:12 +0100 Message-Id: <20200304063212.20843-7-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200304063212.20843-1-jgross@suse.com> References: <20200304063212.20843-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 6/6] xen/rcu: add per-lock counter in debug builds 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" Add a lock specific counter to rcu read locks in debug builds. This allows to test for matching lock/unlock calls. Signed-off-by: Juergen Gross --- xen/include/xen/rcupdate.h | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/xen/include/xen/rcupdate.h b/xen/include/xen/rcupdate.h index 9f6d420898..44a35a809a 100644 --- a/xen/include/xen/rcupdate.h +++ b/xen/include/xen/rcupdate.h @@ -40,17 +40,28 @@ #define __rcu =20 #ifndef NDEBUG +/* * Lock type for passing to rcu_read_{lock,unlock}. */ +struct _rcu_read_lock { + atomic_t cnt; +}; +typedef struct _rcu_read_lock rcu_read_lock_t; +#define DEFINE_RCU_READ_LOCK(x) rcu_read_lock_t x =3D { .cnt =3D ATOMIC_IN= IT(0) } +#define RCU_READ_LOCK_INIT(x) atomic_set(&(x)->cnt, 0) + DECLARE_PER_CPU(unsigned int, rcu_lock_cnt); =20 -static inline void rcu_quiesce_disable(void) +static inline void rcu_quiesce_disable(rcu_read_lock_t *lock) { this_cpu(rcu_lock_cnt)++; + atomic_inc(&lock->cnt); arch_lock_acquire_barrier(); } =20 -static inline void rcu_quiesce_enable(void) +static inline void rcu_quiesce_enable(rcu_read_lock_t *lock) { arch_lock_release_barrier(); + ASSERT(atomic_read(&lock->cnt)); + atomic_dec(&lock->cnt); this_cpu(rcu_lock_cnt)--; } =20 @@ -60,8 +71,17 @@ static inline bool rcu_quiesce_allowed(void) } =20 #else -static inline void rcu_quiesce_disable(void) { } -static inline void rcu_quiesce_enable(void) { } +/* + * Dummy lock type for passing to rcu_read_{lock,unlock}. Currently exists + * only to document the reason for rcu_read_lock() critical sections. + */ +struct _rcu_read_lock {}; +typedef struct _rcu_read_lock rcu_read_lock_t; +#define DEFINE_RCU_READ_LOCK(x) rcu_read_lock_t x +#define RCU_READ_LOCK_INIT(x) + +static inline void rcu_quiesce_disable(rcu_read_lock_t *lock) { } +static inline void rcu_quiesce_enable(rcu_read_lock_t *lock) { } static inline bool rcu_quiesce_allowed(void) { return true; @@ -88,15 +108,6 @@ struct rcu_head { int rcu_pending(int cpu); int rcu_needs_cpu(int cpu); =20 -/* - * Dummy lock type for passing to rcu_read_{lock,unlock}. Currently exists - * only to document the reason for rcu_read_lock() critical sections. - */ -struct _rcu_read_lock {}; -typedef struct _rcu_read_lock rcu_read_lock_t; -#define DEFINE_RCU_READ_LOCK(x) rcu_read_lock_t x -#define RCU_READ_LOCK_INIT(x) - /** * rcu_read_lock - mark the beginning of an RCU read-side critical section. * @@ -125,7 +136,7 @@ typedef struct _rcu_read_lock rcu_read_lock_t; */ static inline void rcu_read_lock(rcu_read_lock_t *lock) { - rcu_quiesce_disable(); + rcu_quiesce_disable(lock); } =20 /** @@ -136,7 +147,7 @@ static inline void rcu_read_lock(rcu_read_lock_t *lock) static inline void rcu_read_unlock(rcu_read_lock_t *lock) { ASSERT(!rcu_quiesce_allowed()); - rcu_quiesce_enable(); + rcu_quiesce_enable(lock); } =20 /* --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel