rip out x86_32 NUMA remapping code
Subsystems (5)
RFC PATCH 1/1 rip out x86_32 NUMA remapping code
This code was an optimization for 32-bit NUMA systems.
It has probably been the cause of a number of subtle bugs over the years, although the conditions to excite them would have been hard to trigger. Essentially, we remap part of the kernel linear mapping area, and then sometimes part of that area gets freed back in to the bootmem allocator. If those pages get used by kernel data structures (say mem_map[] or a dentry), there's no big deal. But, if anyone ever tried to use the linear mapping for these pages _and_ cared about their physical address, bad things happen.
For instance, say you passed __GFP_ZERO to the page allocator and then happened to get handed one of these pages, it zero the remapped page, but it would make a pte to the _old_ page. There are probably a hundred other ways that it could screw with things.
We don't need to hang on to performance optimizations for these old boxes any more. All my 32-bit NUMA systems are long dead and buried, and I probably had access to more than most people.
This code is causing real things to break today:
https://lkml.org/lkml/2013/1/9/376
I looked in to actually fixing this, but it requires surgery to way too much brittle code, as well as stuff like per_cpu_ptr_to_phys().
---
linux-2.6.git-dave/arch/x86/Kconfig | 4 linux-2.6.git-dave/arch/x86/mm/numa.c | 3 linux-2.6.git-dave/arch/x86/mm/numa_32.c | 161 ------------------------- linux-2.6.git-dave/arch/x86/mm/numa_internal.h | 6 4 files changed, 174 deletions(-)
arch/x86/Kconfig renamed from arch/x86/Kconfig~rip-out-i386-NUMA-remapping-code +0 -4
@@ -1253,10 +1253,6 @@ config NODES_SHIFT Specify the maximum number of NUMA Nodes available on the target system. Increases memory reserved to accommodate various tables. -config HAVE_ARCH_ALLOC_REMAP - def_bool y - depends on X86_32 && NUMA - config ARCH_HAVE_MEMORY_PRESENT def_bool y depends on X86_32 && DISCONTIGMEM
arch/x86/mm/numa_32.c renamed from arch/x86/mm/numa_32.c~rip-out-i386-NUMA-remapping-code +0 -161
167 lines not on this page · raw message
arch/x86/mm/numa.c renamed from arch/x86/mm/numa.c~rip-out-i386-NUMA-remapping-code +0 -3
@@ -205,9 +205,6 @@ static void __init setup_node_data(int nif (end && (end - start) <NODE_MIN_SIZE )return ; -/* initialize remap allocator before aligning to ZONE_ALIGN */ -init_alloc_remap (nid, start, end); - start =roundup (start,ZONE_ALIGN ); printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n",
arch/x86/mm/numa_internal.h renamed from arch/x86/mm/numa_internal.h~rip-out-i386-NUMA-remapping-code +0 -6
@@ -21,12 +21,6 @@ void __init numa_reset_distance(void);void __init x86_numa_init (void ); -#ifdef CONFIG_X86_64 -static inline void init_alloc_remap (int nid,u64 start,u64 end) { } -#else -void __init init_alloc_remap (int nid,u64 start,u64 end); -#endif -#ifdef CONFIG_NUMA_EMU void __init numa_emulation (struct numa_meminfo *numa_meminfo,int numa_dist_cnt);
_
H. Peter Anvin
reviewerQuoted 23 lines · Dave Hansen
This code was an optimization for 32-bit NUMA systems.
It has probably been the cause of a number of subtle bugs over the years, although the conditions to excite them would have been hard to trigger. Essentially, we remap part of the kernel linear mapping area, and then sometimes part of that area gets freed back in to the bootmem allocator. If those pages get used by kernel data structures (say mem_map[] or a dentry), there's no big deal. But, if anyone ever tried to use the linear mapping for these pages _and_ cared about their physical address, bad things happen.
For instance, say you passed
__GFP_ZEROto the page allocator and then happened to get handed one of these pages, it zero the remapped page, but it would make a pte to the _old_ page. There are probably a hundred other ways that it could screw with things.We don't need to hang on to performance optimizations for these old boxes any more. All my 32-bit NUMA systems are long dead and buried, and I probably had access to more than most people.
Quoted 8 lines
This code is causing real things to break today:
https://lkml.org/lkml/2013/1/9/376I looked in to actually fixing this, but it requires surgery to way too much brittle code, as well as stuff like
per_cpu_ptr_to_phys().
This came up because we made some changes which made us trap on this bug. Most likely we have been silently corrupting memory for quite some time. Unless someone objects strongly I will apply this patch.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
H. Peter Anvin
reviewerQuoted 23 lines · Dave Hansen
This code was an optimization for 32-bit NUMA systems.
It has probably been the cause of a number of subtle bugs over the years, although the conditions to excite them would have been hard to trigger. Essentially, we remap part of the kernel linear mapping area, and then sometimes part of that area gets freed back in to the bootmem allocator. If those pages get used by kernel data structures (say mem_map[] or a dentry), there's no big deal. But, if anyone ever tried to use the linear mapping for these pages _and_ cared about their physical address, bad things happen.
For instance, say you passed
__GFP_ZEROto the page allocator and then happened to get handed one of these pages, it zero the remapped page, but it would make a pte to the _old_ page. There are probably a hundred other ways that it could screw with things.We don't need to hang on to performance optimizations for these old boxes any more. All my 32-bit NUMA systems are long dead and buried, and I probably had access to more than most people.
Quoted 8 lines
This code is causing real things to break today:
https://lkml.org/lkml/2013/1/9/376I looked in to actually fixing this, but it requires surgery to way too much brittle code, as well as stuff like
per_cpu_ptr_to_phys().
I get a build failure on i386 allyesconfig with this patch:
arch/x86/power/built-in.o: In function `swsusp_arch_resume':
(.text+0x14e4): undefined reference to `resume_map_numa_kva'
It looks trivial to fix up; I assume resume_map_numa_kva() just goes away like it does in the non-NUMA case, but it would be nice if you could confirm that.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · H. Peter Anvin
I get a build failure on i386 allyesconfig with this patch:
arch/x86/power/built-in.o: In function `swsusp_arch_resume':
(.text+0x14e4): undefined reference to `resume_map_numa_kva'It looks trivial to fix up; I assume
resume_map_numa_kva()just goes away like it does in the non-NUMA case, but it would be nice if you could confirm that.
the patches does not seem to complete.
at least, it does not remove
arch/x86/mm/numa.c: nd = alloc_remap(nid, nd_size);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
H. Peter Anvin
reviewerQuoted 10 lines · Yinghai Lu
Quoted 8 lines · H. Peter Anvin
I get a build failure on i386 allyesconfig with this patch:
arch/x86/power/built-in.o: In function `swsusp_arch_resume':
(.text+0x14e4): undefined reference to `resume_map_numa_kva'It looks trivial to fix up; I assume
resume_map_numa_kva()just goes away like it does in the non-NUMA case, but it would be nice if you could confirm that.
Quoted 6 lines
the patches does not seem to complete.
at least, it does not remove
arch/x86/mm/numa.c: nd =alloc_remap(nid, nd_size);
... which will just return NULL because alloc_remap turns into an inline just returning NULL. So the compiled code is correct, but the source code is needlessly messy.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · H. Peter Anvin
Quoted 12 lines · Yinghai Lu
Quoted 8 lines · H. Peter Anvin
I get a build failure on i386 allyesconfig with this patch:
arch/x86/power/built-in.o: In function `swsusp_arch_resume':
(.text+0x14e4): undefined reference to `resume_map_numa_kva'It looks trivial to fix up; I assume
resume_map_numa_kva()just goes away like it does in the non-NUMA case, but it would be nice if you could confirm that.the patches does not seem to complete.
Quoted 8 lines
Quoted 4 lines
at least, it does not remove
arch/x86/mm/numa.c: nd =alloc_remap(nid, nd_size);... which will just return NULL because
alloc_remapturns into an inline just returning NULL. So the compiled code is correct, but the source code is needlessly messy.
yes...
It still left #ifdefCONFIG_HAVE_ARCH_ALLOC_REMAP there.
#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
extern void *alloc_remap(int nid, unsigned long size); #else
static inline void *alloc_remap(int nid, unsigned long size)
{
return NULL;
}#endif /* CONFIG_HAVE_ARCH_ALLOC_REMAP */
should throw them all away.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
H. Peter Anvin
reviewerQuoted 31 lines · Yinghai Lu
Quoted 13 lines · H. Peter Anvin
Quoted 12 lines · Yinghai Lu
Quoted 8 lines · H. Peter Anvin
I get a build failure on i386 allyesconfig with this patch:
arch/x86/power/built-in.o: In function `swsusp_arch_resume':
(.text+0x14e4): undefined reference to `resume_map_numa_kva'It looks trivial to fix up; I assume
resume_map_numa_kva()just goes away like it does in the non-NUMA case, but it would be nice if you could confirm that.the patches does not seem to complete.
Quoted 8 lines
Quoted 4 lines
at least, it does not remove
arch/x86/mm/numa.c: nd =alloc_remap(nid, nd_size);... which will just return NULL because
alloc_remapturns into an inline just returning NULL. So the compiled code is correct, but the source code is needlessly messy.yes...
It still left #ifdefCONFIG_HAVE_ARCH_ALLOC_REMAP there.
#ifdef
CONFIG_HAVE_ARCH_ALLOC_REMAP
extern void *alloc_remap(int nid, unsigned long size); #else
static inline void *alloc_remap(int nid, unsigned long size)
Quoted 7 lines
{ return NULL; }#endif /*
CONFIG_HAVE_ARCH_ALLOC_REMAP*/should throw them all away.
That is arch-independent code, and the tile architecture still uses it.
Makes one wonder how much it will get tested going forward, especially with the x86-32 implementation clearly lacking in that department.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · H. Peter Anvin
That is arch-independent code, and the tile architecture still uses it.
Makes one wonder how much it will get tested going forward, especially with the x86-32 implementation clearly lacking in that department.
Yeah, I left the tile one because it wasn't obvious how it was being used over there. It _probably_ has the same bugs that x86 does.
I'll refresh the patch fixing some of the compile issues and resend.
H. Peter Anvin
reviewerQuoted 11 lines · Dave Hansen
Quoted 4 lines · H. Peter Anvin
That is arch-independent code, and the tile architecture still uses it.
Makes one wonder how much it will get tested going forward, especially with the x86-32 implementation clearly lacking in that department.
Yeah, I left the tile one because it wasn't obvious how it was being used over there. It _probably_ has the same bugs that x86 does.
I'll refresh the patch fixing some of the compile issues and resend.
I already have fixup patches, I think.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[tip:x86/mm] x86-32, mm: Remove reference to alloc_remap()
In reply to Yinghai LuCommit-ID: 07f4207a305c834f528d08428df4531744e25678 Gitweb: http://git.kernel.org/tip/07f4207a305c834f528d08428df4531744e25678 Author: H. Peter Anvin <[email protected]> AuthorDate: Thu, 31 Jan 2013 14:00:48 -0800 Committer: H. Peter Anvin <[email protected]> CommitDate: Thu, 31 Jan 2013 14:12:30 -0800
x86-32, mm: Remove reference to alloc_remap()
We have removed the remap allocator for x86-32, and x86-64 never had it (and doesn't need it). Remove residual reference to it.
--- arch/x86/mm/numa.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
arch/x86/mm/numa.c +11 -18
@@ -193,7 +193,6 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)static void __init setup_node_data (int nid,u64 start,u64 end) {const size_t nd_size =roundup (sizeof (pg_data_t),PAGE_SIZE ); -bool remapped = false;u64 nd_pa;void *nd;int tnid;
@@ -211,28 +210,22 @@ static void __init setup_node_data(int nid, u64 start, u64 end) nid, start, end - 1);/* -* Allocate node data. Try remap allocator first, node-local -* memory and then any node. Never allocate in DMA zone. +* Allocate node data. Try node-local memory and then any node. +* Never allocate in DMA zone. */ - nd =alloc_remap (nid, nd_size); -if (nd) { - nd_pa =__pa_nodebug (nd); - remapped = true; - }else { - nd_pa =memblock_alloc_nid (nd_size,SMP_CACHE_BYTES , nid); -if (!nd_pa) { -pr_err ("Cannot find %zu bytes in node %d\n" , - nd_size, nid); -return ; - } - nd =__va (nd_pa); + nd_pa =memblock_alloc_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) { +pr_err ("Cannot find %zu bytes in node %d\n" , + nd_size, nid); +return ; } + nd =__va (nd_pa);/* report and initialize */ -printk (KERN_INFO " NODE_DATA [mem %#010Lx-%#010Lx]%s\n" , - nd_pa, nd_pa + nd_size -1 , remapped ?" (remapped)" :"" ); +printk (KERN_INFO " NODE_DATA [mem %#010Lx-%#010Lx]\n" , + nd_pa, nd_pa + nd_size -1 ); tnid =early_pfn_to_nid (nd_pa >>PAGE_SHIFT ); -if (!remapped && tnid != nid) +if (tnid != nid)printk (KERN_INFO " NODE_DATA(%d) on node %d\n" , nid, tnid); node_data[nid] = nd;
[tip:x86/mm] x86-32, mm: Rip out x86_32 NUMA remapping code
In reply to Dave HansenCommit-ID: f03574f2d5b2d6229dcdf2d322848065f72953c7 Gitweb: http://git.kernel.org/tip/f03574f2d5b2d6229dcdf2d322848065f72953c7 Author: Dave Hansen <[email protected]> AuthorDate: Wed, 30 Jan 2013 16:56:16 -0800 Committer: H. Peter Anvin <[email protected]> CommitDate: Thu, 31 Jan 2013 14:12:30 -0800
x86-32, mm: Rip out x86_32 NUMA remapping code
This code was an optimization for 32-bit NUMA systems.
It has probably been the cause of a number of subtle bugs over the years, although the conditions to excite them would have been hard to trigger. Essentially, we remap part of the kernel linear mapping area, and then sometimes part of that area gets freed back in to the bootmem allocator. If those pages get used by kernel data structures (say mem_map[] or a dentry), there's no big deal. But, if anyone ever tried to use the linear mapping for these pages _and_ cared about their physical address, bad things happen.
For instance, say you passed __GFP_ZERO to the page allocator and then happened to get handed one of these pages, it zero the remapped page, but it would make a pte to the _old_ page. There are probably a hundred other ways that it could screw with things.
We don't need to hang on to performance optimizations for these old boxes any more. All my 32-bit NUMA systems are long dead and buried, and I probably had access to more than most people.
This code is causing real things to break today:
https://lkml.org/lkml/2013/1/9/376
I looked in to actually fixing this, but it requires surgery to way too much brittle code, as well as stuff like per_cpu_ptr_to_phys().
[ hpa: Cc: this for -stable, since it is a memory corruption issue.
However, an alternative is to simply mark NUMA as depends BROKEN rather than EXPERIMENTAL in the X86_32 subclause... ]
--- arch/x86/Kconfig | 4 -- arch/x86/mm/numa.c | 3 - arch/x86/mm/numa_32.c | 161 -------------------------------------------- arch/x86/mm/numa_internal.h | 6 -- 4 files changed, 174 deletions(-)
arch/x86/Kconfig +0 -4
@@ -1253,10 +1253,6 @@ config NODES_SHIFT Specify the maximum number of NUMA Nodes available on the target system. Increases memory reserved to accommodate various tables. -config HAVE_ARCH_ALLOC_REMAP - def_bool y - depends on X86_32 && NUMA - config ARCH_HAVE_MEMORY_PRESENT def_bool y depends on X86_32 && DISCONTIGMEM
arch/x86/mm/numa.c +0 -3
@@ -205,9 +205,6 @@ static void __init setup_node_data(int nid, u64 start, u64 end)if (end && (end - start) <NODE_MIN_SIZE )return ; -/* initialize remap allocator before aligning to ZONE_ALIGN */ -init_alloc_remap (nid, start, end); - start =roundup (start,ZONE_ALIGN ); printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n",
arch/x86/mm/numa_32.c +0 -161
167 lines not on this page · raw message
arch/x86/mm/numa_internal.h +0 -6
@@ -21,12 +21,6 @@ void __init numa_reset_distance(void);void __init x86_numa_init (void ); -#ifdef CONFIG_X86_64 -static inline void init_alloc_remap (int nid,u64 start,u64 end) { } -#else -void __init init_alloc_remap (int nid,u64 start,u64 end); -#endif -#ifdef CONFIG_NUMA_EMU void __init numa_emulation (struct numa_meminfo *numa_meminfo,int numa_dist_cnt);
[tip:x86/mm] x86-32, mm: Remove reference to resume_map_numa_kva( )
In reply to Dave HansenCommit-ID: bb112aec5ee41427e9b9726e3d57b896709598ed Gitweb: http://git.kernel.org/tip/bb112aec5ee41427e9b9726e3d57b896709598ed Author: H. Peter Anvin <[email protected]> AuthorDate: Thu, 31 Jan 2013 13:53:10 -0800 Committer: H. Peter Anvin <[email protected]> CommitDate: Thu, 31 Jan 2013 14:12:30 -0800
x86-32, mm: Remove reference to resume_map_numa_kva()
Remove reference to removed function resume_map_numa_kva().
--- arch/x86/include/asm/mmzone_32.h | 6 ------ arch/x86/power/hibernate_32.c | 2 -- 2 files changed, 8 deletions(-)
arch/x86/include/asm/mmzone_32.h +0 -6
@@ -14,12 +14,6 @@ extern struct pglist_data *node_data[];#include <asm/numaq.h> -extern void resume_map_numa_kva (pgd_t *pgd); - -#else /* !CONFIG_NUMA */ - -static inline void resume_map_numa_kva (pgd_t *pgd) {} -#endif /* CONFIG_NUMA */ #ifdef CONFIG_DISCONTIGMEM
arch/x86/power/hibernate_32.c +0 -2
@@ -129,8 +129,6 @@ static int resume_physical_mapping_init(pgd_t *pgd_base) } } -resume_map_numa_kva (pgd_base); -return 0 ; }