[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v6 08/12] libxl: ocaml: drop the ocaml heap lock before calling into libxl



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 <ian.campbell@xxxxxxxxxx>



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.