LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init
@ 2008-01-28  9:16 Yinghai Lu
  2008-01-28 10:34 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Yinghai Lu @ 2008-01-28  9:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Mike Travis, Christoph Lameter, Linux Kernel Mailing List

[PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init

Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>

diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index f0e5cab..d7af3fd 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -31,7 +31,7 @@ bootmem_data_t plat_node_bdata[MAX_NUMNODES];
 
 struct memnode memnode;
 
-int x86_cpu_to_node_map_init[NR_CPUS] = {
+int x86_cpu_to_node_map_init[NR_CPUS] __initdata = {
 	[0 ... NR_CPUS-1] = NUMA_NO_NODE
 };
 void *x86_cpu_to_node_map_early_ptr;
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h
index 8af05a9..d3340de 100644
--- a/include/asm-x86/topology.h
+++ b/include/asm-x86/topology.h
@@ -35,7 +35,7 @@ extern int cpu_to_node_map[];
 
 #else
 DECLARE_PER_CPU(int, x86_cpu_to_node_map);
-extern int x86_cpu_to_node_map_init[];
+extern int __initdata x86_cpu_to_node_map_init[];
 extern void *x86_cpu_to_node_map_early_ptr;
 /* Returns the number of the current Node. */
 #define numa_node_id()		(early_cpu_to_node(raw_smp_processor_id()))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init
  2008-01-28  9:16 [PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init Yinghai Lu
@ 2008-01-28 10:34 ` Ingo Molnar
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-01-28 10:34 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Mike Travis, Christoph Lameter, Linux Kernel Mailing List, Sam Ravnborg


* Yinghai Lu <Yinghai.Lu@Sun.COM> wrote:

> -int x86_cpu_to_node_map_init[NR_CPUS] = {
> +int x86_cpu_to_node_map_init[NR_CPUS] __initdata = {
>  	[0 ... NR_CPUS-1] = NUMA_NO_NODE
>  };

i remember some linker warning here. While this array should indeed only 
be used in early init, that decision is dynamic and our linker warnings 
do not notice it. There's a special marker for such cases: 
__initdata_refok. But ... i'm slightly nervous about turning off a vital 
warning like that.

Sam, it would be nice to have a DEBUG_INITDATA mode of operation: in 
this case free_initmem() would not truly free those pages but would 
unmap them via:

   kernel_map_pages(page, nrpages, 0);

could be made dependent on DEBUG_PAGEALLOC.

If this debugging is enabled then if any code references it, we get a 
hard page fault. If we had a debug mode like that then bugs in this area 
would not go unnoticed.

Or perhaps just make this part of normal DEBUG_PAGEALLOC. Like the patch 
below on top of latest x86.git. Hm?

	Ingo

------------------->
Subject: x86: init memory debugging
From: Ingo Molnar <mingo@elte.hu>

debug incorrect/late access to init memory, by permanently unmapping
the init memory ranges. Depends on CONFIG_DEBUG_PAGEALLOC=y.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/mm/init_32.c |   12 ++++++++++++
 arch/x86/mm/init_64.c |   11 +++++++++++
 2 files changed, 23 insertions(+)

Index: linux-x86.q/arch/x86/mm/init_32.c
===================================================================
--- linux-x86.q.orig/arch/x86/mm/init_32.c
+++ linux-x86.q/arch/x86/mm/init_32.c
@@ -794,6 +794,18 @@ void free_init_pages(char *what, unsigne
 	unsigned long addr;
 
 	/*
+	 * If debugging page accesses then do not free this memory but
+	 * mark them not present - any buggy init-section access will
+	 * create a kernel page fault:
+	 */
+#ifdef CONFIG_DEBUG_PAGEALLOC
+	printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",
+		begin, PAGE_ALIGN(end));
+	set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
+	return;
+#endif
+	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
+	/*
 	 * We just marked the kernel text read only above, now that
 	 * we are going to free part of that, we need to make that
 	 * writeable first.
Index: linux-x86.q/arch/x86/mm/init_64.c
===================================================================
--- linux-x86.q.orig/arch/x86/mm/init_64.c
+++ linux-x86.q/arch/x86/mm/init_64.c
@@ -580,6 +580,17 @@ void free_init_pages(char *what, unsigne
 	if (begin >= end)
 		return;
 
+	/*
+	 * If debugging page accesses then do not free this memory but
+	 * mark them not present - any buggy init-section access will
+	 * create a kernel page fault:
+	 */
+#ifdef CONFIG_DEBUG_PAGEALLOC
+	printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",
+		begin, PAGE_ALIGN(end));
+	set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
+	return;
+#endif
 	printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
 
 	for (addr = begin; addr < end; addr += PAGE_SIZE) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init
       [not found]   ` <20080201170908.GB2159@elte.hu>
@ 2008-02-01 21:29     ` Yinghai Lu
  0 siblings, 0 replies; 3+ messages in thread
From: Yinghai Lu @ 2008-02-01 21:29 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel

[PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init

x86_cpu_to_apicid_init and x86_bios_cpu_apicid_init are defined with __initdata.

Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>

diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index f0e5cab..d7af3fd 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -31,7 +31,7 @@ bootmem_data_t plat_node_bdata[MAX_NUMNODES];
 
 struct memnode memnode;
 
-int x86_cpu_to_node_map_init[NR_CPUS] = {
+int x86_cpu_to_node_map_init[NR_CPUS] __initdata = {
 	[0 ... NR_CPUS-1] = NUMA_NO_NODE
 };
 void *x86_cpu_to_node_map_early_ptr;
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h
index 8af05a9..d3340de 100644
--- a/include/asm-x86/topology.h
+++ b/include/asm-x86/topology.h
@@ -35,7 +35,7 @@ extern int cpu_to_node_map[];
 
 #else
 DECLARE_PER_CPU(int, x86_cpu_to_node_map);
-extern int x86_cpu_to_node_map_init[];
+extern int __initdata x86_cpu_to_node_map_init[];
 extern void *x86_cpu_to_node_map_early_ptr;
 /* Returns the number of the current Node. */
 #define numa_node_id()		(early_cpu_to_node(raw_smp_processor_id()))

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-01 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-28  9:16 [PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init Yinghai Lu
2008-01-28 10:34 ` Ingo Molnar
     [not found] <200801290053.45776.yinghai.lu@sun.com>
2008-01-29  9:05 ` [PATCH 1/2] print out node_data addr and bootmap_start addr Yinghai Lu
     [not found]   ` <20080201170908.GB2159@elte.hu>
2008-02-01 21:29     ` [PATCH] x86_64: mark x86_cpu_to_node_map_init to __initdata like other xx_init Yinghai Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).