public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: tao@acc.umu.se (David Weinehall),
	linux-kernel@vger.kernel.org (Linux-Kernel Mailing List),
	torvalds@transmeta.com
Subject: Re: Poke in the eye regarding sleep_on
Date: Thu, 29 Nov 2001 11:09:11 +0000	[thread overview]
Message-ID: <15351.1007032151@redhat.com> (raw)
In-Reply-To: <E169MJp-0007m6-00@the-village.bc.nu>
In-Reply-To: <E169MJp-0007m6-00@the-village.bc.nu>


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



      reply	other threads:[~2001-11-29 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15351.1007032151@redhat.com \
    --to=dwmw2@infradead.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tao@acc.umu.se \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox