Re: [RFC][PATCH tip/sched/core] sched/rt: Simplify the IPI rt balancing logic

From: Peter Zijlstra
Date: Mon Apr 24 2017 - 04:52:19 EST


On Fri, Apr 21, 2017 at 10:49:29PM -0400, Steven Rostedt wrote:
> When a CPU schedules in a lower priority task and wants to make sure
> overloaded CPUs know about it. It increments the rto_loop_next. Then it does
> an atomic_inc_return() on rto_loop_start. If the returned value is not "1",
> then it does atomic_dec() on rt_loop_start and returns. If the value is "1",
> then it will take the rto_lock to synchronize with a possible IPI being sent
> around to the overloaded CPUs.

> + start = atomic_inc_return(&rq->rd->rto_loop_start);
> + if (start != 1)
> + goto out;

> +out:
> + atomic_dec(&rq->rd->rto_loop_start);


Did you just write a very expensive test-and-set trylock?