perf: Do poll_wait() before checking condition in perf_poll()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Mon, 4 Aug 2014 13:31:08 +0000 (15:31 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 13 Aug 2014 05:51:11 +0000 (07:51 +0200)
commite708d7ad80737496870fd0b6794704d063fb0cdc
treedf4cd87b90efc33e2162c790d07dc4df42faabfd
parent36bbb2f2988a29cdc3f8e0c93478795934553454
perf: Do poll_wait() before checking condition in perf_poll()

One should first enqueue to the waitqueue and then check for the
condition. If the condition gets true after mutex_unlock() but before
poll_wait() then we lose it and would have wait for another wakeup.

This has been like this since v2.6.31-rc1 commit c7138f37f9 ("perf_counter:
fix perf_poll()"). Before that it was slightly worse. I guess we get enough
wakeups so if we miss here one it doesn't really matter. It is still a
bad example.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1407159068-1478-1-git-send-email-bigeasy@linutronix.de
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/core.c