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

Re: [Xen-devel] [PATCH] xen/typesafe: Force helpers to be always_inline


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: George Dunlap <george.dunlap@xxxxxxxxxx>
  • Date: Mon, 21 Oct 2019 12:10:39 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@xxxxxxxxxx; spf=Pass smtp.mailfrom=George.Dunlap@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Autocrypt: addr=george.dunlap@xxxxxxxxxx; prefer-encrypt=mutual; keydata= mQINBFPqG+MBEACwPYTQpHepyshcufo0dVmqxDo917iWPslB8lauFxVf4WZtGvQSsKStHJSj 92Qkxp4CH2DwudI8qpVbnWCXsZxodDWac9c3PordLwz5/XL41LevEoM3NWRm5TNgJ3ckPA+J K5OfSK04QtmwSHFP3G/SXDJpGs+oDJgASta2AOl9vPV+t3xG6xyfa2NMGn9wmEvvVMD44Z7R W3RhZPn/NEZ5gaJhIUMgTChGwwWDOX0YPY19vcy5fT4bTIxvoZsLOkLSGoZb/jHIzkAAznug Q7PPeZJ1kXpbW9EHHaUHiCD9C87dMyty0N3TmWfp0VvBCaw32yFtM9jUgB7UVneoZUMUKeHA fgIXhJ7I7JFmw3J0PjGLxCLHf2Q5JOD8jeEXpdxugqF7B/fWYYmyIgwKutiGZeoPhl9c/7RE Bf6f9Qv4AtQoJwtLw6+5pDXsTD5q/GwhPjt7ohF7aQZTMMHhZuS52/izKhDzIufl6uiqUBge 0lqG+/ViLKwCkxHDREuSUTtfjRc9/AoAt2V2HOfgKORSCjFC1eI0+8UMxlfdq2z1AAchinU0 eSkRpX2An3CPEjgGFmu2Je4a/R/Kd6nGU8AFaE8ta0oq5BSFDRYdcKchw4TSxetkG6iUtqOO ZFS7VAdF00eqFJNQpi6IUQryhnrOByw+zSobqlOPUO7XC5fjnwARAQABtCRHZW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ulZcYwbEC/a49+WvbaYUriaDLHzg9xisijHwD2 yWV8igBeg+cmwnk0mPz8tIVvwi4lICAgXob7HZiaqKnwaDXs4LiS4vdG5s/ElnE3rIc87yru 24n3ypeDZ6f5LkdqL1UNp5/0Aqbr3EiN7/ina4YVyscy9754l944kyHnnMRLVykg0v+kakj0 h0RJ5LbfLAMM8M52KIA3y14g0Fb7kHLcOUMVcgfQ3PrN6chtC+5l6ouDIlSLR3toxH8Aam7E rIFfe2Dk+lD9A9BVd2rfoHA=
  • Cc: Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, WeiLiu <wl@xxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 21 Oct 2019 11:10:47 +0000
  • Ironport-sdr: bAZC3ur0KTZ4mqnBvEZZOisixqFXck5ZIL2p1IvgFA4cF6ORHNnKC/Z6pzl7R7CbloxM1m8qXE PxQlWa8H2HQBc3aw0Ngzq1Fg1eCy7hNldMrzArb64vcAPQ/hv1ShCe9sVmQOrwH9MIvIqJqISJ mqlkygdf8EY1y0dNgrSn5W+5ClcpPMBQE2CTHw0J/ree3+PUISpd4HJATwqwDGL3dCZGAFuu4q PG1XmVvlb9q3AiryB4ByMApuctjELDHiUptslkOWsAaFE2tdlBSQOA39ZFxn3wKlROBwWwCeu9 N+Q=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Openpgp: preference=signencrypt

On 10/7/19 10:25 AM, Jan Beulich wrote:
> On 04.10.2019 19:02, George Dunlap wrote:
>> On 10/2/19 9:11 AM, Jan Beulich wrote:
>>> On 01.10.2019 22:59, Andrew Cooper wrote:
>>>> On 01/10/2019 09:38, Jan Beulich wrote:
>>>>> On 30.09.2019 21:16, Andrew Cooper wrote:
>>>>>> Clang in particular has a habit of out-of-lining these and creating 
>>>>>> multiple
>>>>>> local copies of _mfn() and mfn_x(), etc.  Override this behaviour.
>>>>> Is special casing the typesafe helpers then the right approach? The
>>>>> fundamental idea after all is to let the compiler decide. I certainly
>>>>> agree that not inlining such trivial functions despite the inline
>>>>> keyword looks far from optimal, but if there's such a general issue
>>>>> with clang, shouldn't we make "inline" expand to "always_inline"
>>>>> uniformly?
>>>>
>>>> Inline handing is a mess.
>>>>
>>>> We currently define inline to __inline__.  Undoing this results in build
>>>> failures.
>>>>
>>>> Linux currently defines inline to always_inline and they are desperately
>>>> trying to undo this (mis)behaviour.
>>>>
>>>> There are a few uses of always_inline for safety purposes (the
>>>> speculative helpers).  Most uses of always_inline look to be workarounds
>>>> for the size-of-asm bug/(mis)feature.
>>>>
>>>> In an ideal world, we wouldn't need it at all, but I definitely don't
>>>> think that taking the Linux approach is a clever move.  We definitely
>>>> have some static inlines which would better not being inline.
>>>
>>> IOW your suggested approach (at least for the foreseeable future) is to
>>> do what you do here and convert inline to always_inline as we see fit?
>>> If so, we should at least settle on some sufficiently firm criteria by
>>> which such a conversion would be justifiable.
>>>
>>> Seeing that this is primarily to help clang - did you consider
>>> introducing something like clang_inline, expanding to just inline for
>>> gcc, but always_inline for clang? This would at least provide a
>>> sufficiently easy way to undo this if a better clang-side approach can
>>> be found down the road.
>>
>> What would be the point of this?  The only reason always_inline isn't
>> necessary for gcc (if I'm following the argument) is because it so far
>> has always inlined these functions.  If it stopped inlining them, we'd
>> need to change it to always_inline anyway; so why not just say so to
>> begin with?
> 
> The point of this would be to _avoid_ using always_inline as much as
> possible. We really shouldn't fight compiler decisions more than
> absolutely necessary. Hence also my request for sufficiently firm
> criteria when to switch in the first place. Or else would could, as
> mentioned as an option elsewhere, make inline expand to always_inline
> uniformly. (Or course, even always_inline isn't a guarantee for the
> compiler to actually inline a function.)

Every time I try to compose an answer to this paragraph, I end up
writing the paragraph you responded to.  Let me try something else.

"We really shouldn't fight compiler decisions more than absolutely
necessary."

Sure.  But in this particular case, it's been determined that we want to
fight the compiler decision.  The reason for wanting it to be inline
doesn't depend on whether it's clang or gcc; we want it to be inlined
all the time no matter what.  So why go through the effort of inventing
a new thing targeted at clang?

Let's do a cost-benefits analysis of always_inline vs clang_inline.

For each future gcc version, either it will choose to inline this
function with the `inline` key word or not.

1. Use always_inline
 1a. gcc would have done inline anyway.  No cost.
 1b. gcc would not have inlined it.  always_inline takes effect and
there's no cost.
2. Use clang_inline
 2a. gcc would have done inline anyway.  No cost.
 2b. gcc doesn't inline it.  We have random bugs, a discussion, then a
patch to s/clang_inline/always_inline/g;.

IOW, I only see a cost here to 2, and no benefit.

"Hence also my request for sufficiently firm criteria when to switch in
the first place."

Having criteria describing exactly when we want to specify always_inline
would be nice.  But it doesn't change the fact that in this case, we
want it to be always inlined.

"Or else would could, as mentioned as an option elsewhere, make inline
expand to always_inline uniformly."

But you just said we don't want to fight compiler decisions more than
absolutely necessary.

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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