From: Ian Campbell Subject: Re: [PATCH v6 08/12] libxl: ocaml: drop the ocaml heap lock before calling into libxl Date: Wed, 27 Nov 2013 13:56:56 +0000 Message-ID: <1385560616.30237.7.camel@kazak.uk.xensource.com> References: <1385507713-347-1-git-send-email-rob.hoes@citrix.com> <1385552627.23112.173.camel@kazak.uk.xensource.com> <360717C0B01E6345BCBE64B758E22C2D197EDE@AMSPEX01CL03.citrite.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <360717C0B01E6345BCBE64B758E22C2D197EDE@AMSPEX01CL03.citrite.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Rob Hoes Cc: Ian Jackson , Dave Scott , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2013-11-27 at 13:49 +0000, Rob Hoes wrote: > > > -static libxl_asyncop_how *aohow_val(value async, libxl_asyncop_how > > > *ao_how) > > > +static libxl_asyncop_how *aohow_val(value async) > > > { > > > CAMLparam1(async); > > > + libxl_asyncop_how *ao_how = NULL; > > > > > > if (async != Val_none) { > > > + libxl_asyncop_how *ao_how = malloc(sizeof(*ao_how)); > > > ao_how->callback = async_callback; > > > ao_how->u.for_callback = (void *) Some_val(async); > > > - CAMLreturnT(libxl_asyncop_how *, ao_how); > > > } > > > - else > > > - CAMLreturnT(libxl_asyncop_how *, NULL); > > > + > > > + CAMLreturnT(libxl_asyncop_how *, ao_how); > > > } > > > > > > value stub_libxl_domain_create_new(value ctx, value domain_config, > > > value async, value unit) @@ -411,7 +420,7 @@ value > > stub_libxl_domain_create_new(value ctx, value domain_config, value async, > > > int ret; > > > libxl_domain_config c_dconfig; > > > uint32_t c_domid; > > > - libxl_asyncop_how ao_how; > > > + libxl_asyncop_how *ao_how; > > > > These changes seem to have something (subtle) to do with the lifecycle of > > the ao_how rather than any of the locking stuff which is the meat of this > > change? Does the ao_how need to be dynamically allocated rather than stack > > based for some reason? > > > > If this relates the locking stuff can we get a description in the commit > > message please. > > This fall into the "copying ocaml values to C before dropping the > ocaml lock" category: it avoids calling the aohow_val function inside > the argument list of the libxl functions, which are called without the > ocaml lock. I see, I'd have done it with stack_ao_how and *ao_how as the return value rather than dynamic allocation but OK. Acked-by: Ian Campbell