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

Re: [PATCH] x86/iommu: fix wrong iterator type in arch_iommu_hwdom_init()


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 10 May 2023 12:04:39 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=Ynexq2RV1+AMXVOAi5/6sOtizw/fq6DNVmCMx2qfSX0=; b=blFM4nMitjnN4vnuxwGjcUIEaxll10oJh5M5wcqWzskxGTQNhY3gT4SQVK2h9N5AFD3NPlIqN6LMSCKtva9qZXsR8Yas3QydslH+S5oQ0I5A/TE5imwRjt/mKG8d0L0L1OcD4+uj310e5ueE7+tdzRzJJsSsVX1aELSmiLtPeIlx1VKWovZoTFVOjE9WZ33A4G0A+YSAxK7JCojOlEKhBLYB5efFG9LQQ8MfTV8umlSgZ6f/QrxKAuhL5ySUMREFxnPACj+5eEm3m3q3K+5399UgMTKbw6qZUus8/d5JE37kYk4TwqIOLFIQw5snXz1TidjFiBVoNTb4MQTiBgo2Qw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vah0/qIgRCN9s7awYXgkwPrc2JScNtMeKRTJgf6vVxMnqxNfnb54MzGMewTIFfiLB6xB3NPSJSrlRXglNMH7/8bMrOKcpa2hOEawBq4FDKb3mAwyJaiXfAjAqjKiElr4EdPzYtVv8lpEutFthYOOdkTMNQO6dc41lAMTvlP5Ofi5tIM268hSPATB73HA7VmV2Z65P/+lOugnNA7btKhI5htmi3m5ugH//38zqV129rDPu96RmaIdClIOEg1Wmg62cISGiaeQ/wnL8gUSA1ZwObVXDKpspb+/RfBSPtLV/9TOaw/XwWuvlGEWoroq5Rfko9IBakP7aG3Xkef10UyjKw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 10 May 2023 10:04:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 10.05.2023 12:03, Jan Beulich wrote:
> On 10.05.2023 10:32, Roger Pau Monné wrote:
>> On Tue, May 09, 2023 at 06:25:05PM +0200, Jan Beulich wrote:
>>> On 09.05.2023 13:03, Roger Pau Monne wrote:
>>>> The 'i' iterator index stores a pdx, not a pfn, and hence the initial
>>>> assignation of start (which stores a pfn) needs a conversion from pfn
>>>> to pdx.
>>>
>>> Strictly speaking: Yes. But pdx compression skips the bottom MAX_ORDER
>>> bits, so ...
>>
>> Oh, that wasn't obvious to me.
>>
>>>> --- a/xen/drivers/passthrough/x86/iommu.c
>>>> +++ b/xen/drivers/passthrough/x86/iommu.c
>>>> @@ -406,7 +406,7 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain 
>>>> *d)
>>>>       */
>>>>      start = paging_mode_translate(d) ? PFN_DOWN(MB(1)) : 0;
>>>
>>> ... with this, ...
>>>
>>>> -    for ( i = start, count = 0; i < top; )
>>>> +    for ( i = pfn_to_pdx(start), count = 0; i < top; )
>>>
>>> ... this is an expensive identity transformation. Could I talk you into
>>> adding
>>>
>>>     ASSERT(start == pfn_to_pdx(start));
>>>
>>> instead (or the corresponding BUG_ON() if you'd prefer that, albeit then
>>> the expensive identity transformation will still be there even in release
>>> builds; not that it matters all that much right here, but still)?
>>
>> So far the value of start is not influenced by hardware, so having an
>> assert should be fine.
>>
>> Given that the assignation is just done once at the start of the loop
>> I don't see it being that relevant to the performance of this piece of
>> code TBH, the more that we do a pdx_to_pfn() for each loop
>> iteration, so my preference would be to use the proposed change.
> 
> Well, okay, but then please with the description also "softened" a
> little (it isn't really "needs", but e.g. "better would undergo"),

And in the title then perhaps s/fix wrong/adjust/.

Jan

> alongside ...
> 
>>> In any event, with no real bug fixed (unless I'm overlooking something),
>>> I would suggest to drop the Fixes: tag.
>>
>> Right, I could drop that.
> 
> ... this.
> 
> Jan
> 




 


Rackspace

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