[PATCH 3/8] perf: disable events when we detach them

Peter Zijlstra
2009-11-23T10:42:19Z

[-- Attachment #1: perf-foo-4.patch --]
[-- Type: text/plain, Size: 783 bytes --]

If we leave the event in STATE_INACTIVE, any read of the event after
the detach will increase the running count but not the enabled count
and cause funny scaling artefacts.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/perf_event.c | 2 ++
1 file changed, 2 insertions(+)

Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -294,6 +294,8 @@ list_del_event(struct perf_event *event,
if (event->group_leader != event)
event->group_leader->nr_siblings--;

+ event->state = PERF_EVENT_STATE_OFF;
+
/*
* If this was a group event with sibling events then
* upgrade the siblings to singleton events by adding them

--