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

Re: [PATCH v5 08/15] IOMMU/x86: prefill newly allocate page tables


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 1 Jun 2022 15:17:41 +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=sM2fFa2IAObPD+hod78iFnVgnTcoQ+gaVMhdkgBq2aQ=; b=N8zWE3kR6yDGQxvT/5h0RTjhJwJiQUaeF8Lw62C7ac3cU0Ss7QoV8IEvW1qkgu4657/JCEq2uArgcDM50CqTFX3iDsbfwWIdhGStSfdWpYB/3B/ce24Dxjvv0u0RcH+wp84gr6XVYv5CXcGUduKk7G5IvAj9+FkIy0aBzgkwlJxMNuEjrrmVflJG2sS0ZS0hSXSqB1z4EBwmQh4Ud91ksg9laSzg1YPJVwdsjroJsufyGIO7sVV/8hJq2ufVxjv4bqXP61ZMpKvacEOHq55tFgkshaJN5jjQ7KMCC6fXWnG8d++xleIrjYiibaab3adiVDe5SAiEjcFa2EenHp7qnA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S1ONOQ5EU5k0up1ibaycvbszqVF3O+AQxSx2iw5tWzxRnBEpURqbGe5mQrjrc4sejcb8Gs1fMmmROJ4QRPiQOqOZUa9K6ZcTpKi8AHXSomaHQUUWKAPl48kWSzQj0Zu+V2BQNMAGCWpmKTZeU5HlQ0/DcDI9j5V6jpK4nKwHL1OqYfYUkuVNAHrKKpwJU+0ZXRKqN3dft5kD1vH8dFNjm6Y5lASR1hksz8Xvmroxe/6XLo2y2T+jaZH9pc9Bstxw4ddxnScuDgtPAwAiM3Iu5lxW1+ywVFYX3Jk93z4INxgQ6w+zMyhb22jc5J8bcXCT9fHzQ7zTa4GJbGwjmWZm6A==
  • 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>
  • Delivery-date: Wed, 01 Jun 2022 13:17:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.06.2022 14:59, Roger Pau Monné wrote:
> On Fri, May 27, 2022 at 01:17:35PM +0200, Jan Beulich wrote:
>> Page tables are used for two purposes after allocation: They either
>> start out all empty, or they are filled to replace a superpage.
>> Subsequently, to replace all empty or fully contiguous page tables,
>> contiguous sub-regions will be recorded within individual page tables.
>> Install the initial set of markers immediately after allocation. Make
>> sure to retain these markers when further populating a page table in
>> preparation for it to replace a superpage.
>>
>> The markers are simply 4-bit fields holding the order value of
>> contiguous entries. To demonstrate this, if a page table had just 16
>> entries, this would be the initial (fully contiguous) set of markers:
>>
>> index  0 1 2 3 4 5 6 7 8 9 A B C D E F
>> marker 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0
>>
>> "Contiguous" here means not only present entries with successively
>> increasing MFNs, each one suitably aligned for its slot, and identical
>> attributes, but also a respective number of all non-present (zero except
>> for the markers) entries.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
> 
> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

>> @@ -538,11 +539,12 @@ int iommu_free_pgtables(struct domain *d
>>      return 0;
>>  }
>>  
>> -struct page_info *iommu_alloc_pgtable(struct domain_iommu *hd)
>> +struct page_info *iommu_alloc_pgtable(struct domain_iommu *hd,
>> +                                      uint64_t contig_mask)
>>  {
>>      unsigned int memflags = 0;
>>      struct page_info *pg;
>> -    void *p;
>> +    uint64_t *p;
>>  
>>  #ifdef CONFIG_NUMA
>>      if ( hd->node != NUMA_NO_NODE )
>> @@ -554,7 +556,29 @@ struct page_info *iommu_alloc_pgtable(st
>>          return NULL;
>>  
>>      p = __map_domain_page(pg);
>> -    clear_page(p);
>> +
>> +    if ( contig_mask )
>> +    {
>> +        /* See pt-contig-markers.h for a description of the marker scheme. 
>> */
>> +        unsigned int i, shift = find_first_set_bit(contig_mask);
>> +
>> +        ASSERT((CONTIG_LEVEL_SHIFT & (contig_mask >> shift)) == 
>> CONTIG_LEVEL_SHIFT);
>> +
>> +        p[0] = (CONTIG_LEVEL_SHIFT + 0ull) << shift;
>> +        p[1] = 0;
>> +        p[2] = 1ull << shift;
>> +        p[3] = 0;
>> +
>> +        for ( i = 4; i < PAGE_SIZE / 8; i += 4 )
> 
> FWIW, you could also use sizeof(*p) instead of hardcoding 8.

Indeed. Changed.

Jan




 


Rackspace

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