Commit 4769843b authored by Ingo Molnar's avatar Ingo Molnar

x86, 32-bit: clean up find_low_pfn_range()

Impact: cleanup

Split find_low_pfn_range() into two functions:

 - lowmem_pfn_init()
 - highmem_pfn_init()

The former gets called if all of RAM fits into lowmem,
otherwise we call highmem_pfn_init().
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 3023533d
...@@ -675,75 +675,96 @@ static int __init parse_highmem(char *arg) ...@@ -675,75 +675,96 @@ static int __init parse_highmem(char *arg)
} }
early_param("highmem", parse_highmem); early_param("highmem", parse_highmem);
#define MSG_HIGHMEM_TOO_BIG \
"highmem size (%luMB) is bigger than pages available (%luMB)!\n"
#define MSG_LOWMEM_TOO_SMALL \
"highmem size (%luMB) results in <64MB lowmem, ignoring it!\n"
/* /*
* Determine low and high memory ranges: * All of RAM fits into lowmem - but if user wants highmem
* artificially via the highmem=x boot parameter then create
* it:
*/ */
void __init find_low_pfn_range(void) void __init lowmem_pfn_init(void)
{ {
/* it could update max_pfn */ if (highmem_pages == -1)
highmem_pages = 0;
/* max_low_pfn is 0, we already have early_res support */ #ifdef CONFIG_HIGHMEM
if (highmem_pages >= max_pfn) {
max_low_pfn = max_pfn; printk(KERN_ERR MSG_HIGHMEM_TOO_BIG,
if (max_low_pfn > MAXMEM_PFN) { pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
if (highmem_pages == -1) highmem_pages = 0;
highmem_pages = max_pfn - MAXMEM_PFN; }
if (highmem_pages + MAXMEM_PFN < max_pfn) if (highmem_pages) {
max_pfn = MAXMEM_PFN + highmem_pages; if (max_low_pfn - highmem_pages < 64*1024*1024/PAGE_SIZE) {
if (highmem_pages + MAXMEM_PFN > max_pfn) { printk(KERN_ERR MSG_LOWMEM_TOO_SMALL,
printk(KERN_WARNING "only %luMB highmem pages "
"available, ignoring highmem size of %luMB.\n",
pages_to_mb(max_pfn - MAXMEM_PFN),
pages_to_mb(highmem_pages)); pages_to_mb(highmem_pages));
highmem_pages = 0; highmem_pages = 0;
} }
max_low_pfn = MAXMEM_PFN; max_low_pfn -= highmem_pages;
}
#else
if (highmem_pages)
printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
#endif
}
#define MSG_HIGHMEM_TOO_SMALL \
"only %luMB highmem pages available, ignoring highmem size of %luMB!\n"
#define MSG_HIGHMEM_TRIMMED \
"Warning: only 4GB will be used. Use a HIGHMEM64G enabled kernel!\n"
/*
* We have more RAM than fits into lowmem - we try to put it into
* highmem, also taking the highmem=x boot parameter into account:
*/
void __init highmem_pfn_init(void)
{
if (highmem_pages == -1)
highmem_pages = max_pfn - MAXMEM_PFN;
if (highmem_pages + MAXMEM_PFN < max_pfn)
max_pfn = MAXMEM_PFN + highmem_pages;
if (highmem_pages + MAXMEM_PFN > max_pfn) {
printk(KERN_WARNING MSG_HIGHMEM_TOO_SMALL,
pages_to_mb(max_pfn - MAXMEM_PFN),
pages_to_mb(highmem_pages));
highmem_pages = 0;
}
max_low_pfn = MAXMEM_PFN;
#ifndef CONFIG_HIGHMEM #ifndef CONFIG_HIGHMEM
/* Maximum memory usable is what is directly addressable */ /* Maximum memory usable is what is directly addressable */
printk(KERN_WARNING "Warning only %ldMB will be used.\n", printk(KERN_WARNING "Warning only %ldMB will be used.\n", MAXMEM>>20);
MAXMEM>>20); if (max_pfn > MAX_NONPAE_PFN)
if (max_pfn > MAX_NONPAE_PFN) printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
printk(KERN_WARNING else
"Use a HIGHMEM64G enabled kernel.\n"); printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
else max_pfn = MAXMEM_PFN;
printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
max_pfn = MAXMEM_PFN;
#else /* !CONFIG_HIGHMEM */ #else /* !CONFIG_HIGHMEM */
#ifndef CONFIG_HIGHMEM64G #ifndef CONFIG_HIGHMEM64G
if (max_pfn > MAX_NONPAE_PFN) { if (max_pfn > MAX_NONPAE_PFN) {
max_pfn = MAX_NONPAE_PFN; max_pfn = MAX_NONPAE_PFN;
printk(KERN_WARNING "Warning only 4GB will be used." printk(KERN_WARNING MSG_HIGHMEM_TRIMMED);
"Use a HIGHMEM64G enabled kernel.\n"); }
}
#endif /* !CONFIG_HIGHMEM64G */ #endif /* !CONFIG_HIGHMEM64G */
#endif /* !CONFIG_HIGHMEM */ #endif /* !CONFIG_HIGHMEM */
} else { }
if (highmem_pages == -1)
highmem_pages = 0; /*
#ifdef CONFIG_HIGHMEM * Determine low and high memory ranges:
if (highmem_pages >= max_pfn) { */
printk(KERN_ERR "highmem size specified (%luMB) is " void __init find_low_pfn_range(void)
"bigger than pages available (%luMB)!.\n", {
pages_to_mb(highmem_pages), /* it could update max_pfn */
pages_to_mb(max_pfn));
highmem_pages = 0; /* max_low_pfn is 0, we already have early_res support */
} max_low_pfn = max_pfn;
if (highmem_pages) {
if (max_low_pfn - highmem_pages < if (max_low_pfn > MAXMEM_PFN)
64*1024*1024/PAGE_SIZE){ highmem_pfn_init();
printk(KERN_ERR "highmem size %luMB results in " else
"smaller than 64MB lowmem, ignoring it.\n" lowmem_pfn_init();
, pages_to_mb(highmem_pages));
highmem_pages = 0;
}
max_low_pfn -= highmem_pages;
}
#else
if (highmem_pages)
printk(KERN_ERR "ignoring highmem size on non-highmem"
" kernel!\n");
#endif
}
} }
#ifndef CONFIG_NEED_MULTIPLE_NODES #ifndef CONFIG_NEED_MULTIPLE_NODES
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment