• T
    workqueue: update synchronization rules on workqueue->pwqs · 76af4d93
    Tejun Heo 提交于
    Make workqueue->pwqs protected by workqueue_lock for writes and
    sched-RCU protected for reads.  Lockdep assertions are added to
    for_each_pwq() and first_pwq() and all their users are converted to
    either hold workqueue_lock or disable preemption/irq.
    
    alloc_and_link_pwqs() is updated to use list_add_tail_rcu() for
    consistency which isn't strictly necessary as the workqueue isn't
    visible.  destroy_workqueue() isn't updated to sched-RCU release pwqs.
    This is okay as the workqueue should have on users left by that point.
    
    The locking is superflous at this point.  This is to help
    implementation of unbound pools/pwqs with custom attributes.
    
    This patch doesn't introduce any behavior changes.
    
    v2: Updated for_each_pwq() use if/else for the hidden assertion
        statement instead of just if as suggested by Lai.  This avoids
        confusing the following else clause.
    Signed-off-by: NTejun Heo <tj@kernel.org>
    Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
    76af4d93
workqueue.c 104.5 KB