From: Ian Jackson Subject: Re: [PATCH 1/3] libxl: ao: allow immediate completion Date: Mon, 20 Feb 2012 13:32:04 +0000 Message-ID: <20290.19284.270369.772434@mariner.uk.xensource.com> References: <20286.31877.938411.558236@mariner.uk.xensource.com> <1329504239-19999-2-git-send-email-ian.jackson@eu.citrix.com> <1329733585.3990.13.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1329733585.3990.13.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/3] libxl: ao: allow immediate completion"): > On Fri, 2012-02-17 at 18:43 +0000, Ian Jackson wrote: > > - assert(ao->in_initiator); > > + assert(ao->constructing && ao->in_initiator); > > Doing two asserts will make it clearer which condition is not satisfied > if we ever see this. Good point. I was foolishly thinking of bitfield optimisations but this code is not a hot path. > > - AO_GC; > > + EGC_INIT(ctx); > > This means that the "gc" within a function which uses this macro is now > "&egc->gc" rather than "&ao->gc". You are right, and this is wrong. > Another difference is that any function calling AO_CREATE cannot now be > called from within libxl, since it now calls LIBXL__INIT_EGC which has > this restriction. libxl_cdrom_insert does not obey this new restriction. This restriction is not new. libxl_cdrom_insert has always violated it and needs converting to the new scheme of things. The restriction is documented here in libxl_internal.h but sadly has a "outside" when it should say "inside": * All "slow" functions (includes anything that might block on a * guest or an external script) need to use the asynchronous * operation ("ao") machinery. The function should take a parameter * const libxl_asyncop_how *ao_how and must start with a call to * AO_INITIATOR_ENTRY. These functions MAY NOT be called from * outside libxl, because they can cause reentrancy callbacks. In practice I think libxl_cdrom_insert will not mind the reentrancy so the bug is latent. It doesn't take out the ctx lock, and although a callback might involve messing with the same device there is no difference between that and another process doing the same. Ian.