[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:03:35 +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=SIzG/InMionDYyknx2veYU+SReoQM3RQYUFC15PQg4M=; b=fzIliewcBLpcIhXOFWN7L05uwI8+v40F+gkYKqscRAFKTagRdCIRYRH/pF9pzGf5K1k5mxuL7Bc/n8fhQxcl1I8rPsKiF1ZFtydyIh1ioVHAoUvwPEjhORzf04dPyB2HtreOHhYsUQ53TSEQaHyzuAmmGNFH1ZTLE3I2tkQbpL8XDEm49A1uhaQoIkfNciBSert/0AVRw4R7PZ93LrTmVcWmJARaZfCCYEaOr9N49usdAuIhfngjhZkXfVA+Vu2iZJTzeBskfJxm7hCQV6W+lqxgztDrJbL/WZXE+UPtXQSeQeUg+zdmwGGIHnDh45v+cPw7lcbjQ4gFrI5ShH3rKg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gyViGbAy9CHoyJVnL/OTCv76F3eVvOa86rZFU9hOzxiSAEcjoSvfu9fThTwVUwUokIRdEkibzq8Gqcuea3Zl9D8rvmC0frGlIJVFRz9jMunCojHpCceUhXMpi88GYcoUad8IEwV+fLGNfeD6XOsjLJQPAsagYk7meqji57XjPRoTliJEoJq+WmF6XEmPNaLUyDfKB7YprxqUVQoPm7kLDbqTJnwGNvr5PYr1Uz+7cbGiKxbDHis9tbd6ncef04/vYzHFISH+uA4FzfGoOjszRuKo3UTQGhZlx03XnkIfBG2on3YrEUrKtbVoncd3QisGWRB23AGrQnUHNZnWVaxO5Q==
  • 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:03:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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"),
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®.