Re: [PATCH -stable] workqueue: UNBOUND -> REBIND morphing inrebind_workers() should be atomic

From: Ben Hutchings
Date: Sun Sep 16 2012 - 11:50:43 EST


On Tue, 2012-09-04 at 16:58 -0700, Tejun Heo wrote:
> From: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
>
> The compiler may compile the following code into TWO write/modify
> instructions.
>
> worker->flags &= ~WORKER_UNBOUND;
> worker->flags |= WORKER_REBIND;
>
> so the other CPU may temporarily see worker->flags which doesn't have
> either WORKER_UNBOUND or WORKER_REBIND set and perform local wakeup
> prematurely.
>
> Fix it by using single explicit assignment via ACCESS_ONCE().
>
> Because idle workers have another WORKER_NOT_RUNNING flag, this bug
> doesn't exist for them; however, update it to use the same pattern for
> consistency.
>
> tj: Applied the change to idle workers too and updated comments and
> patch description a bit.
>
> stable: Idle worker rebinding doesn't apply for -stable and
> WORKER_UNBOUND used to be WORKER_ROGUE. Updated accordingly.
[...]

Added to the queue for 3.2, thanks.

Ben.

--
Ben Hutchings
Experience is what causes a person to make new mistakes instead of old ones.

Attachment: signature.asc
Description: This is a digitally signed message part