lkml.org 
[lkml]   [2010]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 17/43] workqueue: update cwq alignement
    On 02/26, Tejun Heo wrote:
    >
    > +static struct cpu_workqueue_struct *alloc_cwqs(void)
    > +{
    > + const size_t size = sizeof(struct cpu_workqueue_struct);
    > + const size_t align = 1 << WORK_STRUCT_FLAG_BITS;
    > + struct cpu_workqueue_struct *cwqs;
    > +#ifndef CONFIG_SMP
    > + void *ptr;
    > +
    > + /*
    > + * On UP, percpu allocator doesn't honor alignment parameter
    > + * and simply uses arch-dependent default. Allocate enough
    > + * room to align cwq and put an extra pointer at the end
    > + * pointing back to the originally allocated pointer which
    > + * will be used for free.
    > + */
    > + ptr = __alloc_percpu(size + align + sizeof(void *), 1);
    > + cwqs = PTR_ALIGN(ptr, align);
    > + *(void **)per_cpu_ptr(cwqs + 1, 0) = ptr;
    > +#else

    Nice trick, but perhaps it would be more simple/clear to just add
    "void *my_memory" into cpu_workqueue_struct, under !CONFIG_SMP ?

    Oleg.



    \
     
     \ /
      Last update: 2010-02-28 18:17    [W:4.238 / U:0.180 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site