[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3] xen/x86: delay parsing of dom0_mem parameter until needed
Instead of parsing the dom0_mem command line parameter as custom parameter do that only when building dom0. This will enable a later addition of specifying the memory size by fractions of the host memory size, which isn't known when doing custom parameter parsing. As this is needed later anyway move the logic for negative values into the parameter parsing, too. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- xen/arch/x86/dom0_build.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 5e2ad4bd56..e34022a9b8 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -24,6 +24,8 @@ static long __initdata dom0_nrpages; static long __initdata dom0_min_nrpages; static long __initdata dom0_max_nrpages = LONG_MAX; +static char __initdata dom0_mem_par[64]; + /* * dom0_mem=[min:<min_amt>,][max:<max_amt>,][<amt>] * @@ -44,14 +46,20 @@ static long __initdata dom0_max_nrpages = LONG_MAX; * If +ve: The specified amount is an absolute value. * If -ve: The specified amount is subtracted from total available memory. */ -static long __init parse_amt(const char *s, const char **ps) +static unsigned long __init parse_amt(const char *s, const char **ps, + unsigned long avail) { - long pages = parse_size_and_unit((*s == '-') ? s+1 : s, ps) >> PAGE_SHIFT; - return (*s == '-') ? -pages : pages; + unsigned int minus = (*s == '-') ? 1 : 0; + unsigned long pages = parse_size_and_unit(s + minus, ps) >> PAGE_SHIFT; + + /* Negative specification means "all memory - specified amount". */ + return minus ? avail - pages : pages; } -static int __init parse_dom0_mem(const char *s) +static int __init parse_dom0_mem(unsigned long avail) { + const char *s = dom0_mem_par; + /* xen-shim uses shim_mem parameter instead of dom0_mem */ if ( pv_shim ) { @@ -61,16 +69,16 @@ static int __init parse_dom0_mem(const char *s) do { if ( !strncmp(s, "min:", 4) ) - dom0_min_nrpages = parse_amt(s+4, &s); + dom0_min_nrpages = parse_amt(s + 4, &s, avail); else if ( !strncmp(s, "max:", 4) ) - dom0_max_nrpages = parse_amt(s+4, &s); + dom0_max_nrpages = parse_amt(s + 4, &s, avail); else - dom0_nrpages = parse_amt(s, &s); + dom0_nrpages = parse_amt(s, &s, avail); } while ( *s++ == ',' ); return s[-1] ? -EINVAL : 0; } -custom_param("dom0_mem", parse_dom0_mem); +string_param("dom0_mem", dom0_mem_par); static unsigned int __initdata opt_dom0_max_vcpus_min = 1; static unsigned int __initdata opt_dom0_max_vcpus_max = UINT_MAX; @@ -298,6 +306,10 @@ unsigned long __init dom0_compute_nr_pages( (!iommu_hap_pt_share || !paging_mode_hap(d)); for ( ; ; need_paging = false ) { + if ( dom0_mem_par[0] && parse_dom0_mem(avail) ) + printk("Invalid dom0_mem parameter value \"%s\", ignoring\n", + dom0_mem_par); + nr_pages = dom0_nrpages; min_pages = dom0_min_nrpages; max_pages = dom0_max_nrpages; @@ -308,14 +320,9 @@ unsigned long __init dom0_compute_nr_pages( * maximum of 128MB. */ if ( !nr_pages ) - nr_pages = -(pv_shim ? pv_shim_mem(avail) + nr_pages = avail - (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; - if ( (long)min_pages < 0 ) min_pages += avail; - if ( (long)max_pages < 0 ) max_pages += avail; - /* Clamp according to min/max limits and available memory. */ nr_pages = max(nr_pages, min_pages); nr_pages = min(nr_pages, max_pages); -- 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |