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

Re: [PATCH v2 15/18] IOMMU/x86: prefill newly allocate page tables


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 14 Dec 2021 16:21:49 +0100
  • 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=BuLwTY5RZx4Bn86K/JtQgfz+h+ld0WJ0s3DFkB/c9po=; b=aB7FkO9ZcBLgJOSZsSqvwmB65N3otHdMuHlJjYLz45IMzuu/QRyuPXY2caNEmHBqURp7UBbeudt7b5HAhaqa8C47bwFmFez+gKB2cMrMbBUrzQiboNQV1IxWm6YdHI1OvgyZ3OFh8veMyQpvZbrTEKkuwsf6IbKODXlBF2+Kgn47zATRI02W/RIyLAN/e0mEVsuDhnrKZ8diZy58SnZsDIHK3siJc7NwZ8sLNajRO7GlKSmgpUx8YNDdwrDPq8auxPyo1Tc6WYxuYfGTeFYyEJqPdR0Ydz7fPHfyOUl1TbEkNbdHAW5GpWfwxh8RBuh1VKQ/SfEhg7Ge5rF7vWYGUw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IKMVl0A5sIiGx5gPzP0egGh6qzNdh+8Ln9EFBhEanqvOmADPZy85qA4EACY+7FOTG4iv0myUu/bU5Cf/um6Jk4ROXKNmHzHRkjKM3Zn8HaXR2X+1ugRNs0MjYHCc7VWyCFjmMvOBxMubhpoodzCDTYwyTgiv4gEu2h1Rf6hScarhT5amfpAe+hZU8DEoOqWic/NYvqjOXw7J6VrbxaEmJqJEF51qiJ6e5q5lrQ8lO6ZuRcIBTf4RTXG3uD8RBa7J+W33nFEglfKy5R9cdNkAmVwljXHQ5b6U5+L4B4+7pB87KKAwqV2LhoUzLw87btxl+8D82LjNd2RRQC7Ft+Y+gQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Tue, 14 Dec 2021 15:22:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.12.2021 16:15, Roger Pau Monné wrote:
> On Tue, Dec 14, 2021 at 04:05:27PM +0100, Jan Beulich wrote:
>> On 14.12.2021 15:50, Roger Pau Monné wrote:
>>> On Fri, Sep 24, 2021 at 11:54:58AM +0200, Jan Beulich wrote:
>>>> --- a/xen/drivers/passthrough/amd/iommu_map.c
>>>> +++ b/xen/drivers/passthrough/amd/iommu_map.c
>>>> @@ -116,7 +116,19 @@ static void set_iommu_ptes_present(unsig
>>>>  
>>>>      while ( nr_ptes-- )
>>>>      {
>>>> -        set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
>>>> +        ASSERT(!pde->next_level);
>>>> +        ASSERT(!pde->u);
>>>> +
>>>> +        if ( pde > table )
>>>> +            ASSERT(pde->ign0 == find_first_set_bit(pde - table));
>>>> +        else
>>>> +            ASSERT(pde->ign0 == PAGE_SHIFT - 3);
>>>
>>> You could even special case (pde - table) % 2 != 0, but this is debug
>>> only code, and it's possible a mod is more costly than
>>> find_first_set_bit.
>>
>> Not sure why I would want to special case anything that doesn't need
>> special casing. The pde == table case needs special care because there
>> find_first_set_bit() cannot be called.
> 
> Well in iommu_alloc_pgtable you already special case odd entries by
> explicitly setting the mask to 0 instead of using find_first_set_bit.

I don't consider this special casing; instead I'm unrolling the loop
4 times to simplify calculations not only for odd entries, but also
for those where index % 4 == 2. Unrolling the loop here just for the
assertions doesn't look very desirable.

Jan




 


Rackspace

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