linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: [PATCH 16/16] NOTYET: sched: remove sleep_on() and friends
Date: Wed, 26 Feb 2014 12:01:56 +0100	[thread overview]
Message-ID: <1393412516-3762435-17-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1393412516-3762435-1-git-send-email-arnd@arndb.de>

Do not apply yet, we first have to wait for the other patches
in the series to get merged. Comments appreciated.

8<----

We probably should have done this 15 years ago. I have created patches
for every remaining user of the four sleep_on variants that are all
broken, and this patch should get applied as soon as all of the other
patches are merged.

If you are reading this changeset because you are looking for the
functions I removed, please convert your code to use wait_event,
wait_for_completion or an open-coded prepare_to_wait loop.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
---
 Documentation/DocBook/kernel-hacking.tmpl | 10 -------
 include/linux/wait.h                      | 11 --------
 kernel/sched/core.c                       | 46 -------------------------------
 3 files changed, 67 deletions(-)

diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
index d0758b24..bd9015d 100644
--- a/Documentation/DocBook/kernel-hacking.tmpl
+++ b/Documentation/DocBook/kernel-hacking.tmpl
@@ -850,16 +850,6 @@ printk(KERN_INFO "my ip: %pI4\n", &amp;ipaddress);
     <returnvalue>-ERESTARTSYS</returnvalue> if a signal is received.
     The <function>wait_event()</function> version ignores signals.
    </para>
-   <para>
-   Do not use the <function>sleep_on()</function> function family -
-   it is very easy to accidentally introduce races; almost certainly
-   one of the <function>wait_event()</function> family will do, or a
-   loop around <function>schedule_timeout()</function>. If you choose
-   to loop around <function>schedule_timeout()</function> remember
-   you must set the task state (with 
-   <function>set_current_state()</function>) on each iteration to avoid
-   busy-looping.
-   </para>
  
   </sect1>
 
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 559044c..e7d9d9e 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -803,17 +803,6 @@ do {									\
 	__ret;								\
 })
 
-
-/*
- * These are the old interfaces to sleep waiting for an event.
- * They are racy.  DO NOT use them, use the wait_event* interfaces above.
- * We plan to remove these interfaces.
- */
-extern void sleep_on(wait_queue_head_t *q);
-extern long sleep_on_timeout(wait_queue_head_t *q, signed long timeout);
-extern void interruptible_sleep_on(wait_queue_head_t *q);
-extern long interruptible_sleep_on_timeout(wait_queue_head_t *q, signed long timeout);
-
 /*
  * Waitqueues which are removed from the waitqueue_head at wakeup time
  */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b46131e..25377f4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2852,52 +2852,6 @@ int default_wake_function(wait_queue_t *curr, unsigned mode, int wake_flags,
 }
 EXPORT_SYMBOL(default_wake_function);
 
-static long __sched
-sleep_on_common(wait_queue_head_t *q, int state, long timeout)
-{
-	unsigned long flags;
-	wait_queue_t wait;
-
-	init_waitqueue_entry(&wait, current);
-
-	__set_current_state(state);
-
-	spin_lock_irqsave(&q->lock, flags);
-	__add_wait_queue(q, &wait);
-	spin_unlock(&q->lock);
-	timeout = schedule_timeout(timeout);
-	spin_lock_irq(&q->lock);
-	__remove_wait_queue(q, &wait);
-	spin_unlock_irqrestore(&q->lock, flags);
-
-	return timeout;
-}
-
-void __sched interruptible_sleep_on(wait_queue_head_t *q)
-{
-	sleep_on_common(q, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
-}
-EXPORT_SYMBOL(interruptible_sleep_on);
-
-long __sched
-interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
-{
-	return sleep_on_common(q, TASK_INTERRUPTIBLE, timeout);
-}
-EXPORT_SYMBOL(interruptible_sleep_on_timeout);
-
-void __sched sleep_on(wait_queue_head_t *q)
-{
-	sleep_on_common(q, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
-}
-EXPORT_SYMBOL(sleep_on);
-
-long __sched sleep_on_timeout(wait_queue_head_t *q, long timeout)
-{
-	return sleep_on_common(q, TASK_UNINTERRUPTIBLE, timeout);
-}
-EXPORT_SYMBOL(sleep_on_timeout);
-
 #ifdef CONFIG_RT_MUTEXES
 
 /*
-- 
1.8.3.2


  parent reply	other threads:[~2014-02-26 11:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26 11:01 [PATCH 00/16] sleep_on removal, second try Arnd Bergmann
2014-02-26 11:01 ` [PATCH 01/16] ataflop: fix sleep_on races Arnd Bergmann
2014-02-26 11:01 ` [PATCH 02/16] scsi: atari_scsi: fix sleep_on race Arnd Bergmann
2014-02-27  7:58   ` Michael Schmitz
2014-02-27 20:44     ` Arnd Bergmann
2014-03-01  0:24       ` Michael Schmitz
2014-02-26 11:01 ` [PATCH 03/16] DAC960: remove sleep_on usage Arnd Bergmann
2014-02-26 11:01 ` [PATCH 04/16] swim3: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 05/16] [media] omap_vout: avoid sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 06/16] [media] usbvision: drop unused define USBVISION_SAY_AND_WAIT Arnd Bergmann
2014-02-26 11:01 ` [PATCH 07/16] [media] radio-cadet: avoid interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 08/16] [media] arv: fix sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 09/16] parport: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 10/16] atm: nicstar: remove interruptible_sleep_on_timeout Arnd Bergmann
2014-02-26 16:06   ` David Miller
2014-02-27 18:51     ` [PATCH v3] " Arnd Bergmann
2014-02-27 20:23       ` David Miller
2014-02-26 11:01 ` [PATCH 11/16] atm: firestream: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 12/16] isdn: pcbit: " Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 13/16] isdn: hisax/elsa: fix sleep_on race in elsa FSM Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 14/16] isdn: divert, hysdn: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 15/16] isdn: fix multiple sleep_on races Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` Arnd Bergmann [this message]
2014-02-26 17:36 ` [PATCH 00/16] sleep_on removal, second try Jens Axboe
2014-02-27  6:37 ` Michael Schmitz
2014-02-27 11:55   ` Geert Uytterhoeven
2014-02-28  8:53 ` Karsten Keil

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=1393412516-3762435-17-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).