All of lore.kernel.org
 help / color / mirror / Atom feed
From: martin rogers <martin.rogers@windriver.com>
To: linux-kernel@vger.kernel.org
Subject: Help with 2.6.10 concurrency issue
Date: Thu, 09 Feb 2006 16:08:04 -0500	[thread overview]
Message-ID: <43EBAF34.1020105@windriver.com> (raw)

All,
I need help with a concurrency issue on 2.6.10.
CONFIG_PREEMPT not set, but my code must run on both uni and SMP systems.


I have a function, that runs from a tastlet:

void readlist(unsigned long arg)
{    
  int flags;
  my_type *entry, *n;

  if (list_empty(&mylist.list)) return;
  list_for_each_entry_safe(entry, n, &mylist.list, list)
  {
        spin_lock_irqsave(&mylock, flags); // protect against intr
        list_del(&entry->list);
        spin_unlock_irqrestore(&mylock, flags);
        INIT_LIST_HEAD(&entry->list);
        do_stuff(entry);
  }
}


And the func that puts things on the list:

void writeList(my_type *record)
{
  spin_lock(&mylock);
  list_add_tail(&record->list, &mylist.list);
  spin_unlock(&mylock);
  tasklet_schedule(&mytasklet.tlet);
}


Problem is, the function writeList can be called from a H/W intr,
and a workqueue (and that intr could of course happen while either
the workqueue or the tasklet is running, right?).

If I use spin_lock_irqsave in writeList, it protects against the intr
but not the tasklet.  If I use spin_lock_bh, I don't get protection
from the intr I think; plus, I get :

Badness in local_bh_enable at kernel/softirq.c:142

when the intr runs (what does this mean?).

So, how can I protect my data (my list) from both intrs (calling
writeList) and the tasklet (calling readList) while the workqueue is
inside of writeList?  Combination of spin_lock_irqsave and local_bh_disable
inside writeList ?

Thanks to all,
Martin Rogers
Wind River


             reply	other threads:[~2006-02-09 21:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-09 21:08 martin rogers [this message]
     [not found] <5Erdv-5iS-39@gated-at.bofh.it>
2006-02-10  0:48 ` Help with 2.6.10 concurrency issue Robert Hancock

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=43EBAF34.1020105@windriver.com \
    --to=martin.rogers@windriver.com \
    --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.