SMP share data declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I know that an integer variable should be declared volatile to share between
CPUs.
But for more complicated variable, I don't know if it should be volatile.
for example:

linux-2.6.6/kernel/workqueue.c:
struct workqueue_struct *__create_workqueue(const char *name,int
singlethread)
{
    ...
    if (singlethread) {
        ...
    } else {
        spin_lock(&workqueue_lock);
        list_add(&wq->list, &workqueues);
        spin_unlock_irq(&workqueue_lock);
        ...
    }
    ...
}

workqueues is a none volatile list_head. The spin_lock/unlock act as memory
barrier, so gcc flush any register cached value to memory. But if another
CPU allocate workqueues.next/prev in registers, how to make sure this cpu
get new value ?

static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
      unsigned long action,
      void *hcpu)
{
    ...
    switch (action) {
    case CPU_UP_PREPARE:
    /* Create a new workqueue thread for it. */
    list_for_each_entry(wq, &workqueues, list) {
        ...
}

how to make sure workqueue_cpu_callback() get new value ?

thanks very much


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux