--- /dev/null
+From 5d27c23df09b702868d9a3bff86ec6abd22963ac Mon Sep 17 00:00:00 2001
+From: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Date: Thu, 17 Dec 2009 13:16:32 +0100
+Subject: perf events: Dont report side-band events on each cpu for per-task-per-cpu events
+
+From: Peter Zijlstra <a.p.zijlstra@chello.nl>
+
+commit 5d27c23df09b702868d9a3bff86ec6abd22963ac upstream.
+
+Acme noticed that his FORK/MMAP numbers were inflated by about
+the same factor as his cpu-count.
+
+This led to the discovery of a few more sites that need to
+respect the event->cpu filter.
+
+Reported-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
+Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Cc: Paul Mackerras <paulus@samba.org>
+LKML-Reference: <20091217121830.215333434@chello.nl>
+Signed-off-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ kernel/perf_event.c | 20 ++++++++++++++++++--
+ 1 file changed, 18 insertions(+), 2 deletions(-)
+
+--- a/kernel/perf_event.c
++++ b/kernel/perf_event.c
+@@ -1359,6 +1359,9 @@ static void perf_ctx_adjust_freq(struct
+ if (event->state != PERF_EVENT_STATE_ACTIVE)
+ continue;
+
++ if (event->cpu != -1 && event->cpu != smp_processor_id())
++ continue;
++
+ hwc = &event->hw;
+
+ interrupts = hwc->interrupts;
+@@ -3226,6 +3229,9 @@ static void perf_event_task_output(struc
+
+ static int perf_event_task_match(struct perf_event *event)
+ {
++ if (event->cpu != -1 && event->cpu != smp_processor_id())
++ return 0;
++
+ if (event->attr.comm || event->attr.mmap || event->attr.task)
+ return 1;
+
+@@ -3262,6 +3268,7 @@ static void perf_event_task_event(struct
+ ctx = rcu_dereference(task_event->task->perf_event_ctxp);
+ if (ctx)
+ perf_event_task_ctx(ctx, task_event);
++ put_cpu_var(perf_cpu_context);
+ rcu_read_unlock();
+ }
+
+@@ -3338,6 +3345,9 @@ static void perf_event_comm_output(struc
+
+ static int perf_event_comm_match(struct perf_event *event)
+ {
++ if (event->cpu != -1 && event->cpu != smp_processor_id())
++ return 0;
++
+ if (event->attr.comm)
+ return 1;
+
+@@ -3378,7 +3388,6 @@ static void perf_event_comm_event(struct
+
+ cpuctx = &get_cpu_var(perf_cpu_context);
+ perf_event_comm_ctx(&cpuctx->ctx, comm_event);
+- put_cpu_var(perf_cpu_context);
+
+ rcu_read_lock();
+ /*
+@@ -3388,6 +3397,7 @@ static void perf_event_comm_event(struct
+ ctx = rcu_dereference(current->perf_event_ctxp);
+ if (ctx)
+ perf_event_comm_ctx(ctx, comm_event);
++ put_cpu_var(perf_cpu_context);
+ rcu_read_unlock();
+ }
+
+@@ -3462,6 +3472,9 @@ static void perf_event_mmap_output(struc
+ static int perf_event_mmap_match(struct perf_event *event,
+ struct perf_mmap_event *mmap_event)
+ {
++ if (event->cpu != -1 && event->cpu != smp_processor_id())
++ return 0;
++
+ if (event->attr.mmap)
+ return 1;
+
+@@ -3539,7 +3552,6 @@ got_name:
+
+ cpuctx = &get_cpu_var(perf_cpu_context);
+ perf_event_mmap_ctx(&cpuctx->ctx, mmap_event);
+- put_cpu_var(perf_cpu_context);
+
+ rcu_read_lock();
+ /*
+@@ -3549,6 +3561,7 @@ got_name:
+ ctx = rcu_dereference(current->perf_event_ctxp);
+ if (ctx)
+ perf_event_mmap_ctx(ctx, mmap_event);
++ put_cpu_var(perf_cpu_context);
+ rcu_read_unlock();
+
+ kfree(buf);
+@@ -3811,6 +3824,9 @@ static int perf_swevent_match(struct per
+ enum perf_type_id type,
+ u32 event_id, struct pt_regs *regs)
+ {
++ if (event->cpu != -1 && event->cpu != smp_processor_id())
++ return 0;
++
+ if (!perf_swevent_is_counting(event))
+ return 0;
+
--- /dev/null
+From 22e190851f8709c48baf00ed9ce6144cdc54d025 Mon Sep 17 00:00:00 2001
+From: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Date: Mon, 18 Jan 2010 09:12:32 +0100
+Subject: perf: Honour event state for aux stream data
+
+From: Peter Zijlstra <a.p.zijlstra@chello.nl>
+
+commit 22e190851f8709c48baf00ed9ce6144cdc54d025 upstream.
+
+Anton reported that perf record kept receiving events even after calling
+ioctl(PERF_EVENT_IOC_DISABLE). It turns out that FORK,COMM and MMAP
+events didn't respect the disabled state and kept flowing in.
+
+Reported-by: Anton Blanchard <anton@samba.org>
+Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Tested-by: Anton Blanchard <anton@samba.org>
+LKML-Reference: <1263459187.4244.265.camel@laptop>
+Signed-off-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ kernel/perf_event.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/kernel/perf_event.c
++++ b/kernel/perf_event.c
+@@ -3229,6 +3229,9 @@ static void perf_event_task_output(struc
+
+ static int perf_event_task_match(struct perf_event *event)
+ {
++ if (event->state != PERF_EVENT_STATE_ACTIVE)
++ return 0;
++
+ if (event->cpu != -1 && event->cpu != smp_processor_id())
+ return 0;
+
+@@ -3345,6 +3348,9 @@ static void perf_event_comm_output(struc
+
+ static int perf_event_comm_match(struct perf_event *event)
+ {
++ if (event->state != PERF_EVENT_STATE_ACTIVE)
++ return 0;
++
+ if (event->cpu != -1 && event->cpu != smp_processor_id())
+ return 0;
+
+@@ -3472,6 +3478,9 @@ static void perf_event_mmap_output(struc
+ static int perf_event_mmap_match(struct perf_event *event,
+ struct perf_mmap_event *mmap_event)
+ {
++ if (event->state != PERF_EVENT_STATE_ACTIVE)
++ return 0;
++
+ if (event->cpu != -1 && event->cpu != smp_processor_id())
+ return 0;
+
--- /dev/null
+From 8f06d7e6e1bbfb32698d6d455583ab7460c090e2 Mon Sep 17 00:00:00 2001
+From: Arjan van de Ven <arjan@linux.intel.com>
+Date: Sat, 16 Jan 2010 12:53:19 -0800
+Subject: perf timechart: Use tid not pid for COMM change
+
+From: Arjan van de Ven <arjan@linux.intel.com>
+
+commit 8f06d7e6e1bbfb32698d6d455583ab7460c090e2 upstream.
+
+A process that changes its comm field, does this on a per kernel
+task struct basis. The timechart tool used, incorrectly, the pid
+to track this, and should have used the tid instead...
+
+Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
+Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
+Cc: Mike Galbraith <efault@gmx.de>
+Cc: Paul Mackerras <paulus@samba.org>
+Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Frederic Weisbecker <fweisbec@gmail.com>
+LKML-Reference: <20100116125319.34ac3edd@infradead.org>
+Signed-off-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ tools/perf/builtin-timechart.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/perf/builtin-timechart.c
++++ b/tools/perf/builtin-timechart.c
+@@ -275,7 +275,7 @@ static u64 cpus_pstate_state[MAX_CPUS];
+ static int
+ process_comm_event(event_t *event)
+ {
+- pid_set_comm(event->comm.pid, event->comm.comm);
++ pid_set_comm(event->comm.tid, event->comm.comm);
+ return 0;
+ }
+ static int