]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - kernel/events/core.c
perf_counter: fix race in perf_output_*
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Fri, 1 May 2009 10:23:16 +0000 (12:23 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 1 May 2009 11:23:43 +0000 (13:23 +0200)
commitc33a0bc4e41ef169d6e807d8abb9502544b518e5
treef7ba55205352cd91a4f86999710008e89932ef10
parent3c56999eec7acc105a31b4546c94aad2fb844b13
perf_counter: fix race in perf_output_*

When two (or more) contexts output to the same buffer, it is possible
to observe half written output.

Suppose we have CPU0 doing perf_counter_mmap(), CPU1 doing
perf_counter_overflow(). If CPU1 does a wakeup and exposes head to
user-space, then CPU2 can observe the data CPU0 is still writing.

[ Impact: fix occasionally corrupted profiling records ]

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090501102533.007821627@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/perf_counter.h
kernel/perf_counter.c