From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>, Keir Fraser <keir@xen.org>
Subject: Re: [PATCH] x86/Dom0: account for shadow/HAP allocation
Date: Fri, 27 Feb 2015 12:02:25 +0000 [thread overview]
Message-ID: <54F05CD1.6040909@citrix.com> (raw)
In-Reply-To: <54EEDCA10200007800063EF2@mail.emea.novell.com>
On 26/02/15 07:43, Jan Beulich wrote:
>>>> On 25.02.15 at 18:06, <andrew.cooper3@citrix.com> wrote:
>> On 25/02/15 14:45, Jan Beulich wrote:
>>> +static unsigned long __init dom0_paging_pages(const struct domain *d,
>>> + unsigned long nr_pages)
>>> +{
>>> + /* Copied from: libxl_get_required_shadow_memory() */
>>> + unsigned long memkb = nr_pages * (PAGE_SIZE / 1024);
>>> +
>>> + memkb = 4 * (256 * d->max_vcpus + 2 * (memkb / 1024));
>> I have recently raised a bug against Xapi for similar wrong logic when
>> calculating the size of the shadow pool.
>>
>> A per-vcpu reservation of shadow allocation is only needed if shadow
>> paging is actually in use, and even then should match
>> shadow_min_acceptable_pages() at 128 pages per vcpu.
>>
>> If HAP is in use, the only allocations from the shadow pool are for the
>> EPT/NPT tables (1% of nr_pages), IOMMU tables (another 1% of nr_pages if
>> in use), and the logdirty radix tree (substantially less than than 1% of
>> nr_pages).
>>
>> One could argue that structure such as the vmcs/vmcb should have their
>> allocations accounted against the domain, in which case a small per-vcpu
>> component would be appropriate.
>>
>> However as it currently stands, this calculation wastes 4MB of ram per
>> vcpu in shadow allocation which is not going to be used.
> But you realize that the functional change here explicitly only covers
> the shadow case - the PVH (i.e. HAP) case is effectively unchanged
> (merely correcting the mistake of not accounting for what gets
> actually allocated), and I don't intend any functional change for PVH
> (other than said bug fix) with this patch.
Ok
> Hence correcting this (i.e.
> lowering the accounted for as well as the allocated amount) as well
> as adding accounting for VMCS/VMCB (just like we account for
> struct vcpu) should be the subject of a separate patch, presumably
> by someone actively working on PVH (and then perhaps at once for
> libxc). I also think that this calculation would better become a paging
> variant specific hook if calculations differ between shadow and HAP.
That would be better, in the longrun.
~Andrew
next prev parent reply other threads:[~2015-02-27 12:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-25 14:45 [PATCH] x86/Dom0: account for shadow/HAP allocation Jan Beulich
2015-02-25 17:06 ` Andrew Cooper
2015-02-26 7:43 ` Jan Beulich
2015-02-27 12:02 ` Andrew Cooper [this message]
2015-02-27 13:21 ` Jan Beulich
2015-02-27 14:45 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54F05CD1.6040909@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.