perf/core: Fix time on IOC_ENABLE
authorPeter Zijlstra <peterz@infradead.org>
Thu, 3 Aug 2017 13:42:09 +0000 (15:42 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 10 Aug 2017 10:01:09 +0000 (12:01 +0200)
commit9b231d9f47c6114d317ce28cff92a74ad80547f5
tree97e34b1a82a56ab28046055a0c4dfc6d288c228f
parentbfe334924ccd9f4a53f30240c03cf2f43f5b2df1
perf/core: Fix time on IOC_ENABLE

Vince reported that when we do IOC_ENABLE/IOC_DISABLE while the task
is SIGSTOP'ed state the timestamps go wobbly.

It turns out we indeed fail to correctly account time while in 'OFF'
state and doing IOC_ENABLE without getting scheduled in exposes the
problem.

Further thinking about this problem, it occurred to me that we can
suffer a similar fate when we migrate an uncore event between CPUs.
The perf_event_install() on the 'new' CPU will do add_event_to_ctx()
which will reset all the time stamp, resulting in a subsequent
update_event_times() to overwrite the total_time_* fields with smaller
values.

Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/core.c