Re: missing symbols...
"Brian F. G. Bidulock" <[email protected]>
| Newsgroups | gmane.linux.kernel.streams |
|---|---|
| Organization | http://www.openss7.org/ |
| Message-ID | <[email protected]> |
dan_gora,
sleep_on was removed because it was not MP safe in the first place. You
need to check the condition after already being interruptible and on the
wait queue, otherwise you can sleep forever. And of course you cannot
hold basic locks while calling sleep_on. So it is useless.
sleep_on_interruptible can be interrupted instead of waiting forever
(and you can set a timer that interrupts it) but it does not change the
fact that it is not MP safe either in that you can get behavior far
different that what you want. If you want this type of thing, use a
wait queue (they've only been around for a few hundred kernel versions).
Here it is:
lis_sleep_on(wait_queue_head_t *q)
{
unsigned long flags;
wait_queue_t wait;
init_wait_queue_entry(&wait, current);
current->state = TASK_UNINTERRUPTIBLE;
spin_lock_irqsave(&q->lock, flags);
__add_wait_queue(q, &wait);
spin_unlock(&q->lock);
schedule();
spin_lock_irq(&q->lock);
__remove_wait_queue(q, &wait);
spin_unlock_irqrestore(&q->lock, flags);
}
The problem with a premptive kernel is the uninterruptible wait.
Of course you realize also that if you call this function you will block
the entire LiS kernel thread until something wakes the queue. On a
single threaded UP machine, don't expect any STREAMS queue procedures to
be waking you up ;)
On Linux Fast-STREAMS I have the Solaris style functions qwait(9) and
qwait_sig(9) which are far closer to what is desired. These allow you to
sleep (hopefully momentarily) in the qopen/qclose procedures with
procson for a queue event. This is more what the STREAMS module and
driver writer wants.
Also on Linux Fast-STREAMS I have the SV_ALLOC(9), SV_BROADCAST(9),
SV_DEALLOC(9), SV_SIGNAL(9), SV_WAIT(9) and SV_WAIT_SIG(9) functions.
These functions take a synchronization variable pointer (like a wait
queue head, an interrupt priority, and a locked basic lock).
Just as SVR4.2MP made sleep() unsafe (with signals blocked), Linux 2.4
made sleep_on unsafe. It _was_ usable for 2.0 and 2.2 kernels.
--brian
On Wed, 02 Mar 2005, dan_gora wrote:
> Just to chime in as an update here.
>
> To make things work on RHEL4 x86_64 I had to remove the sleep_on()
> function, lis_sleep_on(), because it is in fact not exported as
> Edward
> pointed out. It's not really clear to me what this is even used for.
> Anyone in the LiS community going to be upset if this function goes
> away? (Not that you really have much choice) I know that we don't
> use it at all.
>
> Also, I put in Edward's trick of just inserting the body of
> cdev_put()
> in place of cdev_put and that does seem to work fine for RHEL 4.0.
>
> Another silly "feature" of RHEL 4.0 is that if you use the kbuild
> method to build your drivers (that is $(MAKE) -C /usr/src/linux -M
> `pwd` modules), RHEL 4.0 gives you -Os and -g for gcc flags by
> default. Ugh. This meant that I had to go around adding 'strip -d
> <filename>' to all my makefiles to get rid of all of the debugging
> crap. Just to let you know...
>
> thanks-
> dan
>
> > >----------
> > >From: Dave Grothe [mailto:[email protected]]
> > >Sent: Thursday, February 10, 2005 10:19 AM
> > >To: Rodrigues, Edward; [email protected]
> > >Cc: Wm. Reich; LiS Mailing List
> > >Subject: RE: [Linux-streams] missing symbols...
> > >
> > >At 08:11 AM 2/10/2005, Rodrigues, Edward wrote:
> > >>
> > >>Hi All,
> > >>
> > >>I did check 2.6.10 kernel. cdev_put() and cdev_get() are not
> > exported.
> > >>
> > >>But sleep_on() and sleep_on_timeout() are still defined as well
> > as
> > >>exported in kernel 2.6.10 unlike RHEL4 or FC-3.
> > >>
> > >>Since some of these symbols are deprecated or obsoleted and hard
> > to
> > >>pursue these kernel folks, can we use sleep_on_interruptible()
> > instead
> > >>of sleep_on() in LiS.
> > >
> > >Does anyone actually use these functions? They are WAY outside
> > the
> > >STREAMS DKI.
> > >
> > >
> > >>In the case of cdev_put can we stick the code in LiS
> > >>
> > >>void cdev_put(struct cdev *p)
> > >>{
> > >> if (p) {
> > >> kobject_put(&p->kobj);
> > >> module_put(p->owner);
> > >> }
> > >>}
> > >>
> > >>BTW: I tried these changes with kernel 2.6.8 and worked fine for
> > me. I
> > >>may not be testing complete functionality -:). It did work on
> > FC-3 as
> > >>well. I am yet to validate RHEL 4.
> > >
> > >This should work just fine. Isn't it odd that they export
> > kobject_put and
> > >module_put but not cdev_put? Seems very irrational to me.
>
> _______________________________________________
> Linux-streams mailing list
> [email protected]
> http://gsyc.escet.urjc.es/mailman/listinfo/linux-streams
--
Brian F. G. Bidulock ¦ The reasonable man adapts himself to the ¦
[email protected] ¦ world; the unreasonable one persists in ¦
http://www.openss7.org/ ¦ trying to adapt the world to himself. ¦
¦ Therefore all progress depends on the ¦
¦ unreasonable man. -- George Bernard Shaw ¦