Patches contributed by Eötvös Lorand University


commit ec5e61aabeac58670691bd0613388d16697d0d81
Merge: 75ec5a245c77 8bb39f9aa068
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Apr 2 19:37:50 2010 +0200

    Merge branch 'perf/urgent' into perf/core
    
    Conflicts:
            arch/x86/kernel/cpu/perf_event.c
    
    Merge reason: Resolve the conflict, pick up fixes
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --cc arch/x86/kernel/cpu/perf_event.c
index 6f66d4a845ff,53ea4cf1a878..b53435661813
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@@ -28,52 -28,48 +28,53 @@@
  #include <asm/apic.h>
  #include <asm/stacktrace.h>
  #include <asm/nmi.h>
+ #include <asm/compat.h>
  
 -static u64 perf_event_mask __read_mostly;
 +#if 0
 +#undef wrmsrl
 +#define wrmsrl(msr, val) 					\
 +do {								\
 +	trace_printk("wrmsrl(%lx, %lx)\n", (unsigned long)(msr),\
 +			(unsigned long)(val));			\
 +	native_write_msr((msr), (u32)((u64)(val)), 		\
 +			(u32)((u64)(val) >> 32));		\
 +} while (0)
 +#endif
  
 -/* The maximal number of PEBS events: */
 -#define MAX_PEBS_EVENTS	4
 +/*
 + * best effort, GUP based copy_from_user() that assumes IRQ or NMI context
 + */
 +static unsigned long
 +copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 +{
 +	unsigned long offset, addr = (unsigned long)from;
 +	int type = in_nmi() ? KM_NMI : KM_IRQ0;
 +	unsigned long size, len = 0;
 +	struct page *page;
 +	void *map;
 +	int ret;
  
 -/* The size of a BTS record in bytes: */
 -#define BTS_RECORD_SIZE		24
 +	do {
 +		ret = __get_user_pages_fast(addr, 1, 0, &page);
 +		if (!ret)
 +			break;
  
 -/* The size of a per-cpu BTS buffer in bytes: */
 -#define BTS_BUFFER_SIZE		(BTS_RECORD_SIZE * 2048)
 +		offset = addr & (PAGE_SIZE - 1);
 +		size = min(PAGE_SIZE - offset, n - len);
  
 -/* The BTS overflow threshold in bytes from the end of the buffer: */
 -#define BTS_OVFL_TH		(BTS_RECORD_SIZE * 128)
 +		map = kmap_atomic(page, type);
 +		memcpy(to, map+offset, size);
 +		kunmap_atomic(map, type);
 +		put_page(page);
  
 +		len  += size;
 +		to   += size;
 +		addr += size;
  
 -/*
 - * Bits in the debugctlmsr controlling branch tracing.
 - */
 -#define X86_DEBUGCTL_TR			(1 << 6)
 -#define X86_DEBUGCTL_BTS		(1 << 7)
 -#define X86_DEBUGCTL_BTINT		(1 << 8)
 -#define X86_DEBUGCTL_BTS_OFF_OS		(1 << 9)
 -#define X86_DEBUGCTL_BTS_OFF_USR	(1 << 10)
 +	} while (len < n);
  
 -/*
 - * A debug store configuration.
 - *
 - * We only support architectures that use 64bit fields.
 - */
 -struct debug_store {
 -	u64	bts_buffer_base;
 -	u64	bts_index;
 -	u64	bts_absolute_maximum;
 -	u64	bts_interrupt_threshold;
 -	u64	pebs_buffer_base;
 -	u64	pebs_index;
 -	u64	pebs_absolute_maximum;
 -	u64	pebs_interrupt_threshold;
 -	u64	pebs_event_reset[MAX_PEBS_EVENTS];
 -};
 +	return len;
 +}
  
  struct event_constraint {
  	union {
@@@ -207,9 -158,8 +208,9 @@@ struct x86_pmu 
  	void		(*put_event_constraints)(struct cpu_hw_events *cpuc,
  						 struct perf_event *event);
  	struct event_constraint *event_constraints;
 +	void		(*quirks)(void);
  
- 	void		(*cpu_prepare)(int cpu);
+ 	int		(*cpu_prepare)(int cpu);
  	void		(*cpu_starting)(int cpu);
  	void		(*cpu_dying)(int cpu);
  	void		(*cpu_dead)(int cpu);
@@@ -1620,14 -1596,77 +1623,42 @@@ perf_callchain_kernel(struct pt_regs *r
  	dump_trace(NULL, regs, NULL, regs->bp, &backtrace_ops, entry);
  }
  
- static int copy_stack_frame(const void __user *fp, struct stack_frame *frame)
 -/*
 - * best effort, GUP based copy_from_user() that assumes IRQ or NMI context
 - */
 -static unsigned long
 -copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 -{
 -	unsigned long offset, addr = (unsigned long)from;
 -	int type = in_nmi() ? KM_NMI : KM_IRQ0;
 -	unsigned long size, len = 0;
 -	struct page *page;
 -	void *map;
 -	int ret;
 -
 -	do {
 -		ret = __get_user_pages_fast(addr, 1, 0, &page);
 -		if (!ret)
 -			break;
 -
 -		offset = addr & (PAGE_SIZE - 1);
 -		size = min(PAGE_SIZE - offset, n - len);
 -
 -		map = kmap_atomic(page, type);
 -		memcpy(to, map+offset, size);
 -		kunmap_atomic(map, type);
 -		put_page(page);
 -
 -		len  += size;
 -		to   += size;
 -		addr += size;
 -
 -	} while (len < n);
 -
 -	return len;
 -}
 -
+ #ifdef CONFIG_COMPAT
+ static inline int
+ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
  {
- 	unsigned long bytes;
+ 	/* 32-bit process in 64-bit kernel. */
+ 	struct stack_frame_ia32 frame;
+ 	const void __user *fp;
  
- 	bytes = copy_from_user_nmi(frame, fp, sizeof(*frame));
+ 	if (!test_thread_flag(TIF_IA32))
+ 		return 0;
+ 
+ 	fp = compat_ptr(regs->bp);
+ 	while (entry->nr < PERF_MAX_STACK_DEPTH) {
+ 		unsigned long bytes;
+ 		frame.next_frame     = 0;
+ 		frame.return_address = 0;
+ 
+ 		bytes = copy_from_user_nmi(&frame, fp, sizeof(frame));
+ 		if (bytes != sizeof(frame))
+ 			break;
+ 
+ 		if (fp < compat_ptr(regs->sp))
+ 			break;
  
- 	return bytes == sizeof(*frame);
+ 		callchain_store(entry, frame.return_address);
+ 		fp = compat_ptr(frame.next_frame);
+ 	}
+ 	return 1;
  }
+ #else
+ static inline int
+ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
+ {
+     return 0;
+ }
+ #endif
  
  static void
  perf_callchain_user(struct pt_regs *regs, struct perf_callchain_entry *entry)

commit 50d11d190afa4e21284b735bb0a092036f298f0b
Merge: 42be79e37e26 ab310b5edb8b
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Apr 2 19:29:17 2010 +0200

    Merge branch 'perf/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into perf/urgent

commit d2f1e15b661e71fd52111f51c99a6ce41384e9ef
Merge: 40b7e05e17ee 220bf991b036
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Mar 22 18:46:57 2010 +0100

    Merge commit 'v2.6.34-rc2' into perf/core
    
    Merge reason: Pick up latest perf fixes from upstream.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

commit 55632770d7298835645489828af87f854c47749c
Author: Ingo Molnar <mingo@elte.hu>
Date:   Thu Mar 18 16:51:16 2010 +0100

    perf events: Fix false positive build warning with older GCC's
    
    gcc 4.2.1 produces:
    
     util/probe-event.c: In function 'add_perf_probe_events':
     util/probe-event.c:883: warning: 'tev' may be used uninitialized in this function
     make: *** [util/probe-event.o] Error 1
    
    Newer GCCs get this right.
    
    To work it around, initialize the variable to NULL so that older GCCs see
    it as initialized too.
    
    Cc: Masami Hiramatsu <mhiramat@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <20100316220612.32050.33806.stgit@localhost6.localdomain6>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f33326980583..c6603f3bb430 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -880,7 +880,7 @@ static void __add_kprobe_trace_events(struct perf_probe_event *pev,
 				      int ntevs, bool allow_suffix)
 {
 	int i, fd;
-	struct kprobe_trace_event *tev;
+	struct kprobe_trace_event *tev = NULL;
 	char buf[64];
 	const char *event, *group;
 	struct strlist *namelist;

commit 3b0d516463f8deb897a55cb81e9dbbe58a2490ed
Author: Ingo Molnar <mingo@elte.hu>
Date:   Wed Mar 17 12:13:28 2010 +0100

    perf probe: Fix !dwarf build
    
    Fix the !drawf build.
    
    This uses the existing NO_DWARF_SUPPORT mechanism we use for that,
    but it's really fragile and needs a cleanup. (in a separate patch)
    
    1) Such uses:
    
     #ifndef NO_DWARF_SUPPORT
    
    are double inverted logic a'la 'not not'. Instead the flag should
    be called DWARF_SUPPORT.
    
    2) Furthermore, assymetric #ifdef polluted code flow like:
    
            if (need_dwarf)
     #ifdef NO_DWARF_SUPPORT
                    die("Debuginfo-analysis is not supported");
     #else   /* !NO_DWARF_SUPPORT */
                    pr_debug("Some probes require debuginfo.\n");
    
            fd = open_vmlinux();
    
    is very fragile and not acceptable. Instead of that helper functions
    should be created and the dwarf/no-dwarf logic should be separated more
    cleanly.
    
    3) Local variable #ifdefs like this:
    
     #ifndef NO_DWARF_SUPPORT
            int fd;
     #endif
    
    Are fragile as well and should be eliminated. Helper functions achieve
    that too.
    
    Cc: Masami Hiramatsu <mhiramat@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <20100316220612.32050.33806.stgit@localhost6.localdomain6>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 64dea6c3d58a..f33326980583 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1012,8 +1012,10 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
 	if (!sym)
 		die("Kernel symbol \'%s\' not found - probe not added.",
 		    tev->point.symbol);
+#ifndef NO_DWARF_SUPPORT
 found:
 	close(fd);
+#endif
 	return ntevs;
 }
 
@@ -1172,10 +1174,13 @@ void show_line_range(struct line_range *lr)
 	unsigned int l = 1;
 	struct line_node *ln;
 	FILE *fp;
+#ifndef NO_DWARF_SUPPORT
 	int fd, ret;
+#endif
 
 	/* Search a line range */
 	init_vmlinux();
+#ifndef NO_DWARF_SUPPORT
 	fd = open_vmlinux();
 	if (fd < 0)
 		die("Could not open debuginfo file.");
@@ -1183,6 +1188,7 @@ void show_line_range(struct line_range *lr)
 	if (ret <= 0)
 		die("Source line is not found.\n");
 	close(fd);
+#endif
 
 	setup_pager();
 

commit e4713e93b125497e9ba44d93de1bd9d8e5ad8946
Merge: 984763cb90d4 a6b84574eed7
Author: Ingo Molnar <mingo@elte.hu>
Date:   Wed Mar 17 11:31:45 2010 +0100

    Merge branch 'perf/urgent' into perf/core
    
    Merge reason: We'll be queueing dependent changes.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --cc tools/perf/builtin-top.c
index c968bd3391e0,1f529321607e..887ebbf5d1ff
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@@ -464,10 -455,10 +464,10 @@@ static void print_sym_table(void
  	struct sym_entry *syme, *n;
  	struct rb_root tmp = RB_ROOT;
  	struct rb_node *nd;
- 	int sym_width = 0, dso_width = 0, max_dso_width;
+ 	int sym_width = 0, dso_width = 0, dso_short_width = 0;
  	const int win_width = winsize.ws_col - 1;
  
 -	samples = userspace_samples = 0;
 +	samples = userspace_samples = exact_samples = 0;
  
  	/* Sort the active symbols */
  	pthread_mutex_lock(&active_symbols_lock);

commit 12b8aeee3e51654fb95a3baff2e093f2513bb87d
Merge: 25268498c9e0 a3d3203e4bb4
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Mar 15 08:17:33 2010 +0100

    Merge branch 'linus' into timers/core
    
    Conflicts:
            Documentation/feature-removal-schedule.txt
    
    Merge reason: Resolve the conflict, update to upstream.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --cc Documentation/feature-removal-schedule.txt
index 198acdc05fd1,ed511af0f79a..8f8e4241bd90
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@@ -564,6 -564,6 +564,16 @@@ Who:	Avi Kivity <avi@redhat.com
  
  ----------------------------
  
++What:	xtime, wall_to_monotonic
++When:	2.6.36+
++Files:	kernel/time/timekeeping.c include/linux/time.h
++Why:	Cleaning up timekeeping internal values. Please use
++	existing timekeeping accessor functions to access
++	the equivalent functionality.
++Who:	John Stultz <johnstul@us.ibm.com>
++
++----------------------------
++
  What:	KVM kernel-allocated memory slots
  When:	July 2010
  Why:	Since 2.6.25, kvm supports user-allocated memory slots, which are

commit 2aa2b50dd62b5d0675bd7453fbeb5732dc2d7866
Author: Ingo Molnar <mingo@elte.hu>
Date:   Sun Mar 14 08:57:03 2010 +0100

    x86/mce: Fix build bug with CONFIG_PROVE_LOCKING=y && CONFIG_X86_MCE_INTEL=y
    
    Commit f56e8a076 "x86/mce: Fix RCU lockdep splats" introduced the
    following build bug:
    
      arch/x86/kernel/cpu/mcheck/mce.c: In function 'mce_log':
      arch/x86/kernel/cpu/mcheck/mce.c:166: error: 'mce_read_mutex' undeclared (first use in this function)
      arch/x86/kernel/cpu/mcheck/mce.c:166: error: (Each undeclared identifier is reported only once
      arch/x86/kernel/cpu/mcheck/mce.c:166: error: for each function it appears in.)
    
    Move the in-the-middle-of-file lock variable up to the variable
    definition section, the top of the .c file.
    
    Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: x86@kernel.org
    Cc: laijs@cn.fujitsu.com
    Cc: dipankar@in.ibm.com
    Cc: mathieu.desnoyers@polymtl.ca
    Cc: josh@joshtriplett.org
    Cc: dvhltc@us.ibm.com
    Cc: niv@us.ibm.com
    Cc: peterz@infradead.org
    Cc: rostedt@goodmis.org
    Cc: Valdis.Kletnieks@vt.edu
    Cc: dhowells@redhat.com
    LKML-Reference: <1267830207-9474-3-git-send-email-paulmck@linux.vnet.ibm.com>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index bd58de4d7a29..3ab9c886b613 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -46,6 +46,8 @@
 
 #include "mce-internal.h"
 
+static DEFINE_MUTEX(mce_read_mutex);
+
 #define rcu_dereference_check_mce(p) \
 	rcu_dereference_check((p), \
 			      rcu_read_lock_sched_held() || \
@@ -1490,8 +1492,6 @@ static void collect_tscs(void *data)
 	rdtscll(cpu_tsc[smp_processor_id()]);
 }
 
-static DEFINE_MUTEX(mce_read_mutex);
-
 static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
 			loff_t *off)
 {

commit 0308635917273030db6121d67c41ef2279b30340
Merge: 3997d3776a6e 0b861225a589
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Mar 12 21:06:35 2010 +0100

    Merge branch 'perf/x86' into perf/core
    
    Merge reason: The new P4 driver is stable and ready now for more
                  testing.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

commit 937779db13fb6cb621e28d9ae0a6cf1d05b57d05
Merge: 6230f2c7ef01 9f591fd76afd
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Mar 12 10:20:57 2010 +0100

    Merge branch 'perf/urgent' into perf/core
    
    Merge reason: We want to queue up a dependent patch.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>