mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/shim: modify shim_mem parameter behaviour
shim_mem will now account for both the memory used by the hypervisor loaded in memory and the free memory slack given to the shim for runtime usage. From experimental testing it seems like the total amount of MiB used by the shim (giving it ~1MB of free memory for runtime) is: memory/113 + 20 Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
This commit is contained in:
1 parent
29dd3142bf
commit
9d60bc96be
3 files changed
+29
-28
No files matched your search
@@ -1461,16 +1461,17 @@ constructed into a plain unprivileged PV domain.
|
||||
### shim\_mem (x86)
|
||||
> `= List of ( min:<size> | max:<size> | <size> )`
|
||||
|
||||
Set the amount of memory that xen-shim reserves for itself. Only has effect
|
||||
if pv-shim mode is enabled.
|
||||
Set the amount of memory that xen-shim uses. Only has effect if pv-shim mode is
|
||||
enabled. Note that this value accounts for the memory used by the shim itself
|
||||
plus the free memory slack given to the shim for runtime allocations.
|
||||
|
||||
* `min:<size>` specifies the minimum amount of memory. Ignored if greater
|
||||
than max. Default: 10M.
|
||||
* `max:<size>` specifies the maximum amount of memory. Default: 128M.
|
||||
than max.
|
||||
* `max:<size>` specifies the maximum amount of memory.
|
||||
* `<size>` specifies the exact amount of memory. Overrides both min and max.
|
||||
|
||||
By default, 1/16th of total HVM container's memory is reserved for xen-shim
|
||||
with minimum amount being 10MB and maximum amount 128MB.
|
||||
By default, the amount of free memory slack given to the shim for runtime usage
|
||||
is 1MB.
|
||||
|
||||
### rcu-idle-timer-period-ms
|
||||
> `= <integer>`
|
||||
|
||||
@@ -290,17 +290,9 @@ unsigned long __init dom0_compute_nr_pages(
|
||||
* for things like DMA buffers. This reservation is clamped to a
|
||||
* maximum of 128MB.
|
||||
*/
|
||||
if ( nr_pages == 0 )
|
||||
{
|
||||
uint64_t rsvd = min(avail / 16, 128UL << (20 - PAGE_SHIFT));
|
||||
if ( pv_shim )
|
||||
{
|
||||
rsvd = pv_shim_mem(avail);
|
||||
printk("Reserved %lu pages for xen-shim\n", rsvd);
|
||||
|
||||
}
|
||||
nr_pages = -rsvd;
|
||||
}
|
||||
if ( !nr_pages )
|
||||
nr_pages = -(pv_shim ? pv_shim_mem(avail)
|
||||
: min(avail / 16, 128UL << (20 - PAGE_SHIFT)));
|
||||
|
||||
/* Negative specification means "all memory - specified amount". */
|
||||
if ( (long)nr_pages < 0 ) nr_pages += avail;
|
||||
|
||||
+19
-11
@@ -57,9 +57,8 @@ static long pv_shim_grant_table_op(unsigned int cmd,
|
||||
unsigned int count);
|
||||
|
||||
/*
|
||||
* By default, 1/16th of total HVM container's memory is reserved for xen-shim
|
||||
* with minimum amount being 10MB and maximum amount 128MB. Some users may wish
|
||||
* to tune this constants for better memory utilization. This can be achieved
|
||||
* By default give the shim 1MB of free memory slack. Some users may wish to
|
||||
* tune this constants for better memory utilization. This can be achieved
|
||||
* using the following xen-shim's command line option:
|
||||
*
|
||||
* shim_mem=[min:<min_amt>,][max:<max_amt>,][<amt>]
|
||||
@@ -71,8 +70,8 @@ static long pv_shim_grant_table_op(unsigned int cmd,
|
||||
* (overrides both min and max)
|
||||
*/
|
||||
static uint64_t __initdata shim_nrpages;
|
||||
static uint64_t __initdata shim_min_nrpages = 10UL << (20 - PAGE_SHIFT);
|
||||
static uint64_t __initdata shim_max_nrpages = 128UL << (20 - PAGE_SHIFT);
|
||||
static uint64_t __initdata shim_min_nrpages;
|
||||
static uint64_t __initdata shim_max_nrpages;
|
||||
|
||||
static int __init parse_shim_mem(const char *s)
|
||||
{
|
||||
@@ -91,15 +90,24 @@ custom_param("shim_mem", parse_shim_mem);
|
||||
|
||||
uint64_t pv_shim_mem(uint64_t avail)
|
||||
{
|
||||
uint64_t rsvd = min(avail / 16, shim_max_nrpages);
|
||||
if ( !shim_nrpages )
|
||||
{
|
||||
shim_nrpages = max(shim_min_nrpages,
|
||||
total_pages - avail + (1UL << (20 - PAGE_SHIFT)));
|
||||
if ( shim_max_nrpages )
|
||||
shim_max_nrpages = min(shim_nrpages, shim_max_nrpages);
|
||||
}
|
||||
|
||||
if ( shim_nrpages )
|
||||
return shim_nrpages;
|
||||
if ( total_pages - avail > shim_nrpages )
|
||||
panic("pages used by shim > shim_nrpages (%#lx > %#lx)",
|
||||
total_pages - avail, shim_nrpages);
|
||||
|
||||
if ( shim_min_nrpages <= shim_max_nrpages )
|
||||
rsvd = max(rsvd, shim_min_nrpages);
|
||||
shim_nrpages -= total_pages - avail;
|
||||
|
||||
return rsvd;
|
||||
printk("shim used pages %#lx reserving %#lx free pages\n",
|
||||
total_pages - avail, shim_nrpages);
|
||||
|
||||
return shim_nrpages;
|
||||
}
|
||||
|
||||
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER| \
|
||||
|
||||