A simple way to determine if the kernel needs HIGHMEM64G to be able to use all the installed memory
Hi,
When the installed memory size is >= 4GB, kernel drops some messages like
Warning only 4GB of memory will be used
You have to enable HIGHMEM64G.
I checked that the message comes from arch/x86/init_32.c after checking max_pfn.
I'm quite dumb about the internal structures of the kernel but, wouldn't it be possible to create a simple read-only sysfs object like kexec_loaded that will contain "1" when the kernel needs HIGHMEM64G to see all of the memory and "0" when it doesn't?
I think that it would be a nice facility for distribution kernels to detect the need for a PAE enabled 32-bit kernel by just reading some /sys/.. entry.
Thanks,
Signature · 2 lines
Ozan Çağlayan <ozan_at_pardus.org.tr>
Quoted 5 lines · Ozan Çağlayan
When the installed memory size is >= 4GB, kernel drops some messages like
Warning only 4GB of memory will be used
You have to enable HIGHMEM64G.
Quoted 7 lines
I checked that the message comes from
arch/x86/init_32.cafter checkingmax_pfn.I'm quite dumb about the internal structures of the kernel but, wouldn't it be possible to create a simple read-only sysfs object like
kexec_loadedthat will contain "1" when the kernel needs HIGHMEM64G to see all of the memory and "0" when it doesn't?
Why do you need a file? If kernel says to enable HIGHMEM64G, enable it.
Quoted 2 lines
I think that it would be a nice facility for distribution kernels to detect the need for a PAE enabled 32-bit kernel by just reading some
/sys/.. entry.
Quoted 8 lines · Alexey Dobriyan
Quoted 5 lines · Ozan Çağlayan
I'm quite dumb about the internal structures of the kernel but, wouldn't it be possible to create a simple read-only sysfs object like
kexec_loadedthat will contain "1" when the kernel needs HIGHMEM64G to see all of the memory and "0" when it doesn't?Why do you need a file? If kernel says to enable HIGHMEM64G, enable it.
It's not for me. We're not able to ship HIGHMEM64G enabled kernel packages with distributions because it breaks some processors not having PAE flag.
So, the PAE enabled kernel should be installed by distribution installers or package management systems if the processor honors the PAE bit. Because PAE is an extension mechanism for 32bit processors, AFAIK it has some overhead. So enabling it if the user doesn't have a memory size >=4GB would not make much sense if a proper noexecute (NX) support is not intended.
Fedora installer parses /proc/iomem to see if any address listed is bigger than 0x100000000h. I checked it on a machine having 4GB of memory, and it failed.
If the linux kernel is able to drop such an advisory message into the log buffer, it would be very easy to implement a read-only sysfs object. dmesg parsing is another hacky, dirty solution to the problem that I would not prefer at all.
Regards,
Signature · 2 lines
Ozan Çağlayan <ozan_at_pardus.org.tr>
Quoted 6 lines · Ozan Çağlayan
So, the PAE enabled kernel should be installed by distribution installers or package management systems if the processor honors the PAE bit. Because PAE is an extension mechanism for 32bit processors, AFAIK it has some overhead. So enabling it if the user doesn't have a memory size >=4GB would not make much sense if a proper noexecute (NX) support is not intended.
The general recommendation is to always use PAE when the machine is NX capable. Or at least use it by default.
Quoted 2 lines
Fedora installer parses
/proc/iomemto see if any address listed is bigger than 0x100000000h. I checked it on a machine having 4GB of memory, and it failed.
Newer kernels have the memmap in /sys/firmware/memmap to export the memory map. If anything is in there >4GB you need PAE.
But there's also the problem that a few systems have MMIO mappings above 4GB. If you're lucky they are in the memmap too, but sometimes they are not.
For those you also always need PAE. The only way to check for that would be to load all drivers and then check /proc/iomem or walk the PCI resources (in /sys/bus/pci). That would be still not 100% fool proof, but probably as good as you can get.
-Andi
Peter Zijlstra
maintainerPATCH 1/1 x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
Quoted 10 lines · Andi Kleen
Quoted 6 lines · Ozan Çağlayan
So, the PAE enabled kernel should be installed by distribution installers or package management systems if the processor honors the PAE bit. Because PAE is an extension mechanism for 32bit processors, AFAIK it has some overhead. So enabling it if the user doesn't have a memory size >=4GB would not make much sense if a proper noexecute (NX) support is not intended.
The general recommendation is to always use PAE when the machine is NX capable. Or at least use it by default.
How about we do the below as well?
---
If the hardware is capable, its much better to run a 64bit kernel than a 32bit PAE kernel with lots of memory.
--- arch/x86/mm/init_32.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/mm/init_32.c +5 -0
@@ -714,6 +714,9 @@ void __init lowmem_pfn_init(void)#define MSG_HIGHMEM_TRIMMED \ "Warning: only 4GB will be used. Use a HIGHMEM64G enabled kernel!\n" + +#define MSG_LM_TRIMMED \ + "Warning: instead of using a 32bit PAE kernel, Use a 64bit 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:
@@ -750,6 +753,8 @@ void __init highmem_pfn_init(void) }#endif /* !CONFIG_HIGHMEM64G */ #endif /* !CONFIG_HIGHMEM */ +if (boot_cpu_has (X86_FEATURE_LM )) + printk(KERN_WARNING MSG_LM_TRIMMED); }/*
Re: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
Quoted 1 line
How about we do the below as well?
Idea looks good, but with your patch it would print two conflicting messages ("use highmem64. No, use 64bit instead"), wouldn't it? Only one would be better.
-Andi
Peter Zijlstra
maintainerRe: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
Quoted 5 lines · Andi Kleen
Quoted 1 line
How about we do the below as well?
Idea looks good, but with your patch it would print two conflicting messages ("use highmem64. No, use 64bit instead"), wouldn't it? Only one would be better.
Something like the below?
--- arch/x86/mm/init_32.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
arch/x86/mm/init_32.c +22 -4
@@ -713,13 +713,19 @@ void __init lowmem_pfn_init(void) "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" + "Warning: only 4GB will be used. Use a %s kernel!\n" + +#define MSG_LM_TRIMMED \ + "Warning: instead of using a 32bit %s kernel, Use a 64bit 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 ) { +char *highmem; max_low_pfn =MAXMEM_PFN ;if (highmem_pages ==-1 )
@@ -737,16 +743,28 @@ void __init highmem_pfn_init(void)#ifndef CONFIG_HIGHMEM /* Maximum memory usable is what is directly addressable */ printk (KERN_WARNING "Warning only %ldMB will be used.\n" ,MAXMEM >>20 ); +if (max_pfn >MAX_NONPAE_PFN ) -printk (KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n" ); + highmem ="HIGHMEM64G" ;else -printk (KERN_WARNING "Use a HIGHMEM enabled kernel.\n" ); + highmem ="HIGHMEM" ; + +if (boot_cpu_has (X86_FEATURE_LM )) + printk(KERN_WARNING MSG_LM_TRIMMED, highmem); +else +printk (KERN_WARNING "Use a %s enabled kernel.\n" , highmem); + max_pfn =MAXMEM_PFN ;#else /* !CONFIG_HIGHMEM */ #ifndef CONFIG_HIGHMEM64G if (max_pfn >MAX_NONPAE_PFN ) { max_pfn =MAX_NONPAE_PFN ; - printk(KERN_WARNING MSG_HIGHMEM_TRIMMED); +if (boot_cpu_has (X86_FEATURE_LM )) + highmem ="64bit" ; +else + highmem ="HIGHMEM64G enabled" ; + + printk(KERN_WARNING MSG_HIGHMEM_TRIMMED, highmem); }#endif /* !CONFIG_HIGHMEM64G */ #endif /* !CONFIG_HIGHMEM */
Re: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
Quoted 8 lines · Peter Zijlstra
Quoted 5 lines · Andi Kleen
Quoted 1 line
How about we do the below as well?
Idea looks good, but with your patch it would print two conflicting messages ("use highmem64. No, use 64bit instead"), wouldn't it? Only one would be better.
Something like the below?
Looks good from the logic. Only nit would be missing grepability.
-Andi
Re: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
In reply to Peter ZijlstraQuoted 14 lines · On Tue, 10 Mar 2009 10:37:08 +0100 Peter Zijlstra <[email protected]> wrote:
arch/x86/mm/init_32.c +0
-0@@ -713,13 +713,19 @@ void __init lowmem_pfn_init(void) "only %luMB highmem pages available, ignoring highmem sizeof %luMB!\n"
#defineMSG_HIGHMEM_TRIMMED\arch/x86/mm/init_32.c +0
-1- "Warning: only 4GB will be used. Use a HIGHMEM64G enabledkernel!\n"
arch/x86/mm/init_32.c +4
-0+ "Warning: only 4GB will be used. Use a %s kernel!\n" + +#define MSG_LM_TRIMMED \ + "Warning: instead of using a 32bit %s kernel, Use a 64bit
Quoted 1 line
kernel!\n" +
I would like to avoid the prefix "Warning:" for something like this ;-)
lets keep that prefix for Real Warnings(tm) instead please.
Signature · 3 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
Re: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
In reply to Peter Zijlstraarch/x86/mm/init_32.c void __init lowmem_pfn_init(void) · line 719
Quoted 4 lines · Peter Zijlstra
Something like the below?
arch/x86/mm/init_32.c +2
-0+#define MSG_LM_TRIMMED \ + "Warning: instead of using a 32bit %s kernel, Use a 64bit kernel!\n"
Sounds good, but please change the message to something like:
INFO: running a 32-bit %s kernel on a 64-bit capable CPU!
To not overwhelm Arjan's kerneloops.org site with a hundred thousand bogus warnings ;-)
Ingo
Peter Zijlstra
maintainerRe: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
In reply to Arjan van de VenQuoted 20 lines · Arjan van de Ven
Quoted 14 lines · On Tue, 10 Mar 2009 10:37:08 +0100 Peter Zijlstra <[email protected]> wrote:
arch/x86/mm/init_32.c +0
-0@@ -713,13 +713,19 @@ void __init lowmem_pfn_init(void) "only %luMB highmem pages available, ignoring highmem sizeof %luMB!\n"
#defineMSG_HIGHMEM_TRIMMED\arch/x86/mm/init_32.c +0
-1- "Warning: only 4GB will be used. Use a HIGHMEM64G enabledkernel!\n"
arch/x86/mm/init_32.c +4
-0+ "Warning: only 4GB will be used. Use a %s kernel!\n" + +#define MSG_LM_TRIMMED \ + "Warning: instead of using a 32bit %s kernel, Use a 64bitQuoted 1 line
kernel!\n" +
I would like to avoid the prefix "Warning:" for something like this ;-)
Quoted 1 line
lets keep that prefix for Real Warnings(tm) instead please.
It is a Real warning, its issued when memory gets trimmed because you run a wrong kernel. The only change is suggesting to run a 64bit kernel when possible instead of a HIGHMEM/PAE kernel.
Esp on x86_64 machines with >=4G of memory its insane to run i386-PAE.
Re: [PATCH] x86: suggest running a 64bit kernel on LM capable machines with plenty memory.
Quoted 1 line
Esp on
x86_64machines with >=4G of memory its insane to run i386-PAE.
Not sure I would apply insane to 4GB, but it definitely applies to >= 16GB, likely >= 8GB. Enough known deadlocks in this case. I would consider >=16GB on 32bit at least a kerneloops worthy condition.
Perhaps the warnings should vary in urgency. e.g. if it's >= 16GB and not 2:2 split we know that the system will have problems and it should strongly suggest, otherwise weakly.
Or perhaps it should be measured in percentage of mem_map in lowmem?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.