From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: ffc1e,2a3ebc1d720b61f6 X-Google-Attributes: gidffc1e,public X-Google-Thread: fa528,2a3ebc1d720b61f6 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-09-25 12:04:42 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: ron.jolly@gefanuc.com (Ron Jolly) Newsgroups: comp.unix.tru64,comp.programming.threads Subject: Re: Blocked kernel thread misses wakeup on SMP - Tru64 5.1A Date: 25 Sep 2003 12:04:39 -0700 Organization: http://groups.google.com/ Message-ID: References: <3f7204be$0$10421$626a54ce@news.free.fr> NNTP-Posting-Host: 24.75.75.18 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1064516680 2204 127.0.0.1 (25 Sep 2003 19:04:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Sep 2003 19:04:40 GMT Xref: archiver1.google.com comp.unix.tru64:10819 comp.programming.threads:19068 "Eric Dumazet" wrote in message news:<3f7204be$0$10421$626a54ce@news.free.fr>... > "Ron Jolly" 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