• L
    workqueue: UNBOUND -> REBIND morphing in rebind_workers() should be atomic · 96e65306
    Lai Jiangshan 提交于
    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.
    Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
    Signed-off-by: NTejun Heo <tj@kernel.org>
    Cc: stable@vger.kernel.org
    96e65306
workqueue.c 102.3 KB