All of lore.kernel.org
 help / color / mirror / Atom feed
From: <wyb@topsec.com.cn>
To: <linux-kernel@vger.kernel.org>
Subject: SMP share data declaration
Date: Fri, 14 Jul 2006 10:58:57 +0800	[thread overview]
Message-ID: <002001c6a6f1$74ff85f0$0100000a@codingman> (raw)

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



             reply	other threads:[~2006-07-14  3:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-14  2:58 wyb [this message]
2006-07-14  8:48 ` SMP share data declaration Jesper Juhl
2006-07-14 11:31   ` Hannibal B

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='002001c6a6f1$74ff85f0$0100000a@codingman' \
    --to=wyb@topsec.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.