* Help with 2.6.10 concurrency issue
@ 2006-02-09 21:08 martin rogers
0 siblings, 0 replies; 2+ messages in thread
From: martin rogers @ 2006-02-09 21:08 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread[parent not found: <5Erdv-5iS-39@gated-at.bofh.it>]
* Re: Help with 2.6.10 concurrency issue
[not found] <5Erdv-5iS-39@gated-at.bofh.it>
@ 2006-02-10 0:48 ` Robert Hancock
0 siblings, 0 replies; 2+ messages in thread
From: Robert Hancock @ 2006-02-10 0:48 UTC (permalink / raw)
To: linux-kernel
martin rogers wrote:
> 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.
Yes, it protects against the tasklet as well. Disabling interrupts also
implicity disables BH execution (tasklets).
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?).
It means you're enabling BHs when interrupts are disabled, which doesn't
make any sense. You can't use spin_lock_bh/spin_unlock_bh when
interrupts are disabled.
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-10 0:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-09 21:08 Help with 2.6.10 concurrency issue martin rogers
[not found] <5Erdv-5iS-39@gated-at.bofh.it>
2006-02-10 0:48 ` Robert Hancock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox