• Tejun Heo's avatar
    workqueue: fix unbound workqueue attrs hashing / comparison · 13e2e556
    Tejun Heo authored
    29c91e99 ("workqueue: implement attribute-based unbound worker_pool
    management") implemented attrs based worker_pool matching.  It tried
    to avoid false negative when comparing cpumasks with custom hash
    function; unfortunately, the hash and comparison functions fail to
    ignore CPUs which are not possible.  It incorrectly assumed that
    bitmap_copy() skips leftover bits in the last word of bitmap and
    cpumask_equal() ignores impossible CPUs.
    
    This patch updates attrs->cpumask handling such that impossible CPUs
    are properly ignored.
    
    * Hash and copy functions no longer do anything special.  They expect
      their callers to clear impossible CPUs.
    
    * alloc_workqueue_attrs() initializes the cpumask to cpu_possible_mask
      instead of setting all bits and explicit cpumask_setall() for
      unbound_std_wq_attrs[] in init_workqueues() is dropped.
    
    * apply_workqueue_attrs() is now responsible for ignoring impossible
      CPUs.  It makes a copy of @attrs and clears impossible CPUs before
      doing anything else.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    13e2e556
workqueue.c 122 KB