• Tejun Heo's avatar
    workqueue: introduce kmem_cache for pool_workqueues · e904e6c2
    Tejun Heo authored
    pool_workqueues need to be aligned to 1 << WORK_STRUCT_FLAG_BITS as
    the lower bits of work->data are used for flags when they're pointing
    to pool_workqueues.
    
    Due to historical reasons, unbound pool_workqueues are allocated using
    kzalloc() with sufficient buffer area for alignment and aligned
    manually.  The original pointer is stored at the end which free_pwqs()
    retrieves when freeing it.
    
    There's no reason for this hackery anymore.  Set alignment of struct
    pool_workqueue to 1 << WORK_STRUCT_FLAG_BITS, add kmem_cache for
    pool_workqueues with proper alignment and replace the hacky alloc and
    free implementation with plain kmem_cache_zalloc/free().
    
    In case WORK_STRUCT_FLAG_BITS gets shrunk too much and makes fields of
    pool_workqueues misaligned, trigger WARN if the alignment of struct
    pool_workqueue becomes smaller than that of long long.
    
    Note that assertion on IS_ALIGNED() is removed from alloc_pwqs().  We
    already have another one in pwq init loop in __alloc_workqueue_key().
    
    This patch doesn't introduce any visible behavior changes.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reviewed-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
    e904e6c2
workqueue.c 104 KB