Patches contributed by Eötvös Lorand University


commit a0176e2485ce6468f9b74264a2fd6c19811f027a
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Jun 16 12:44:17 2008 +0200

    Revert "Revert "x86: fix ioapic bug again""
    
    This reverts commit 0b6a39f7ebcb1c82587ce35b401c513eed41ac5c.
    
    The changes in tip/x86/apic solve this better.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c
index 4dc8600d9d20..a40d54fc1fdd 100644
--- a/arch/x86/kernel/io_apic_32.c
+++ b/arch/x86/kernel/io_apic_32.c
@@ -2130,10 +2130,14 @@ static inline void __init check_timer(void)
 {
 	int apic1, pin1, apic2, pin2;
 	int vector;
+	unsigned int ver;
 	unsigned long flags;
 
 	local_irq_save(flags);
 
+	ver = apic_read(APIC_LVR);
+	ver = GET_APIC_VERSION(ver);
+
 	/*
 	 * get/set the timer IRQ vector:
 	 */
@@ -2146,11 +2150,15 @@ static inline void __init check_timer(void)
 	 * mode for the 8259A whenever interrupts are routed
 	 * through I/O APICs.  Also IRQ0 has to be enabled in
 	 * the 8259A which implies the virtual wire has to be
-	 * disabled in the local APIC.
+	 * disabled in the local APIC.  Finally timer interrupts
+	 * need to be acknowledged manually in the 8259A for
+	 * timer_interrupt() and for the i82489DX when using
+	 * the NMI watchdog.
 	 */
 	apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
 	init_8259A(1);
-	timer_ack = 1;
+	timer_ack = !cpu_has_tsc;
+	timer_ack |= (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver));
 	if (timer_over_8254 > 0)
 		enable_8259A_irq(0);
 
diff --git a/arch/x86/kernel/nmi_32.c b/arch/x86/kernel/nmi_32.c
index 84160f74eeb0..11b14bbaa61e 100644
--- a/arch/x86/kernel/nmi_32.c
+++ b/arch/x86/kernel/nmi_32.c
@@ -26,6 +26,7 @@
 
 #include <asm/smp.h>
 #include <asm/nmi.h>
+#include <asm/timer.h>
 
 #include "mach_traps.h"
 
@@ -81,7 +82,7 @@ int __init check_nmi_watchdog(void)
 
 	prev_nmi_count = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
 	if (!prev_nmi_count)
-		return -1;
+		goto error;
 
 	printk(KERN_INFO "Testing NMI watchdog ... ");
 
@@ -118,7 +119,7 @@ int __init check_nmi_watchdog(void)
 	if (!atomic_read(&nmi_active)) {
 		kfree(prev_nmi_count);
 		atomic_set(&nmi_active, -1);
-		return -1;
+		goto error;
 	}
 	printk("OK.\n");
 
@@ -129,6 +130,10 @@ int __init check_nmi_watchdog(void)
 
 	kfree(prev_nmi_count);
 	return 0;
+error:
+	timer_ack = !cpu_has_tsc;
+
+	return -1;
 }
 
 static int __init setup_nmi_watchdog(char *str)

commit 93022136fff9e6130aa128a5ed8a599e93ac813c
Merge: c49c412a47b5 b7279469d66b
Author: Ingo Molnar <mingo@elte.hu>
Date:   Tue Jul 8 07:47:47 2008 +0200

    Merge commit 'v2.6.26-rc9' into x86/cpu

commit 4d51c7587bb13dbb2fafcad6c0b5231bd864b55f
Merge: d763d5edf945 f4628e644c34
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Jul 7 08:08:19 2008 +0200

    Merge branch 'tracing/mmiotrace-mergefixups' into tracing/mmiotrace

commit d763d5edf945eec47bd443b699f174976f0afc13
Merge: 790e2a290b49 1b40a895df6c
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Jul 7 08:07:35 2008 +0200

    Merge branch 'linus' into tracing/mmiotrace

diff --cc kernel/sched.c
index e2e985eeee78,94ead43eda62..70cb127e3495
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@@ -2631,11 -2277,8 +2299,11 @@@ void wake_up_new_task(struct task_struc
  		 * management (if any):
  		 */
  		p->sched_class->task_new(rq, p);
- 		inc_nr_running(rq);
+ 		inc_nr_running(p, rq);
  	}
 +	trace_mark(kernel_sched_wakeup_new,
 +		"pid %d state %ld ## rq %p task %p rq->curr %p",
 +		p->pid, p->state, rq, p, rq->curr);
  	check_preempt_curr(rq, p);
  #ifdef CONFIG_SMP
  	if (p->sched_class->task_wake_up)

commit 032f82786f9be4635acaa5f77feca175a4ac5fe1
Merge: 46ac22bab42c b7279469d66b
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Jul 7 08:01:26 2008 +0200

    Merge commit 'v2.6.26-rc9' into sched/devel

commit 9982fbface82893e77d211fbabfbd229da6bdde6
Author: Ingo Molnar <mingo@elte.hu>
Date:   Sun Jul 6 14:24:08 2008 +0200

    Revert "cpumask: introduce new APIs"
    
    This reverts commit acb7669c125676e63cf96582455509216c39745e.
    
    the wrappers are not needed anymore.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 47418b1b4103..80226e776143 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -394,10 +394,6 @@ int __next_cpu_nr(int n, const cpumask_t *srcp);
 
 #endif /* NR_CPUS > 64 */
 
-#define next_cpu_nr(n, src)		next_cpu(n, src)
-#define cpus_weight_nr(cpumask)		cpus_weight(cpumask)
-#define for_each_cpu_mask_nr(cpu, mask)	for_each_cpu_mask(cpu, mask)
-
 /*
  * The following particular system cpumasks and operations manage
  * possible, present and online cpus.  Each of them is a fixed size

commit 68083e05d72d94f347293d8cc0067050ba904bfa
Merge: 7baac8b91f98 b7279469d66b
Author: Ingo Molnar <mingo@elte.hu>
Date:   Sun Jul 6 14:23:39 2008 +0200

    Merge commit 'v2.6.26-rc9' into cpus4096

diff --cc include/linux/cpumask.h
index 80226e776143,c24875bd9c5b..47418b1b4103
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@@ -351,49 -343,20 +351,53 @@@ static inline void __cpus_fold(cpumask_
  	bitmap_fold(dstp->bits, origp->bits, sz, nbits);
  }
  
 -#if NR_CPUS > 1
 -#define for_each_cpu_mask(cpu, mask)		\
 -	for ((cpu) = first_cpu(mask);		\
 -		(cpu) < NR_CPUS;		\
 -		(cpu) = next_cpu((cpu), (mask)))
 -#else /* NR_CPUS == 1 */
 -#define for_each_cpu_mask(cpu, mask)		\
 +#if NR_CPUS == 1
 +
 +#define nr_cpu_ids		1
 +#define first_cpu(src)		({ (void)(src); 0; })
 +#define next_cpu(n, src)	({ (void)(src); 1; })
 +#define any_online_cpu(mask)	0
 +#define for_each_cpu_mask(cpu, mask)	\
  	for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
 -#endif /* NR_CPUS */
 +
 +#else /* NR_CPUS > 1 */
 +
 +extern int nr_cpu_ids;
 +int __first_cpu(const cpumask_t *srcp);
 +int __next_cpu(int n, const cpumask_t *srcp);
 +int __any_online_cpu(const cpumask_t *mask);
 +
 +#define first_cpu(src)		__first_cpu(&(src))
 +#define next_cpu(n, src)	__next_cpu((n), &(src))
 +#define any_online_cpu(mask) __any_online_cpu(&(mask))
 +#define for_each_cpu_mask(cpu, mask)			\
 +	for ((cpu) = -1;				\
 +		(cpu) = next_cpu((cpu), (mask)),	\
 +		(cpu) < NR_CPUS; )
 +#endif
 +
 +#if NR_CPUS <= 64
 +
 +#define next_cpu_nr(n, src)		next_cpu(n, src)
 +#define cpus_weight_nr(cpumask)		cpus_weight(cpumask)
 +#define for_each_cpu_mask_nr(cpu, mask)	for_each_cpu_mask(cpu, mask)
 +
 +#else /* NR_CPUS > 64 */
 +
 +int __next_cpu_nr(int n, const cpumask_t *srcp);
 +#define next_cpu_nr(n, src)	__next_cpu_nr((n), &(src))
 +#define cpus_weight_nr(cpumask)	__cpus_weight(&(cpumask), nr_cpu_ids)
 +#define for_each_cpu_mask_nr(cpu, mask)			\
 +	for ((cpu) = -1;				\
 +		(cpu) = next_cpu_nr((cpu), (mask)),	\
 +		(cpu) < nr_cpu_ids; )
 +
 +#endif /* NR_CPUS > 64 */
  
+ #define next_cpu_nr(n, src)		next_cpu(n, src)
+ #define cpus_weight_nr(cpumask)		cpus_weight(cpumask)
+ #define for_each_cpu_mask_nr(cpu, mask)	for_each_cpu_mask(cpu, mask)
+ 
  /*
   * The following particular system cpumasks and operations manage
   * possible, present and online cpus.  Each of them is a fixed size
diff --cc kernel/rcuclassic.c
index 251358de70b0,a38895a5b8e2..adde10388d0c
--- a/kernel/rcuclassic.c
+++ b/kernel/rcuclassic.c
@@@ -89,10 -89,24 +89,24 @@@ static void force_quiescent_state(struc
  		/*
  		 * Don't send IPI to itself. With irqs disabled,
  		 * rdp->cpu is the current cpu.
+ 		 *
+ 		 * cpu_online_map is updated by the _cpu_down()
+ 		 * using stop_machine_run(). Since we're in irqs disabled
+ 		 * section, stop_machine_run() is not exectuting, hence
+ 		 * the cpu_online_map is stable.
+ 		 *
+ 		 * However,  a cpu might have been offlined _just_ before
+ 		 * we disabled irqs while entering here.
+ 		 * And rcu subsystem might not yet have handled the CPU_DEAD
+ 		 * notification, leading to the offlined cpu's bit
+ 		 * being set in the rcp->cpumask.
+ 		 *
+ 		 * Hence cpumask = (rcp->cpumask & cpu_online_map) to prevent
+ 		 * sending smp_reschedule() to an offlined CPU.
  		 */
- 		cpumask = rcp->cpumask;
+ 		cpus_and(cpumask, rcp->cpumask, cpu_online_map);
  		cpu_clear(rdp->cpu, cpumask);
 -		for_each_cpu_mask(cpu, cpumask)
 +		for_each_cpu_mask_nr(cpu, cpumask)
  			smp_send_reschedule(cpu);
  	}
  }

commit a1716d508abf77e4bd02c275ab9293b9866929f3
Merge: 64e83b5a919a 4b4f7280d7fd
Author: Ingo Molnar <mingo@elte.hu>
Date:   Sat Jul 5 08:42:45 2008 +0200

    Merge branch 'x86/s2ram-fix' into x86/urgent

commit a8cac817764a494705aebd99fd51bdf6cdc28ec9
Merge: b4b3bd96f265 543cf4cb3fe6
Author: Ingo Molnar <mingo@elte.hu>
Date:   Thu Jul 3 15:03:02 2008 +0200

    Merge commit 'v2.6.26-rc8' into x86/mce

commit 7b4c9505f2fd82b117dd015b561f723b9a5dab79
Author: Ingo Molnar <mingo@elte.hu>
Date:   Thu Jul 3 09:17:55 2008 +0200

    stacktrace: export save_stack_trace[_tsk]
    
    Andrew Morton reported this against linux-next:
    
    ERROR: ".save_stack_trace" [tests/backtracetest.ko] undefined!
    
    Reported-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index ae31deb2d065..6b3ffde5deaa 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -66,4 +66,5 @@ void save_stack_trace(struct stack_trace *trace)
 
 	walk_stackframe(fp, base, base + THREAD_SIZE, save_trace, &data);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
 #endif
diff --git a/arch/avr32/kernel/stacktrace.c b/arch/avr32/kernel/stacktrace.c
index 9a68190bbffd..f4bdb448049c 100644
--- a/arch/avr32/kernel/stacktrace.c
+++ b/arch/avr32/kernel/stacktrace.c
@@ -51,3 +51,4 @@ void save_stack_trace(struct stack_trace *trace)
 		fp = frame->fp;
 	}
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index ebd9db8d1ece..5eb4681a73d2 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -73,3 +73,4 @@ void save_stack_trace(struct stack_trace *trace)
 	prepare_frametrace(regs);
 	save_context_stack(trace, regs);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 962944038430..9861f17258da 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -44,3 +44,4 @@ void save_stack_trace(struct stack_trace *trace)
 		sp = newsp;
 	}
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index 85e46a5d0e08..57571f10270c 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -81,6 +81,7 @@ void save_stack_trace(struct stack_trace *trace)
 			   S390_lowcore.thread_info,
 			   S390_lowcore.thread_info + THREAD_SIZE, 1);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
@@ -93,3 +94,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 	if (trace->nr_entries < trace->max_entries)
 		trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
+EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/sh/kernel/stacktrace.c b/arch/sh/kernel/stacktrace.c
index d41e561be20e..1b2ae35c4a76 100644
--- a/arch/sh/kernel/stacktrace.c
+++ b/arch/sh/kernel/stacktrace.c
@@ -34,3 +34,4 @@ void save_stack_trace(struct stack_trace *trace)
 		}
 	}
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c
index c73ce3f4197e..49656ed6ab18 100644
--- a/arch/sparc64/kernel/stacktrace.c
+++ b/arch/sparc64/kernel/stacktrace.c
@@ -47,3 +47,4 @@ void save_stack_trace(struct stack_trace *trace)
 			trace->entries[trace->nr_entries++] = pc;
 	} while (trace->nr_entries < trace->max_entries);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);