Skip to content

Commit

Permalink
perf: Fix forgotten preempt_enable by nested writers
Browse files Browse the repository at this point in the history
A writer that gets a reference to the buffer handle disables
preemption. When we put that reference, we check if we are
the outer most writer and if not, we simply return and defer
the head update to the outer most writer. The problem here
is that preemption is only reenabled by the outer most, that
produces preemption count imbalance for every nested writer
that exit.

So just don't forget to always re-enable preemption when we
put the buffer reference, whoever we are.

Fixes lots of sleeping in atomic warnings, visible with lock
events recording.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Robert Richter <robert.richter@amd.com>
  • Loading branch information
Frederic Weisbecker committed May 20, 2010
1 parent dfacc4d commit acd35a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@ static void perf_output_put_handle(struct perf_output_handle *handle)
*/

if (!local_dec_and_test(&data->nest))
return;
goto out;

/*
* Publish the known good head. Rely on the full barrier implied
Expand All @@ -2954,6 +2954,7 @@ static void perf_output_put_handle(struct perf_output_handle *handle)
if (handle->wakeup != local_read(&data->wakeup))
perf_output_wakeup(handle);

out:
preempt_enable();
}

Expand Down

0 comments on commit acd35a4

Please sign in to comment.