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

Re: [PATCH for-4.17 1/2] docs: Document the minimal requirement of static heap





On 14/10/2022 10:31, Henry Wang wrote:
Hi Julien,

Hi,


-----Original Message-----
From: Julien Grall <julien@xxxxxxx>
+Users should be mindful that the static heap should at least satisfy the
+allocation of the P2M maps for all guests. Currently, the minimal
requirement
+of per-domain P2M pages pool is in-sync with function
+libxl__get_required_paging_memory() (for xl-created domUs) and
+domain_p2m_pages() (for dom0less domUs), that is, 1MB per vCPU,
plus
4KiB per
+MiB of RAM for the P2M map, and plus 512KiB to cover extended
regions.

I think this wording is OK if the feature is a tech preview. However, if
this is security supported, we need to provide some more details about
the size.

In particular, this doesn't tell a user how they can find the size that
would fit them. Can this be decided with a formula?
My feeling of the formula would be:

Total heap size needed per guest =  1MB * num_guest_vcpu +
      4KB * guest_ram_size_in_mb + 512KB +
      the memory allocated from heap by xzalloc/xzalloc_array for
        various uses
      for example alloc_domain_struct(), d->shared_info, evtchn_bucket, etc.

There are also some pages allocated using alloc_{xen,dom}heap_pages().
We also need to take into account runtime allocation done by some
hypercalls (I can't remember which one) or subsystem like OPTee.

In addition to that, you also have memory for the system. E.g
frametables, Xen page-tables, various driver allocations...


Is this formula somehow make sense to you? I think we need to have a
rough estimation of the last part (boot time allocation) though.

That's going to be hard. It will vary depending on your system and this
could change in the future as we add more features. For instance, I
expect the PCI passthrough will need some memory to keep track of all
the devices.

I am worry the formula will become complex. Ideally we need to have a
very simple formula. If that's not possible, then we need to provide a
way for the user to estimate it at runtime (like what I suggested before).

I agree, I think the simple formula can only be achieved is we have an
estimation of the worst case scenario of those scattered memory usages.
I remember I once had a try so let me try to find the results back that time...

I am also very interested in the method that you proposed to provide a
mechanism for users to get the system memory allocation at runtime. But
IIUC this needs some work in another series. Could you please confirm if I
am understanding correctly? Or probably Xen has some mechanisms that
I am likely unaware? Thanks!

It will depend the way you account memory statically allocated to domains in Xen.

We already provide the total amount of memory in the system and how much is free. The values can be retrieved using ``xl info``.

 * When not allocated, is this considered free or used?
 * Are they included in the total memory?

If the answer is no for both (possibly just one), then we will need to provide extra hypercalls to expose the size of the xenheap and how much is free.

Cheers,

--
Julien Grall



 


Rackspace

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