[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/3] x86/pvh: use max_pdx to calculate the paging memory usage
nr_pages doesn't take into account holes or MMIO regions, and underestimates the amount of memory needed for paging. Be on the safe side and use max_pdx instead. Note that both cases are just approximations, but using max_pdx yields a number of free pages after Dom0 build always greater than the minimum reserve (either 1/16 of memory or 128MB, whatever is smaller). Without this patch on a 16GB box the amount of free memory after building Dom0 without specifying any dom0_mem parameter would be 122MB, with this patch applied the amount of free memory after Dom0 build is 144MB, which is greater than the reserved 128MB. In order to avoid having to calculate the same value twice, add a local variable to store it. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- --- xen/arch/x86/dom0_build.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index c997f5e6f5..e2be70c33f 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -241,6 +241,7 @@ unsigned long __init dom0_compute_nr_pages( { nodeid_t node; unsigned long avail = 0, nr_pages, min_pages, max_pages; + unsigned long paging_pgs = dom0_paging_pages(d, max_pdx); bool need_paging; for_each_node_mask ( node, dom0_nodes ) @@ -256,7 +257,7 @@ unsigned long __init dom0_compute_nr_pages( /* Reserve memory for iommu_dom0_init(). */ if ( iommu_enabled ) - avail -= dom0_paging_pages(d, max_pdx); + avail -= paging_pgs; need_paging = is_hvm_domain(d) && (!iommu_hap_pt_share || !paging_mode_hap(d)); @@ -288,7 +289,7 @@ unsigned long __init dom0_compute_nr_pages( break; /* Reserve memory for shadow or HAP. */ - avail -= dom0_paging_pages(d, nr_pages); + avail -= paging_pgs; } if ( is_pv_domain(d) && -- 2.13.5 (Apple Git-94) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |