[RFC PATCH 05/15] ARM: perf: move active_events into struct arm_pmu

Will Deacon will.deacon at arm.com
Mon Aug 22 15:51:57 EDT 2011


Ashwin,

On Mon, Aug 22, 2011 at 07:25:52PM +0100, Ashwin Chaugule wrote:
> Hi Mark,
> 
> >> From: Mark Rutland 
> >> 	case PERF_TYPE_RAW:
> >> @@ -556,15 +559,14 @@ static int armpmu_event_init(struct perf_event
> >> *event)
> >>
> >> 	event->destroy = hw_perf_event_destroy;
> >>
> >> -	if (!atomic_inc_not_zero(&active_events)) {
> >> -		mutex_lock(&pmu_reserve_mutex);
> >> -		if (atomic_read(&active_events) == 0) {
> >> +	if (!atomic_inc_not_zero(active_events)) {
> >> +		mutex_lock(&armpmu->reserve_mutex);
> >> +		if (atomic_read(active_events) == 0)
> 
> 
> Isn't this use of atomic_* still racy ?

I don't believe so.

> http://www.spinics.net/lists/arm-kernel/msg123297.html

That thread is referring to previous behaviour where it was assumed that a
group of atomic operations would execute as an atomic block. The code
in question was fixed in 57ce9bb3 ("ARM: 6902/1: perf: Remove erroneous check
on active_events").

Now that we only modify active_events with the reserve_mutex held, we're
safe as houses.

Will



More information about the linux-arm-kernel mailing list