[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: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Wed, 16 Feb 2022 11:55:19 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=qU6uSB0HFChXFdJLtQwfaZtWxn3LHATQgu/PsztoSHg=; b=jMSioFOYQzYVNv6+i3ufsHPllwBn8twPyLGDTb7GU5rXHKoBuAl/xk9Kk2DFUt0OCzy7rLMn22zYZpGGPHZhdhkWgtsl0yyq8yc/HpNVxCt1Jn158ylXnOn53xm52MI/yDMFW1qlXJ9iZuIIn+6Se6KZBb3MSf3Tszs3Q1c3E1k/7EpTwle8nuzzqIMswLhOb8lfcN9rfq7WJuGMha8C6NylSDeIX8ry342kamxyL8A2cISW2o/66Fxzsz6HzjGJaj+w1pIED0d0Wra3dWLtoqghOD16ARZM+rp8SKqNVPaNbzeJcpwvwnG/nEIthqcDwWGlD0tdjbYSkJ9gIKST6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JzKBCaSlHdJ6AyZz4GSzyOA6/wD9Bc593FRk9WLid0P4JHh9vxeRWR4Fl4/1XYETKVCT1P240AgR1YDRUwsBuejAo2GrEsNB48azb104FyUUyU9JTTwxukkCJTP8zcu8IgHbg2k6HUb5mPI/LPec1DhnWP+urGsW41vCj2LwB90x/dJMGS0HllDvemGeHLO2WDs8nKpjfL3xsZer26JmWB+nSdevlO3tmD7VFcP/Fjcro5rSFJ4/L3dndyNGdAHFJxb7dbo6vB9bZroNn6aGbMJW2KbJwPwRWwJxWtYAduOCZDJtRvyI+xQC5NmUujZe7Uw/qbeHDBB2OUDs46tknA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 16 Feb 2022 11:55:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYIaGnBAePJgt7y0O7PyvIWQlKrKyTBxsAgAKFHwCAAHT3AIAAERWAgAACmoA=
  • Thread-topic: [PATCH v2 02/70] xen/sort: Switch to an extern inline implementation

Hi,

> On 16 Feb 2022, at 11:46, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi,
> 
> On 16/02/2022 10:44, Andrew Cooper wrote:
>> 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
> 
> Our take on Arm has always been to avoid micro-optimization when the 
> resulting code is more difficult to maintain.
> 
>> justification alone for the patch, and Bertrand's R-by is testament to this.
> 
> I am not sure why calling out that Bertrand agreed means that everyone else 
> should accept your approach.
> 
> This reminds me other series that have been blocked for a long time by you. 
> Yet you made no effort to compromise... How ironic.
> 
>> 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.
> 
> This is a more compelling reason. However, I am a bit puzzled why it took you 
> so long to come up with this reason.
> 
>> 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.
> 
> Well, this argument would have never happened if your commit message 
> contained information about BTI.

I agree that this would be nice to have in the commit message as a 
justification for the change.

Cheers
Bertrand

> 
> Instead you decided to just mention the performance part despite me objecting 
> it and requesting for a different reason in v1 (see [1]).
> 
> Anyway, I will wait for a reword of the commit message before lifting my 
> Nacked-by.
> 
> Cheers,
> 
> [1] 
> https://lore.kernel.org/xen-devel/f7bb7a08-4721-f2a8-8602-0cd1baf1f083@xxxxxxx/
> 
> -- 
> Julien Grall




 


Rackspace

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