From: ron.jolly@gefanuc.com (Ron Jolly)
Subject: Re: Blocked kernel thread misses wakeup on SMP - Tru64 5.1A
Date: 25 Sep 2003 12:04:39 -0700 [thread overview]
Message-ID: <c76164d.0309251104.53d09f38@posting.google.com> (raw)
In-Reply-To: 3f7204be$0$10421$626a54ce@news.free.fr
"Eric Dumazet" <jsiour@nospam.cosmosbay.com> wrote in message news:<3f7204be$0$10421$626a54ce@news.free.fr>...
> "Ron Jolly" <ron.jolly@gefanuc.com> a �crit dans le message de
> news:c76164d.0309231336.377f5148@posting.google.com...
> > Hello all,
> > I have a device driver operating on Tru64 that appears to miss
> > catching a thread_wakeup_one() only on a SMP system.
> >
> > Here is the scenario:
> > The driver is for a PCI network memory board that has a DMA controller
> > for moving data from the PCI contained memory to main system memory.
> > I have a command line utility which allows me to select DMA reads or
> > writes through an API call.
> > When a DMA operation needs to be performed,
> > the driver sets up a simple_lock(), sets the DMA controller registers,
> > then as the last operation, starts the
> > DMA. I then go into an mpsleep(), unlock the simple
> > lock, and block waiting for a wakeup or timeout. When the DMA has
> > finished,
>
>
> what do you mean ? You manually unlock the simple lock before calling
> mpsleep() ?
> The locking kernel services works only if you use it correctly as :
>
> lock_write(&mydriverlock) ;
> initiate_transfert() ;
> while (!finished_transfert()) {
> mpsleep(&mycondaddr, PCATCH | (PZERO + 1), "mydrivername", 0,
> &mydriverlock, MS_LOCK_WRITE | MS_LOCK_ON_ERROR) ;
> }
> ok_done:
> lock_done(&mydriverlock) ;
...deleted addtional
Thanks for the suggestions to Mr Dumazet and Mr. Butenhof.
In my driver code, I am doing precisely what you have
in your snippet of code. The statement I made "unlock the simple
lock..." should not have been listed in the sequence of steps. No, I
do not manually unlock the simple lock before calling mpsleep(). Only
after the operation has completed do I call the unlock().
One thing that you have in the sample that I do not have implemented,
is the "(PZERO + 1)" for the priority. My code is setting this to
PZERO only. I recompiled with the PZERO+1, but it did not make any
difference. I still
miss a thread_wakeup_one call.
I have a Linux driver for the same hardware that approaches this
problem in a different way. The assumption is that at some point you
may miss a wakeup, so go ahead and code for this condition. In Linux
you plan for it by going "halfway asleep". See the O'Reilly book,
"Linux Device Drivers" by Rubini and Corbet.
In chapter 9, the section,"Going to Sleep Without Races" (online at
http://www.xml.com/ldd/chapter/book/ch09.html ) explains
how this is done, on page 287.....
From the book:
/*************************************************************************
The way to solve this problem is to go halfway to sleep before
performing the test. The idea is that the process can add itself to
the wait queue, declare itself to be sleeping, and then perform its
tests. This is the typical implementation:
wait_queue_t wait;
init_waitqueue_entry(&wait, current);
add_wait_queue(&short_queue, &wait);
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
if (short_head != short_tail) /* whatever test your driver needs
*/
break;
schedule();
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&short_queue, &wait);
**************************************************************************/
This works for my driver on Linux. The code runs without error on an
SMP system. Question is, how is this performed on Tru64?
Do I have access to the wait queue? How do I access the scheduler?
Any thoughts on why the current implementation works successfully on a
12 CPU NUMA (GS160) system but fails on a SMP system?
thanks
Ron
> > Any suggestions welcomed...
> > thanks,
> > Ron Jolly
> > GE Embedded Systems
> > ron.jolly at gefanuc dot com
next prev parent reply other threads:[~2003-09-25 19:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-23 21:36 Blocked kernel thread misses wakeup on SMP - Tru64 5.1A Ron Jolly
2003-09-24 20:55 ` Eric Dumazet
2003-09-25 19:04 ` Ron Jolly [this message]
2003-09-26 17:39 ` Eric Dumazet
2003-09-25 10:35 ` David Butenhof
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox