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

Re: [PATCH v2 02/70] xen/sort: Switch to an extern inline implementation


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Wed, 16 Feb 2022 10:44:52 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9aRORfQFiFGzJowWamjkxN0EDjr88tMV2BKQBi2Mc10=; b=nBtIF566W/1LvBN7igCeZds1yIonouGG/1Rrp4FYIqpWiOXy/icTWmQnCgW+4Ow653FS7VCgLYaqLgA+2lZquMi3wZ7bTifoW03KJuefWKiBcPWofl9R4rMuL3TvFetTrcoPdnk9vHsKOjjW5eHCP84qVdWrJ9prPPSybeQMqjPMk8E+JSh9PH5PyN5EBCgqywBEo2BzD8bZ1igq1Lr7yzEF4iKXKlEyU4qg2Wd8e5NTYYDiHBwptW5qm/Eic3lwZvYk+JmUkowMxmdEU69g4wOBBE+usB/ahlt1Uc/rXa9QYWQuK3nuImzWF8Cf4qmajCwU+yBa/g64bNVNh6gwuQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MGLMsWMhMcwJ/aAScULkQ8DUwFUHWbr2QbW4xwuodf8TRmflFo5syF+ol/wTeMAxPLwadqZWLAV2q08AQ3psDrXJY7n2onb+Mw5xSngdOR/iaJ5T6NGylcAjfuAC+CGjlda0tyeg4H5HuHXeJvWVq3uo0UtRTEUHvL+OruKv4iYq14wdTI6kTsaEYqOpe/OSaH9sS0dkBi1M3+yNHOPAd9Qd7hM7DcP8xQ1tuGNonbgg85ay7LV6De6bTr7BYXbDu59Dasbpn2JYp19R77W/qQG9YaqKgBEaFBAhi6otKZMogENi+FCoyafc52oiD54e7cuxlgYeeyCVvusb1xN7bQ==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "Bertrand Marquis" <bertrand.marquis@xxxxxxx>
  • Delivery-date: Wed, 16 Feb 2022 10:45:13 +0000
  • Ironport-data: A9a23:JzL2JqqNybtmKE0Vh/QmKBAtT4peBmKhYhIvgKrLsJaIsI4StFCzt garIBmOPqmLMWTyftogO97gpkkFuJTQn9I2HQBqqCg3H3gS95uZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlZT4vE2xbuKU5NTsY0idfic5Dndx4f5fs7Rh2NQw24HnW1rlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCnaOAZD04MInSodwQbCN/GT1MYv0XxaCSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFKoZtmtt0nfyCvE+TIqYa67L+cVZzHE7gcUm8fP2O ZZCM2o1MUqojxtnE3MRM7QFs9eRvVb+YRR1pH2NpZYs2j2GpOB2+Oe0a4eEEjCQfu1Kmm6Iq 2SA+H72ajkkM9iYxSuA42ibrObFliPmW6ofDLS9sPVthTW7zGEJFAcfU1f9pPCjk1O/QPpWM Ul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8icViWSqLoGvIl VpGt5On4CL3DJVrhDQY2L1IY
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYIaGjy/wpq8SdQkKdLl3UHHKbD6yTBxwAgAKFHgCAAHT3AA==
  • Thread-topic: [PATCH v2 02/70] xen/sort: Switch to an extern inline implementation

On 16/02/2022 03:46, Stefano Stabellini wrote:
> On Mon, 14 Feb 2022, Julien Grall wrote:
>> On 14/02/2022 12:50, Andrew Cooper wrote:
>>> There are exactly 3 callers of sort() in the hypervisor.  Callbacks in a
>>> tight
>>> loop like this are problematic for performance, especially with Spectre v2
>>> protections, which is why extern inline is used commonly by libraries.
>>>
>>> Both ARM callers pass in NULL for the swap function, and while this might
>>> seem
>>> like an attractive option at first, it causes generic_swap() to be used,
>>> which
>>> forced a byte-wise copy.  Provide real swap functions so the compiler can
>>> optimise properly, which is very important for ARM downstreams where
>>> milliseconds until the system is up matters.
>> Did you actually benchmark it? Both those lists will have < 128 elements in
>> them. So I would be extremely surprised if you save more than a few hundreds
>> microseconds with this approach.
>>
>> So, my opinion on this approach hasn't changed. On v1, we discussed an
>> approach that would suit both Stefano and I. Jan seemed to confirm that would
>> also suit x86.
> This patch series has become 70 patches and for the sake of helping
> Andrew move forward in the quickest and most painless way possible, I
> append the following using generic_swap as static inline.
>
> Julien, Bertrand, is that acceptable to you?
>
> Andrew, I know this is not your favorite approach but you have quite a
> lot of changes to handle -- probably not worth focussing on one detail
> which is pretty minor?

It's not pretty minor.  My version really is the best thing for ARM.

The perf improvement alone, marginal as it may be in practice, is
justification alone for the patch, and Bertrand's R-by is testament to this.

But the reasons why getting rid the swap functions is important for
CET-IBT on x86 are exactly the same as why getting rid of them on ARM
will be important for BTI support.  A tagged function doing an arbitrary
bytewise swap from two parameters controlled by the third is far more
valuable to an attackers gadget library than a typical function.

i.e. this proposed intermediary, if it compiles, is just busywork which
someone else is going to have to revert in the future, along with having
this argument again.

~Andrew

 


Rackspace

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