Re: [PATCH 03/12] perf: add perf_event_task_migrate()

Previous thread: [PATCH 04/12] perf: add @rq to perf_event_task_sched_out() by Tejun Heo on Tuesday, May 4, 2010 - 5:38 am. (10 messages)

Next thread: [PATCH 05/12] perf: move perf_event_task_sched_in() next to fire_sched_notifiers_in() by Tejun Heo on Tuesday, May 4, 2010 - 5:38 am. (1 message)
From: Tejun Heo
Date: Tuesday, May 4, 2010 - 5:38 am

Instead of calling perf_sw_event() directly from set_task_cpu(),
implement perf_event_task_migrate() which takes the same arguments as
trace_sched_migrate_task() and invokes perf_sw_event() is the task is
really migrating (cur_cpu != new_cpu).  This will help unifying
notifiers in sched.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 include/linux/perf_event.h |    3 +++
 kernel/perf_event.c        |   11 +++++++++++
 kernel/sched.c             |    5 ++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index c8e3754..a5eec48 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -754,6 +754,7 @@ extern int perf_max_events;
 
 extern const struct pmu *hw_perf_event_init(struct perf_event *event);
 
+extern void perf_event_task_migrate(struct task_struct *task, int new_cpu);
 extern void perf_event_task_sched_in(struct task_struct *task);
 extern void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next);
 extern void perf_event_task_tick(struct task_struct *task);
@@ -949,6 +950,8 @@ extern void perf_event_enable(struct perf_event *event);
 extern void perf_event_disable(struct perf_event *event);
 #else
 static inline void
+perf_event_task_migrate(struct task_struct *task, int new_cpu)		{ }
+static inline void
 perf_event_task_sched_in(struct task_struct *task)			{ }
 static inline void
 perf_event_task_sched_out(struct task_struct *task,
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 3d1552d..a01ba31 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1148,6 +1148,17 @@ static void perf_event_sync_stat(struct perf_event_context *ctx,
 }
 
 /*
+ * Called from scheduler set_task_cpu() to notify migration events.
+ * If the task is moving to a different cpu, ...
From: Frederic Weisbecker
Date: Tuesday, May 4, 2010 - 10:08 pm

This needs to be static and inline (I haven't seem external users in this
patchset).

And we want it to be inlined because we save the caller address and the frame



In fact why not moving both tracing calls under this check.
This is going to fix the migrate trace event that gets called
even on "spurious" migrations, and you avoid the duplicate check
in the perf callback.


--

From: Tejun Heo
Date: Tuesday, May 4, 2010 - 10:16 pm

Hello,


Hmm... after the last patch, this one becomes a TP probe function

Oh I see.  So, to use it with TP, I would need increase the @skip
parameter to perf_fetch_caller_regs() somehow, right?  Also, it
probably would be a good idea to add a comment w/ big fat warning to

Yeah, that would be my preferred choice too.  I just didn't know that
could be changed.  Cool.  I'll.

Thanks.

-- 
tejun
--

From: Peter Zijlstra
Date: Wednesday, May 5, 2010 - 2:11 am

I kept the tracepoint out of that because I wanted to see how often it
attempts silly migrations :-)



--

From: Tejun Heo
Date: Wednesday, May 5, 2010 - 2:37 am

Do you still need to keep it or is it okay to move it under the
silliness check?

Thanks.

-- 
tejun
--

From: Peter Zijlstra
Date: Wednesday, May 5, 2010 - 2:50 am

I guess you can move it, I often end up adding tons of trace_printk()
anyway when hunting funnies, might as well add one here when its
relevant.

--

From: Tejun Heo
Date: Wednesday, May 5, 2010 - 2:56 am

Great, will do so.

Thanks.

-- 
tejun
--

Previous thread: [PATCH 04/12] perf: add @rq to perf_event_task_sched_out() by Tejun Heo on Tuesday, May 4, 2010 - 5:38 am. (10 messages)

Next thread: [PATCH 05/12] perf: move perf_event_task_sched_in() next to fire_sched_notifiers_in() by Tejun Heo on Tuesday, May 4, 2010 - 5:38 am. (1 message)