perf: Fix software migrate events
authorPeter Zijlstra <peterz@infradead.org>
Fri, 17 Apr 2015 18:05:30 +0000 (20:05 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 8 May 2015 10:25:38 +0000 (12:25 +0200)
commitff303e66c240ba6269e31817a386995440a18c99
treeaa4e506beabc409966d9cda0c722dee41e8d8ce9
parent1836ac856e4fb446e48afa4f8cae897d4856b06c
perf: Fix software migrate events

Stephane asked about PERF_COUNT_SW_CPU_MIGRATIONS and I realized it
was borken:

 > The problem is that the task isn't actually scheduled while its being
 > migrated (obviously), and if its not scheduled, the counters aren't
 > scheduled either, so there's no observing of the fact.
 >
 > A further problem with migrations is that many migrations happen from
 > softirq context, which is nested inside the 'random' task context of
 > whoemever happens to run at that time, similarly for the wakeup
 > migrations triggered from (soft)irq context. All those end up being
 > accounted in the task that's currently running, eg. your 'ls'.

The below cures this by marking a task as migrated and accounting it
on the subsequent sched_in().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/perf_event.h
include/linux/sched.h
kernel/sched/core.c