• Tejun Heo's avatar
    workqueue: set PF_WQ_WORKER on rescuers · 111c225a
    Tejun Heo authored
    PF_WQ_WORKER is used to tell scheduler that the task is a workqueue
    worker and needs wq_worker_sleeping/waking_up() invoked on it for
    concurrency management.  As rescuers never participate in concurrency
    management, PF_WQ_WORKER wasn't set on them.
    
    There's a need for an interface which can query whether %current is
    executing a work item and if so which.  Such interface requires a way
    to identify all tasks which may execute work items and PF_WQ_WORKER
    will be used for that.  As all normal workers always have PF_WQ_WORKER
    set, we only need to add it to rescuers.
    
    As rescuers start with WORKER_PREP but never clear it, it's always
    NOT_RUNNING and there's no need to worry about it interfering with
    concurrency management even if PF_WQ_WORKER is set; however, unlike
    normal workers, rescuers currently don't have its worker struct as
    kthread_data().  It uses the associated workqueue_struct instead.
    This is problematic as wq_worker_sleeping/waking_up() expect struct
    worker at kthread_data().
    
    This patch adds worker->rescue_wq and start rescuer kthreads with
    worker struct as kthread_data and sets PF_WQ_WORKER on rescuers.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    111c225a
workqueue.c 107 KB