public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Poke in the eye regarding sleep_on
@ 2001-11-29  2:15 David Weinehall
  2001-11-29  8:13 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: David Weinehall @ 2001-11-29  2:15 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux-Kernel Mailing List

Since the 2.5 work now has begun, I should remind you Alan that you
promised on this listto take care of getting rid of sleep_on for good
just as soon as this tree opened.

Just in case you forgot ;-)


Regards: David Weinehall
  _                                                                 _
 // David Weinehall <tao@acc.umu.se> /> Northern lights wander      \\
//  Maintainer of the v2.0 kernel   //  Dance across the winter sky //
\>  http://www.acc.umu.se/~tao/    </   Full colour fire           </

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Poke in the eye regarding sleep_on
  2001-11-29  2:15 Poke in the eye regarding sleep_on David Weinehall
@ 2001-11-29  8:13 ` Alan Cox
  2001-11-29 11:09   ` David Woodhouse
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2001-11-29  8:13 UTC (permalink / raw)
  To: David Weinehall; +Cc: Alan Cox, Linux-Kernel Mailing List

> Since the 2.5 work now has begun, I should remind you Alan that you
> promised on this listto take care of getting rid of sleep_on for good
> just as soon as this tree opened.

That was David Woodhouse.. but he is right

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Poke in the eye regarding sleep_on
  2001-11-29  8:13 ` Alan Cox
@ 2001-11-29 11:09   ` David Woodhouse
  0 siblings, 0 replies; 3+ messages in thread
From: David Woodhouse @ 2001-11-29 11:09 UTC (permalink / raw)
  To: Alan Cox; +Cc: David Weinehall, Linux-Kernel Mailing List, torvalds


alan@lxorguk.ukuu.org.uk said:
> > Since the 2.5 work now has begun, I should remind you Alan that you
> > promised on this listto take care of getting rid of sleep_on for good
> > just as soon as this tree opened.

> That was David Woodhouse.. but he is right

There are still cases where it's just about OK to use sleep_on(). If you
_and_ your waker will hold the BKL, or if you call it with IRQs disabled and
are woken from an ISR, which is horrible but does currently work. Also if
you just don't _care_ if you miss a wakeup sometimes.

ISTR much filesystem code falls into the former category at the moment.
 
We _should_ remove sleep_on and friends, but let's start with this patch, 
which allows us to clean up the filesystem code later...

Note that I haven't put the check in the _timeout versions. Maybe we should.

Index: kernel/sched.c
===================================================================
RCS file: /inst/cvs/linux/kernel/sched.c,v
retrieving revision 1.4.2.57
diff -u -r1.4.2.57 sched.c
--- kernel/sched.c	22 Nov 2001 08:41:45 -0000	1.4.2.57
+++ kernel/sched.c	29 Nov 2001 10:57:48 -0000
@@ -777,6 +777,12 @@
 	wait_queue_t wait;			\
 	init_waitqueue_entry(&wait, current);
 
+#define SLEEP_ON_CHECK										\
+	if (current->lock_depth == -1) {							\
+		printk(KERN_WARNING __FUNCTION__ " called without BKL. Probable race.\n");	\
+		BUG();										\
+	}	
+		
 #define	SLEEP_ON_HEAD					\
 	wq_write_lock_irqsave(&q->lock,flags);		\
 	__add_wait_queue(q, &wait);			\
@@ -790,6 +796,7 @@
 void interruptible_sleep_on(wait_queue_head_t *q)
 {
 	SLEEP_ON_VAR
+	SLEEP_ON_CHECK
 
 	current->state = TASK_INTERRUPTIBLE;
 
@@ -814,6 +821,7 @@
 void sleep_on(wait_queue_head_t *q)
 {
 	SLEEP_ON_VAR
+	SLEEP_ON_CHECK
 	
 	current->state = TASK_UNINTERRUPTIBLE;
 



--
dwmw2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-11-29 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-29  2:15 Poke in the eye regarding sleep_on David Weinehall
2001-11-29  8:13 ` Alan Cox
2001-11-29 11:09   ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox