[discussion not relevant to this reply removed]
Liviu,
I'm just saying that the use case above can't happen because the fields are not updated by thread but by scheduler and it can't be pre-empted by a thread while updating them. We can have the situation where cpu A updates its fields and cpu B reads them simultaneously. This is the use case that i'm trying to address with this patch.
And me and Morten are saying that the compiler and/or system can reorder the reads on CPU B and you have
CPU A (running scheduler) CPU B (running is_buddy_busy) update rq->avg.runnable_avg_sum period = rq->avg.runnable_avg_period new_period = rq->avg.runnable_avg_period update rq->avg.runnable_avg_period sum = rq->avg.runnable_avg_sum new_sum = rq->avg.runnable_avg_sum
while () condition is met and you break out of the loop, using stale value for one of the variables that you then use to decide if the buddy is busy.
Regards, Liviu
Regards, Vincent
[rest of the thread discussion removed for clarity]