• Tejun Heo's avatar
    workqueue: Move pwq_dec_nr_in_flight() to the end of work item handling · dd6c3c54
    Tejun Heo authored
    The planned shared nr_active handling for unbound workqueues will make
    pwq_dec_nr_active() sometimes drop the pool lock temporarily to acquire
    other pool locks, which is necessary as retirement of an nr_active count
    from one pool may need kick off an inactive work item in another pool.
    
    This patch moves pwq_dec_nr_in_flight() call in try_to_grab_pending() to the
    end of work item handling so that work item state changes stay atomic.
    process_one_work() which is the other user of pwq_dec_nr_in_flight() already
    calls it at the end of work item handling. Comments are added to both call
    sites and pwq_dec_nr_in_flight().
    
    This shouldn't cause any behavior changes.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reviewed-by: default avatarLai Jiangshan <jiangshanlai@gmail.com>
    dd6c3c54
workqueue.c 195 KB