public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.13] x86_64: Make trap_init() happen earlier
@ 2005-09-08 16:37 Tom Rini
  2005-09-09  8:01 ` Andi Kleen
  2005-09-09 14:17 ` [PATCH 2.6.13] x86_64: Make trap_init() happen earlier - dropped Andi Kleen
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Rini @ 2005-09-08 16:37 UTC (permalink / raw)
  To: Andrew Morton, Kernel Mailing List; +Cc: Andi Kleen, Bob Picco

It can be handy in some situations to have run trap_init() sooner than the
generic code does.  In order to do this on x86_64 we need to add a custom
early_setup_per_cpu_areas() call as well.

---

 linux-2.6.13-trini/arch/x86_64/kernel/setup.c   |    3 +++
 linux-2.6.13-trini/arch/x86_64/kernel/setup64.c |   16 +++++++++++++++-
 linux-2.6.13-trini/arch/x86_64/kernel/traps.c   |    4 ++++
 linux-2.6.13-trini/include/asm-x86_64/proto.h   |    2 ++
 4 files changed, 24 insertions(+), 1 deletion(-)

diff -puN arch/x86_64/kernel/setup.c~x86_64-early_funcs arch/x86_64/kernel/setup.c
--- linux-2.6.13/arch/x86_64/kernel/setup.c~x86_64-early_funcs	2005-09-01 12:00:44.000000000 -0700
+++ linux-2.6.13-trini/arch/x86_64/kernel/setup.c	2005-09-01 12:00:44.000000000 -0700
@@ -525,6 +525,9 @@ void __init setup_arch(char **cmdline_p)
 {
 	unsigned long kernel_end;
 
+	early_setup_per_cpu_areas();
+	early_trap_init();
+
  	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
  	drive_info = DRIVE_INFO;
  	screen_info = SCREEN_INFO;
diff -puN arch/x86_64/kernel/setup64.c~x86_64-early_funcs arch/x86_64/kernel/setup64.c
--- linux-2.6.13/arch/x86_64/kernel/setup64.c~x86_64-early_funcs	2005-09-01 12:00:44.000000000 -0700
+++ linux-2.6.13-trini/arch/x86_64/kernel/setup64.c	2005-09-01 12:00:44.000000000 -0700
@@ -77,7 +77,19 @@ static int __init nonx32_setup(char *str
 }
 __setup("noexec32=", nonx32_setup);
 
+void __init early_setup_per_cpu_areas(void)
+{
+	static char cpu0[PERCPU_ENOUGH_ROOM] __cacheline_aligned
+		__attribute__ ((aligned (SMP_CACHE_BYTES)));
+	char *ptr = cpu0;
+
+	cpu_pda[0].data_offset = ptr - __per_cpu_start;
+	memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+}
+
 /*
+ * We run this a bit sooner than the normal code, so provide a dummy
+ * function as well.
  * Great future plan:
  * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
  * Always point %gs to its beginning
@@ -97,7 +109,9 @@ void __init setup_per_cpu_areas(void)
 	for (i = 0; i < NR_CPUS; i++) { 
 		char *ptr;
 
-		if (!NODE_DATA(cpu_to_node(i))) {
+		if (cpu_pda[i].data_offset)
+			continue;
+		else if (!NODE_DATA(cpu_to_node(i))) {
 			printk("cpu with no node %d, num_online_nodes %d\n",
 			       i, num_online_nodes());
 			ptr = alloc_bootmem(size);
diff -puN arch/x86_64/kernel/traps.c~x86_64-early_funcs arch/x86_64/kernel/traps.c
--- linux-2.6.13/arch/x86_64/kernel/traps.c~x86_64-early_funcs	2005-09-01 12:00:44.000000000 -0700
+++ linux-2.6.13-trini/arch/x86_64/kernel/traps.c	2005-09-01 12:00:44.000000000 -0700
@@ -904,6 +904,10 @@ void do_call_debug(struct pt_regs *regs)
 
 void __init trap_init(void)
 {
+}
+
+void __init early_trap_init(void)
+{
 	set_intr_gate(0,&divide_error);
 	set_intr_gate_ist(1,&debug,DEBUG_STACK);
 	set_intr_gate_ist(2,&nmi,NMI_STACK);
diff -puN include/asm-x86_64/proto.h~x86_64-early_funcs include/asm-x86_64/proto.h
--- linux-2.6.13/include/asm-x86_64/proto.h~x86_64-early_funcs	2005-09-01 12:00:44.000000000 -0700
+++ linux-2.6.13-trini/include/asm-x86_64/proto.h	2005-09-01 12:00:44.000000000 -0700
@@ -10,6 +10,8 @@ struct pt_regs;
 
 extern void get_cpu_vendor(struct cpuinfo_x86*);
 extern void start_kernel(void);
+extern void early_trap_init(void);
+extern void early_setup_per_cpu_areas(void);
 extern void pda_init(int); 
 
 extern void early_idt_handler(void);

-- 
Tom Rini
http://gate.crashing.org/~trini/

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

* Re: [PATCH 2.6.13] x86_64: Make trap_init() happen earlier
  2005-09-08 16:37 [PATCH 2.6.13] x86_64: Make trap_init() happen earlier Tom Rini
@ 2005-09-09  8:01 ` Andi Kleen
  2005-09-09 14:17 ` [PATCH 2.6.13] x86_64: Make trap_init() happen earlier - dropped Andi Kleen
  1 sibling, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2005-09-09  8:01 UTC (permalink / raw)
  To: Tom Rini; +Cc: Andrew Morton, Kernel Mailing List, Bob Picco

On Thursday 08 September 2005 18:37, Tom Rini wrote:
> It can be handy in some situations to have run trap_init() sooner than the
> generic code does.  In order to do this on x86_64 we need to add a custom
> early_setup_per_cpu_areas() call as well.

Queued, thanks.
-Andi


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

* Re: [PATCH 2.6.13] x86_64: Make trap_init() happen earlier - dropped
  2005-09-08 16:37 [PATCH 2.6.13] x86_64: Make trap_init() happen earlier Tom Rini
  2005-09-09  8:01 ` Andi Kleen
@ 2005-09-09 14:17 ` Andi Kleen
  2005-09-09 15:27   ` Bob Picco
  1 sibling, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2005-09-09 14:17 UTC (permalink / raw)
  To: Tom Rini; +Cc: Andrew Morton, Kernel Mailing List, Bob Picco

On Thursday 08 September 2005 18:37, Tom Rini wrote:
> It can be handy in some situations to have run trap_init() sooner than the
> generic code does.  In order to do this on x86_64 we need to add a custom
> early_setup_per_cpu_areas() call as well.

The patch is totally broken and causes crash even under light load
(just found it after a lengthy binary search) 

>
> +void __init early_setup_per_cpu_areas(void)
> +{
> +	static char cpu0[PERCPU_ENOUGH_ROOM] __cacheline_aligned
> +		__attribute__ ((aligned (SMP_CACHE_BYTES)));

The original code does

    /* Copy section for each CPU (we discard the original) */
        size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
#ifdef CONFIG_MODULES
        if (size < PERCPU_ENOUGH_ROOM)
                size = PERCPU_ENOUGH_ROOM;
#endif


perhaps end-start is larger than PERCPU_ENOUGH_ROOM ? (using defconfig) 

Dropped from my tree for now.

-Andi


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

* Re: [PATCH 2.6.13] x86_64: Make trap_init() happen earlier - dropped
  2005-09-09 14:17 ` [PATCH 2.6.13] x86_64: Make trap_init() happen earlier - dropped Andi Kleen
@ 2005-09-09 15:27   ` Bob Picco
  0 siblings, 0 replies; 4+ messages in thread
From: Bob Picco @ 2005-09-09 15:27 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Tom Rini, Andrew Morton, Kernel Mailing List, Bob Picco

Andi Kleen wrote:	[Fri Sep 09 2005, 10:17:40AM EDT]
> On Thursday 08 September 2005 18:37, Tom Rini wrote:
> > It can be handy in some situations to have run trap_init() sooner than the
> > generic code does.  In order to do this on x86_64 we need to add a custom
> > early_setup_per_cpu_areas() call as well.
> 
> The patch is totally broken and causes crash even under light load
> (just found it after a lengthy binary search) 
> 
> >
> > +void __init early_setup_per_cpu_areas(void)
> > +{
> > +	static char cpu0[PERCPU_ENOUGH_ROOM] __cacheline_aligned
> > +		__attribute__ ((aligned (SMP_CACHE_BYTES)));
> 
> The original code does
> 
>     /* Copy section for each CPU (we discard the original) */
>         size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
> #ifdef CONFIG_MODULES
>         if (size < PERCPU_ENOUGH_ROOM)
>                 size = PERCPU_ENOUGH_ROOM;
> #endif
> 
> 
> perhaps end-start is larger than PERCPU_ENOUGH_ROOM ? (using defconfig) 
> 
> Dropped from my tree for now.
> 
> -Andi
Andi:

Sorry about that.  I originally intended this for KGDB only. The hardcoded
PERCPU_ENOUGH_ROOM value is dangerous and could be the issue.  Let me take
a look at this.

bob

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

end of thread, other threads:[~2005-09-09 15:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-08 16:37 [PATCH 2.6.13] x86_64: Make trap_init() happen earlier Tom Rini
2005-09-09  8:01 ` Andi Kleen
2005-09-09 14:17 ` [PATCH 2.6.13] x86_64: Make trap_init() happen earlier - dropped Andi Kleen
2005-09-09 15:27   ` Bob Picco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox