From: Wei Liu Subject: Re: [PATCH v2 16/18] libxl: introduce libxl_userdata_unlink Date: Wed, 3 Sep 2014 15:10:10 +0100 Message-ID: <20140903141009.GC16937@zion.uk.xensource.com> References: <1406744639-28782-17-git-send-email-wei.liu2@citrix.com> <1409105819.28009.82.camel@citrix.com> <20140828115043.GN13165@zion.uk.xensource.com> <1409250031.21481.25.camel@citrix.com> <20140828190448.GR13165@zion.uk.xensource.com> <1409254299.21481.36.camel@citrix.com> <20140828202746.GA7189@zion.uk.xensource.com> <1409258644.21481.49.camel@citrix.com> <20140829103759.GA7009@zion.uk.xensource.com> <1409746346.20794.10.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1409746346.20794.10.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: ian.jackson@eu.citrix.com, Wei Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org For the record, here is summary of the face-2-face discussion Ian and I had. The lock proposed in patch 2 should be renamed to "domain-data-lock" to avoid making the false impression that it's related to libxl-json data. For any specific application, it should hold a lock to protect its own userdata if it cares, to protect against r-m-w by other threads. With the introduction of libxl-json data, libxl becomes an application of libxl itself, in the sense that libxl now does r-m-w to libxl-json data internally. Hence it needs a lock (LockA). The said lock, proposed in patch 2, is used to lock all types of user data related to a specified domain. It protects userdata against domain destruction (LockB). I reused the lock in patch 2 as the application data lock for libxl-json data. The lock serves two purposes: 1. to protect against r-m-w to libxl-json data 2. to protect against domain destruction This double-duty lock is what confuses most. In theory LockA and LockB can be different locks but there isn't much benefit in doing so in terms of protecting libxl-json data. In general, locking hierarchy should be application userdata lock (if any) ---- (inside libxl) libxl domain data lock ... libxl domain data unlock ---- application userdata unlock In the case of protecting libxl-json data, the application userdata lock is the same one as libxl domain data lock, so the locking hierarchy is preserved. Wei.