### 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>`
* 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;
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>]
* (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)
{
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 ( total_pages - avail > shim_nrpages )
+ panic("pages used by shim > shim_nrpages (%#lx > %#lx)",
+ total_pages - avail, shim_nrpages);
- if ( shim_nrpages )
- return shim_nrpages;
+ shim_nrpages -= total_pages - avail;
- if ( shim_min_nrpages <= shim_max_nrpages )
- rsvd = max(rsvd, shim_min_nrpages);
+ printk("shim used pages %#lx reserving %#lx free pages\n",
+ total_pages - avail, shim_nrpages);
- return rsvd;
+ return shim_nrpages;
}
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER| \