• T
    workqueue: update cwq alignement · 0f900049
    Tejun Heo 提交于
    work->data field is used for two purposes.  It points to cwq it's
    queued on and the lower bits are used for flags.  Currently, two bits
    are reserved which is always safe as 4 byte alignment is guaranteed on
    every architecture.  However, future changes will need more flag bits.
    
    On SMP, the percpu allocator is capable of honoring larger alignment
    (there are other users which depend on it) and larger alignment works
    just fine.  On UP, percpu allocator is a thin wrapper around
    kzalloc/kfree() and don't honor alignment request.
    
    This patch introduces WORK_STRUCT_FLAG_BITS and implements
    alloc/free_cwqs() which guarantees max(1 << WORK_STRUCT_FLAG_BITS,
    __alignof__(unsigned long long) alignment both on SMP and UP.  On SMP,
    simply wrapping percpu allocator is enough.  On UP, extra space is
    allocated so that cwq can be aligned and the original pointer can be
    stored after it which is used in the free path.
    
    * Alignment problem on UP is reported by Michal Simek.
    Signed-off-by: NTejun Heo <tj@kernel.org>
    Cc: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Reported-by: NMichal Simek <michal.simek@petalogix.com>
    0f900049
workqueue.c 30.9 KB