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

Re: [Xen-devel] [PATCH for-4.10 1/2] tools/libxc: Fix precopy_policy() to not pass a structure by value



Andrew Cooper writes ("Re: [PATCH for-4.10 1/2] tools/libxc: Fix 
precopy_policy() to not pass a structure by value"):
> On 16/10/17 16:07, Ian Jackson wrote:
> > This statement is true only if you think "the precopy callback" refers
> > to the stub generated by libxl_save_msgs_gen.
> 
> The commit is about save_callbacks.precopy_policy() specifically (and
> IMO, obviously).
> 
> Given this, the statement is true.

I don't agree.

> >   But a more natural
> > reading is that "the precopy callback" refers to the actual code which
> > implements whatever logic is required.
> >
> > In a system using libxl, that code definitely _is_ executing in a
> > separate address space.  And passing the stats by value rather than
> > reference does make it marginally easier.
> 
> There is no libxl code for any of this.

That is of course a deficiency which we hope will be remedied,
surely.  We should expect there to be libxl code.

> >> Switch the callback to passing by pointer which is far more efficient, and
> >> drop the typedef (because none of the other callback have this oddity).
> > I would like you to expand on this efficiency argument.
> 
> The two most common mechanisms are either to pass the object split
> across pre-agreed registers, or the compiler rearranges things to have a
> local stack object, pass by pointer, and have the prologue memcpy() it
> into local scope.
> 
> The resulting change in calling convention is implementation defined,
> and subject to several different code-gen options in GCC or Clang.
> 
> Therefore it is inappropriate for such an interface to exist in the
> libxenguest ABI.

I asked you to expand on an efficiency argument and instead you have
provided an argument based on calling convention.

Furthermore, the argument you are now presenting is simply wrong.

Yes, there are options in compilers which can change the calling
conventions in incompatible ways (for structs passed as arguments, as
for various other things).  But one must not pass those arguments when
expecting to link against nonconsenting libraries.

The C standard has permitted passing structs by value for a long time
now, and all the (CPU architecture, operating system) combinations we
support have a well-defined ABI doing so.  Passing structs by value is
far from unusual.

Ian.

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

 


Rackspace

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