[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: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Mon, 25 Apr 2022 15:51:36 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=du4FYpbAWINry80qew7JSN2mE9addizpxnnZcNhWFmM=; b=eQC0mJvW2dM9LKhLWsP059KUHkCTfYSiPt449FQYxLeWLicWjnd5CHo4N7/PEN/B67k8Cah5fd5gLdBljd4rGVQGwNQ8rU2E5rgafsQ4vMUVQpgNuYhH0vOsRkrSmez0nhK7a7yRLHv1TDjSUsTOTqQ/F0pQY6MvJKG2xC7AJxMqhwlR4MAGyhHfJM/DVqOnzrwJpHmKrUv62PBded7Co8a63xFenZiKHlkG/RKtRNOuLMttOHImu1kA1ShbuIDwZdIXb/aIwcFRszOXL4F4xrgv+XhyUuhbAAnqMbKSrxEjsUW6N9sM2Mh+LZmbZQnTqCVYb85QM65h9Z5NbUscvQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T3RJsEHBESslkmubEFr1N5L5hb7bFGFk1M8sOTlHr9L4RHfIvWSNHJhRnNYU/ILZ365xygV126whpj+9K0ZCldlRqPpLI8DDE588wrM8k+LxwhJmYK4nW1di4ta5fXeo5Ln8rPfdQvLsyhMpE6sMpelFbd8JbRcHqjKuAwhacBAQm+IAm/HoQjuO+xggK+mACKqipJGuH2vBjkVl5ElTRso7rSSENlLGFtLU8jvgVrwvpLo1PS62NcIGu071UOpDDzWcEeLBa/ePv2IUiEUemiUU8iA+XmjMSrzVl/pCRuFPygeiEKJNYppHs2aOc6uus0so5jgA1eszKvW1EtC3Qg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.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:51:55 +0000
- Ironport-data: A9a23:Prdj5qDahT6/3hVW/y7iw5YqxClBgxIJ4kV8jS/XYbTApDIqhDMPm jFNXD+Eb/bcYWbxKoglbNmw/E0AupODyIM2QQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHWeIdA970Ug5w7Jj39Yx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhj0 9Jj5LiraD4XBZ/Hnd4BWgdiLhlhaPguFL/veRBTsOS15mifKj7G5aUrC0s7e4oF5uxwHGdCs +QCLywAZQyCgOTwx6+nTu5rhYIoK8yD0IE34yk8i22GS6t2B8mcH80m5vcBtNs0rtpJEvvEI dIQdBJkbQjaYg0JMVASYH47tLn51ielKGUHwL6TjZU67C/d8Rxq6qSuO8HzUOyNH8EWgX/N8 woq+Ey8WHn2Lue3yzCI73atje/nhj7gVcQZE7jQ3u5nhhify3IeDDUSVECnur+ph0imQdVdJ kcIvC00osAa60iDXtT7GRqirxasvBEGXMFLO/Yn8wzLwa3Rizt1HUABRz9FLdYg5Mk/QGVz0 kfTxoy1QztyrLeSVHSRsK+Oqi+/MjQUKmlEYjIYSQwC4J/op4RbYg/zc+uP2ZWd1rXdcQwcC RjRxMTir93/VfI26pg=
- Ironport-hdrordr: A9a23:OlDAOKP/7gokycBcT1P155DYdb4zR+YMi2TDiHoddfUFSKalfp 6V98jztSWatN/eYgBEpTmlAtj5fZq6z+8P3WBxB8baYOCCggeVxe5ZjbcKrweQeBEWs9Qtr5 uIEJIOd+EYb2IK6voSiTPQe7hA/DDEytHPuQ639QYQcegAUdAF0+4WMHf4LqUgLzM2eKbRWa Dsr/Zvln6FQzA6f867Dn4KU6zqoMDKrovvZVojCwQ84AeDoDu04PqieiLolSs2Yndq+/MP4G LFmwv26uGKtOy68AbV0yv2445NkNXs59NfDIini9QTKB/rlgG0Db4RE4GqjXQQmqWC+VwqmN 7Dr1MJONly0WrYeiWPrR7ky2DboUITwk6n7WXdrWrooMT/Sj5/IdFGn5hlfhzQ7FdllM1g0Y pQtljp+KZ/PFflpmDQ9tLIXxZlmg6funw5i9MeiHRZTM83dKJRl4oC50lYea1wUB4S0LpXUd WGMfuspMq/KTihHjPkVyhUsZGRt00Ib1m7qhNogL3W79BU9EoJunfwivZv20voz6hNOqWs19 60TJiAq4s+PvP+TZgNc9vpEvHHfFAkf3r3QRGvCGWiMp07EFTwjLOyyIkJxYiRCe41Jd0J6d 78bG8=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, Apr 25, 2022 at 03:19:46PM +0200, Jan Beulich wrote:
> 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.
Thanks, LGTM.
|