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

Re: [PATCH v2] x86+libxl: correct p2m (shadow) memory pool size calculation


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 25 Apr 2022 15:19:46 +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=kQ1uj6j8FX4J98NPRSUhT/TpPhE1EbUt2Bdu9IlpLpA=; b=gUqA03pkAruaRbu82m+4+E9Pvkx4I93112O/002Y0PuPiRr+bMvHK4S8bA06AtCKEOdsQFw+8hV5/gOx2IHgJG7dMg1LjkMnIN8hglrwASrUkbmHTmRx/bYfyocNxPqxjlDk5QvfS901wTKHtVncpaqyxLHBJmMt51Z09TRJAdVNn4vQ5EruifuHwbhuLU+V+ef6yKMwDTAhiljzaXL7yhz03f52/YmH6aj2bHXWGLvnxXyYWskArQAAPYzlfSxW+tPFu9J9VwHtzv3lFQ5sR3b0vSHzealDv21DeWKUhBXJF09Uv6OftUltIXm9f988RVjfOzNwe22bddkCp6eryQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2Ys+a10r68eQk2aTZX8phs9kMQ9ys6H5uwwJ9sQ+FIXJAunTtc0/7PsmjxEWiub3RVhRAy0K6O22SbeB20GWlAIIv4ew0TMdqJ5cYKhuVDS19W5NMLa+ndxivuTBAnoti9RHhzpbE7yKYohdCeNaMQeW9eyGJs6/SDWvJ028XKJmlT70BHPJggjI0SP/mspg83+jUYYcK4r6rLpGXwtmauxw1aDIdOH1HQj5VxbR3sG9Epba2DxobAl8vCwwpiZvvyuXaFxRKQgvwfwk2e+ZAVsyFbBXNwypAO5oluR6FLgYav26t39pjKfrq9LakrKy6aUGAESCGxSVnX63EduvA==
  • 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>, Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 25 Apr 2022 13:19:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.04.2022 14:59, Roger Pau Monné wrote:
> On Mon, Apr 25, 2022 at 10:49:34AM +0200, Jan Beulich wrote:
>>  char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid)
>> --- a/xen/arch/x86/dom0_build.c
>> +++ b/xen/arch/x86/dom0_build.c
>> @@ -317,9 +317,12 @@ unsigned long __init dom0_paging_pages(c
>>      /* Copied from: libxl_get_required_shadow_memory() */
> 
> Could you also update the comment, maybe better would be:
> 
> /* Keep in sync with libxl__get_required_paging_memory(). */

Oh, of course.

>>      unsigned long memkb = nr_pages * (PAGE_SIZE / 1024);
>>  
>> -    memkb = 4 * (256 * d->max_vcpus + 2 * (memkb / 1024));
>> +    memkb = 4 * (256 * d->max_vcpus +
>> +                 (paging_mode_enabled(d) +
>> +                  (opt_dom0_shadow || opt_pv_l1tf_hwdom)) *
> 
> opt_pv_l1tf_hwdom is only relevant for PV guests, so maybe it would be
> best to use:
> 
> paging_mode_enabled(d) ? 1 + opt_dom0_shadow
>                        : 0 + (opt_dom0_shadow || opt_pv_l1tf_hwdom)
> 
> Or something similar.

Originally I was thinking that people simply shouldn't use the option
when Dom0 isn't PV. But meanwhile I've figured that late-hwdom may be
PV even if domain 0 is PVH. So yes.

>  Maybe placing this inside the sum will make the
> expression too complex, so we could use a separate is_shadow boolean
> to signal whether the domain will use shadow pagetables?

I think

    memkb = 4 * (256 * d->max_vcpus +
                 (is_pv_domain(d) ? opt_dom0_shadow || opt_pv_l1tf_hwdom
                                  : 1 + opt_dom0_shadow) *
                 (memkb / 1024));

is still okay-ish. Note that I've switched to is_pv_domain() to be
independent of the point in time when shadow mode would be enabled
for a PV Dom0.

Jan




 


Rackspace

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