Patches contributed by Eötvös Lorand University


commit c5131ad6c3cbe8f6674993e29a76cecf8deb4384
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Aug 15 18:22:09 2008 +0200

    ftrace: ftrace_kill_atomic() build fix
    
    fix:
    
     kernel/built-in.o: In function `ftrace_dump':
     (.text+0x2e2ea): undefined reference to `ftrace_kill_atomic'
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index ce929cb55435..36c439927ff1 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -36,6 +36,7 @@ extern void ftrace_stub(unsigned long a0, unsigned long a1);
 # define register_ftrace_function(ops) do { } while (0)
 # define unregister_ftrace_function(ops) do { } while (0)
 # define clear_ftrace_function(ops) do { } while (0)
+static inline void ftrace_kill_atomic(void) { }
 #endif /* CONFIG_FTRACE */
 
 #ifdef CONFIG_DYNAMIC_FTRACE

commit 7b928c23fa3e9fa37d1d4ba52ba963f41ee5aae0
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Aug 15 17:48:02 2008 +0200

    ftrace: build fix
    
    fix:
    
     In file included from init/main.c:65:
     include/linux/ftrace.h:166: error: expected ‘,' or ‘;' before ‘{' token
     make[1]: *** [init/main.o] Error 1
     make: *** [init/main.o] Error 2
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index f7fb92045bf0..ce929cb55435 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -183,7 +183,10 @@ extern void ftrace_dump(void);
 static inline void
 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
 static inline int
-ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)))
+ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
+
+static inline int
+ftrace_printk(const char *fmt, ...)
 {
 	return 0;
 }

commit 8b1fa1d7b22f386747c7b78b918d4c680c16066f
Author: Ingo Molnar <mingo@elte.hu>
Date:   Tue Jul 29 12:36:02 2008 +0200

    ftrace: mark lapic_wd_event() notrace
    
    it can be called in the NMI path:
    
    [    0.645999] calling  ftrace_dynamic_init+0x0/0xd6
    [    0.647521] ------------[ cut here ]------------
    [    0.647521] WARNING: at kernel/trace/ftrace.c:348 ftrace_record_ip+0x4e/0x252()
    [    0.647521] Modules linked in:
    [    0.647521] Pid: 15, comm: kstop1 Not tainted 2.6.27-rc1-tip #22686
    [    0.647521]
    [    0.647521] Call Trace:
    [    0.647521]  <NMI>  [<ffffffff8024593f>] warn_on_slowpath+0x5d/0x84
    [    0.647521]  [<ffffffff80220b99>] ? lapic_wd_event+0xb/0x5c
    [    0.647521]  [<ffffffff80287b3b>] ftrace_record_ip+0x4e/0x252
    [    0.647521]  [<ffffffff80211274>] mcount_call+0x5/0x31
    [    0.647521]  [<ffffffff80220b9e>] ? lapic_wd_event+0x10/0x5c
    [    0.647521]  [<ffffffff8083f3ec>] nmi_watchdog_tick+0x19d/0x1ad
    [    0.647521]  [<ffffffff8083e875>] default_do_nmi+0x75/0x1e3
    [    0.647521]  [<ffffffff8083f0b3>] do_nmi+0x5d/0x94
    [    0.647521]  [<ffffffff8083e2d2>] nmi+0xa2/0xc2
    [    0.647521]  [<ffffffff802b48c3>] ? check_bytes_and_report+0x11/0xcc
    [    0.647521]  <<EOE>>  [<ffffffff80211274>] ? mcount_call+0x5/0x31
    [    0.647521]  [<ffffffff802b49df>] check_object+0x61/0x1b0
    [    0.647521]  [<ffffffff802b502a>] __slab_free+0x169/0x2ae
    [    0.647521]  [<ffffffff80242dbf>] ? __cleanup_sighand+0x25/0x27
    [    0.647521]  [<ffffffff80242dbf>] ? __cleanup_sighand+0x25/0x27
    [    0.647521]  [<ffffffff802b60cd>] kmem_cache_free+0x85/0xb9
    [    0.647521]  [<ffffffff80242dbf>] __cleanup_sighand+0x25/0x27
    [    0.647521]  [<ffffffff80247b3d>] release_task+0x256/0x339
    [    0.647521]  [<ffffffff802490b4>] do_exit+0x764/0x7ef
    [    0.647521]  [<ffffffff8027624c>] __xchg+0x0/0x38
    [    0.647521]  [<ffffffff8027619a>] ? stop_cpu+0x0/0xb2
    [    0.647521]  [<ffffffff8027619a>] ? stop_cpu+0x0/0xb2
    [    0.647521]  [<ffffffff8025922f>] kthread+0x4e/0x7b
    [    0.647521]  [<ffffffff80212979>] child_rip+0xa/0x11
    [    0.647521]  [<ffffffff80211c17>] ? restore_args+0x0/0x30
    [    0.647521]  [<ffffffff802283a5>] ? native_load_tls+0x14/0x2e
    [    0.647521]  [<ffffffff802591e1>] ? kthread+0x0/0x7b
    [    0.647521]  [<ffffffff8021296f>] ? child_rip+0x0/0x11
    [    0.647521]
    [    0.647521] ---[ end trace 4eaa2a86a8e2da22 ]---
    [    0.672032] initcall ftrace_dynamic_init+0x0/0xd6 returned 0 after 19 msecs
    
    also mark it no-kprobes while at it.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c
index 6bff382094f5..9abd48b22674 100644
--- a/arch/x86/kernel/cpu/perfctr-watchdog.c
+++ b/arch/x86/kernel/cpu/perfctr-watchdog.c
@@ -17,6 +17,8 @@
 #include <linux/bitops.h>
 #include <linux/smp.h>
 #include <linux/nmi.h>
+#include <linux/kprobes.h>
+
 #include <asm/apic.h>
 #include <asm/intel_arch_perfmon.h>
 
@@ -336,7 +338,8 @@ static void single_msr_unreserve(void)
 	release_perfctr_nmi(wd_ops->perfctr);
 }
 
-static void single_msr_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
+static void __kprobes
+single_msr_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
 {
 	/* start the cycle over again */
 	write_watchdog_counter(wd->perfctr_msr, NULL, nmi_hz);
@@ -401,7 +404,7 @@ static int setup_p6_watchdog(unsigned nmi_hz)
 	return 1;
 }
 
-static void p6_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
+static void __kprobes p6_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
 {
 	/*
 	 * P6 based Pentium M need to re-unmask
@@ -605,7 +608,7 @@ static void p4_unreserve(void)
 	release_perfctr_nmi(MSR_P4_IQ_PERFCTR0);
 }
 
-static void p4_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
+static void __kprobes p4_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
 {
 	unsigned dummy;
 	/*
@@ -784,7 +787,7 @@ unsigned lapic_adjust_nmi_hz(unsigned hz)
 	return hz;
 }
 
-int lapic_wd_event(unsigned nmi_hz)
+int __kprobes lapic_wd_event(unsigned nmi_hz)
 {
 	struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
 	u64 ctr;

commit 36dcd67ae994fece615b7c700958d215e884b9ae
Author: Ingo Molnar <mingo@elte.hu>
Date:   Tue Jul 29 12:00:59 2008 +0200

    ftrace: ignore functions that cannot be kprobe-ed
    
    kprobes already has an extensive list of annotations for functions
    that should not be instrumented. Add notrace annotations to these
    functions as well.
    
    This is particularly useful for functions called by the NMI path.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 0be7795655fa..497b1d1f7a05 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -29,6 +29,7 @@
  *		<jkenisto@us.ibm.com>  and Prasanna S Panchamukhi
  *		<prasanna@in.ibm.com> added function-return probes.
  */
+#include <linux/linkage.h>
 #include <linux/list.h>
 #include <linux/notifier.h>
 #include <linux/smp.h>
@@ -47,7 +48,7 @@
 #define KPROBE_HIT_SSDONE	0x00000008
 
 /* Attach to insert probes on any functions which should be ignored*/
-#define __kprobes	__attribute__((__section__(".kprobes.text")))
+#define __kprobes	__attribute__((__section__(".kprobes.text"))) notrace
 
 struct kprobe;
 struct pt_regs;
@@ -256,7 +257,7 @@ void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
 
 #else /* CONFIG_KPROBES */
 
-#define __kprobes	/**/
+#define __kprobes	notrace
 struct jprobe;
 struct kretprobe;
 
diff --git a/kernel/notifier.c b/kernel/notifier.c
index 823be11584ef..4282c0a40a57 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -550,7 +550,7 @@ EXPORT_SYMBOL(unregister_reboot_notifier);
 
 static ATOMIC_NOTIFIER_HEAD(die_chain);
 
-int notify_die(enum die_val val, const char *str,
+int notrace notify_die(enum die_val val, const char *str,
 	       struct pt_regs *regs, long err, int trap, int sig)
 {
 	struct die_args args = {

commit 5f87f1121895dc09d2d1c1db5f14af6aa4ce3e94
Author: Ingo Molnar <mingo@elte.hu>
Date:   Wed Jul 23 14:15:22 2008 +0200

    tracing: clean up tracepoints kconfig structure
    
    do not expose users to CONFIG_TRACEPOINTS - tracers can select it
    just fine.
    
    update ftrace to select CONFIG_TRACEPOINTS.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/init/Kconfig b/init/Kconfig
index d5994490b0b0..031344f954fd 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -771,11 +771,12 @@ config PROFILING
 	  Say Y here to enable the extended profiling support mechanisms used
 	  by profilers such as OProfile.
 
+#
+# Place an empty function call at each tracepoint site. Can be
+# dynamically changed for a probe function.
+#
 config TRACEPOINTS
-	bool "Activate tracepoints"
-	help
-	  Place an empty function call at each tracepoint site. Can be
-	  dynamically changed for a probe function.
+	bool
 
 config MARKERS
 	bool "Activate markers"
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 263e9e6bbd60..cae2637d5e68 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -14,6 +14,7 @@ config TRACING
 	bool
 	select DEBUG_FS
 	select STACKTRACE
+	select TRACEPOINTS
 
 config FTRACE
 	bool "Kernel Function Tracer"

commit cf569a932217b97e2fc2c48aa597fe29519a0cff
Author: Ingo Molnar <mingo@elte.hu>
Date:   Wed Jul 23 13:48:22 2008 +0200

    sched: clean up tracepoints
    
    make it a bit more structured hence more readable.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/include/trace/sched.h b/include/trace/sched.h
index 506ae1323656..ad47369d01b5 100644
--- a/include/trace/sched.h
+++ b/include/trace/sched.h
@@ -6,40 +6,51 @@
 
 DEFINE_TRACE(sched_kthread_stop,
 	TPPROTO(struct task_struct *t),
-	TPARGS(t));
+		TPARGS(t));
+
 DEFINE_TRACE(sched_kthread_stop_ret,
 	TPPROTO(int ret),
-	TPARGS(ret));
+		TPARGS(ret));
+
 DEFINE_TRACE(sched_wait_task,
 	TPPROTO(struct rq *rq, struct task_struct *p),
-	TPARGS(rq, p));
+		TPARGS(rq, p));
+
 DEFINE_TRACE(sched_wakeup,
 	TPPROTO(struct rq *rq, struct task_struct *p),
-	TPARGS(rq, p));
+		TPARGS(rq, p));
+
 DEFINE_TRACE(sched_wakeup_new,
 	TPPROTO(struct rq *rq, struct task_struct *p),
-	TPARGS(rq, p));
+		TPARGS(rq, p));
+
 DEFINE_TRACE(sched_switch,
 	TPPROTO(struct rq *rq, struct task_struct *prev,
 		struct task_struct *next),
-	TPARGS(rq, prev, next));
+		TPARGS(rq, prev, next));
+
 DEFINE_TRACE(sched_migrate_task,
 	TPPROTO(struct rq *rq, struct task_struct *p, int dest_cpu),
-	TPARGS(rq, p, dest_cpu));
+		TPARGS(rq, p, dest_cpu));
+
 DEFINE_TRACE(sched_process_free,
 	TPPROTO(struct task_struct *p),
-	TPARGS(p));
+		TPARGS(p));
+
 DEFINE_TRACE(sched_process_exit,
 	TPPROTO(struct task_struct *p),
-	TPARGS(p));
+		TPARGS(p));
+
 DEFINE_TRACE(sched_process_wait,
 	TPPROTO(struct pid *pid),
-	TPARGS(pid));
+		TPARGS(pid));
+
 DEFINE_TRACE(sched_process_fork,
 	TPPROTO(struct task_struct *parent, struct task_struct *child),
-	TPARGS(parent, child));
+		TPARGS(parent, child));
+
 DEFINE_TRACE(sched_signal_send,
 	TPPROTO(int sig, struct task_struct *p),
-	TPARGS(sig, p));
+		TPARGS(sig, p));
 
 #endif

commit fa340d9c050e78fb21a142b617304214ae5e0c2d
Author: Ingo Molnar <mingo@elte.hu>
Date:   Wed Jul 23 13:38:00 2008 +0200

    tracing: disable tracepoints by default
    
    while it's arguably low overhead, we dont enable new features by default.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/init/Kconfig b/init/Kconfig
index 70082678a914..d5994490b0b0 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -773,7 +773,6 @@ config PROFILING
 
 config TRACEPOINTS
 	bool "Activate tracepoints"
-	default y
 	help
 	  Place an empty function call at each tracepoint site. Can be
 	  dynamically changed for a probe function.

commit 3a1dfe6eefe483589c99c909202ffe1a20d589b5
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Oct 13 17:49:02 2008 +0200

    x86/mm: unify init task OOM handling
    
    Linus noticed that the "again:" versus "survive:" OOM logic for
    the init task was arbitrarily different.
    
    The 64-bit codepath is the better one, because it correctly re-lookups
    the vma after having dropped the ->mmap_sem.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index ac2ad781da00..8bc5956e1af4 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -671,7 +671,8 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
 		goto bad_area_nosemaphore;
 
 again:
-	/* When running in the kernel we expect faults to occur only to
+	/*
+	 * When running in the kernel we expect faults to occur only to
 	 * addresses in user space.  All other faults represent errors in the
 	 * kernel and should generate an OOPS.  Unfortunately, in the case of an
 	 * erroneous fault occurring in a code path which already holds mmap_sem
@@ -734,9 +735,6 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
 			goto bad_area;
 	}
 
-#ifdef CONFIG_X86_32
-survive:
-#endif
 	/*
 	 * If for any reason at all we couldn't handle the fault,
 	 * make sure we exit gracefully rather than endlessly redo
@@ -871,12 +869,11 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
 	up_read(&mm->mmap_sem);
 	if (is_global_init(tsk)) {
 		yield();
-#ifdef CONFIG_X86_32
-		down_read(&mm->mmap_sem);
-		goto survive;
-#else
+		/*
+		 * Re-lookup the vma - in theory the vma tree might
+		 * have changed:
+		 */
 		goto again;
-#endif
 	}
 
 	printk("VM: killing process %s\n", tsk->comm);

commit c00193f9f09f9b852249a66391985f585d066084
Merge: c1a2f4b10852 accba5f3965d f26ed116c0ba
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Oct 13 14:18:42 2008 +0200

    Merge branches 'oprofile-v2' and 'timers/hpet' into x86/core-v4

commit accba5f3965d6a9d1bf7c1e1a7995d17e9d521b6
Merge: 6852fd9b86d0 4480f15b3306
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Oct 13 11:05:51 2008 +0200

    Merge branch 'linus' into oprofile-v2
    
    Conflicts:
            arch/x86/kernel/apic_32.c
            arch/x86/oprofile/nmi_int.c
            include/linux/pci_ids.h

diff --cc arch/x86/kernel/apic_32.c
index 0059e7a8a9e6,a91c57cb666a..21c831d96af3
--- a/arch/x86/kernel/apic_32.c
+++ b/arch/x86/kernel/apic_32.c
@@@ -240,6 -290,36 +290,40 @@@ static void __setup_APIC_LVTT(unsigned 
  		apic_write(APIC_TMICT, clocks / APIC_DIVISOR);
  }
  
+ /*
+  * Setup extended LVT, AMD specific (K8, family 10h)
+  *
+  * Vector mappings are hard coded. On K8 only offset 0 (APIC500) and
+  * MCE interrupts are supported. Thus MCE offset must be set to 0.
++ *
++ * If mask=1, the LVT entry does not generate interrupts while mask=0
++ * enables the vector. See also the BKDGs.
+  */
+ 
+ #define APIC_EILVT_LVTOFF_MCE 0
+ #define APIC_EILVT_LVTOFF_IBS 1
+ 
+ static void setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask)
+ {
+ 	unsigned long reg = (lvt_off << 4) + APIC_EILVT0;
+ 	unsigned int  v   = (mask << 16) | (msg_type << 8) | vector;
+ 
+ 	apic_write(reg, v);
+ }
+ 
+ u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask)
+ {
+ 	setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask);
+ 	return APIC_EILVT_LVTOFF_MCE;
+ }
+ 
+ u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask)
+ {
+ 	setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask);
+ 	return APIC_EILVT_LVTOFF_IBS;
+ }
++EXPORT_SYMBOL_GPL(setup_APIC_eilvt_ibs);
+ 
  /*
   * Program the next event, relative to now
   */
diff --cc arch/x86/oprofile/nmi_int.c
index 287513a09819,8a5f1614a3d5..57f6c9088081
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@@ -468,7 -490,11 +496,10 @@@ int __init op_nmi_init(struct oprofile_
  		return -ENODEV;
  	}
  
 -	init_sysfs();
+ #ifdef CONFIG_SMP
+ 	register_cpu_notifier(&oprofile_cpu_nb);
+ #endif
 -	using_nmi = 1;
 +	/* default values, can be overwritten by model */
  	ops->create_files = nmi_create_files;
  	ops->setup = nmi_setup;
  	ops->shutdown = nmi_shutdown;
@@@ -489,8 -507,10 +520,12 @@@
  
  void op_nmi_exit(void)
  {
- 	if (using_nmi)
+ 	if (using_nmi) {
  		exit_sysfs();
+ #ifdef CONFIG_SMP
+ 		unregister_cpu_notifier(&oprofile_cpu_nb);
+ #endif
+ 	}
 +	if (model->exit)
 +		model->exit();
  }