• Tejun Heo's avatar
    workqueue: prepare flush_workqueue() for dynamic creation and destrucion of unbound pool_workqueues · 75ccf595
    Tejun Heo authored
    Unbound pwqs (pool_workqueues) will be dynamically created and
    destroyed with the scheduled unbound workqueue w/ custom attributes
    support.  This patch synchronizes pwq linking and unlinking against
    flush_workqueue() so that its operation isn't disturbed by pwqs coming
    and going.
    
    Linking and unlinking a pwq into wq->pwqs is now protected also by
    wq->flush_mutex and a new pwq's work_color is initialized to
    wq->work_color during linking.  This ensures that pwqs changes don't
    disturb flush_workqueue() in progress and the new pwq's work coloring
    stays in sync with the rest of the workqueue.
    
    flush_mutex during unlinking isn't strictly necessary but it's simpler
    to do it anyway.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reviewed-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
    75ccf595
workqueue.c 114 KB