[PATCH][plugsched 5/28] Make sleep functions public

From: Con Kolivas
Date: Sat Oct 30 2004 - 09:46:41 EST


Make sleep functions public

All the sleepstuff can be shared so make it public.

Signed-off-by: Con Kolivas <kernel@xxxxxxxxxxx>


Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/sched.c
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/sched.c 2004-10-29 21:45:10.305945023 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/kernel/sched.c 2004-10-29 21:46:27.313926895 +1000
@@ -2912,77 +2912,6 @@ void fastcall __sched wait_for_completio
}
EXPORT_SYMBOL(wait_for_completion);

-#define SLEEP_ON_VAR \
- unsigned long flags; \
- wait_queue_t wait; \
- init_waitqueue_entry(&wait, current);
-
-#define SLEEP_ON_HEAD \
- spin_lock_irqsave(&q->lock,flags); \
- __add_wait_queue(q, &wait); \
- spin_unlock(&q->lock);
-
-#define SLEEP_ON_TAIL \
- spin_lock_irq(&q->lock); \
- __remove_wait_queue(q, &wait); \
- spin_unlock_irqrestore(&q->lock, flags);
-
-void fastcall __sched interruptible_sleep_on(wait_queue_head_t *q)
-{
- SLEEP_ON_VAR
-
- current->state = TASK_INTERRUPTIBLE;
-
- SLEEP_ON_HEAD
- schedule();
- SLEEP_ON_TAIL
-}
-
-EXPORT_SYMBOL(interruptible_sleep_on);
-
-long fastcall __sched interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
-{
- SLEEP_ON_VAR
-
- current->state = TASK_INTERRUPTIBLE;
-
- SLEEP_ON_HEAD
- timeout = schedule_timeout(timeout);
- SLEEP_ON_TAIL
-
- return timeout;
-}
-
-EXPORT_SYMBOL(interruptible_sleep_on_timeout);
-
-void fastcall __sched sleep_on(wait_queue_head_t *q)
-{
- SLEEP_ON_VAR
-
- current->state = TASK_UNINTERRUPTIBLE;
-
- SLEEP_ON_HEAD
- schedule();
- SLEEP_ON_TAIL
-}
-
-EXPORT_SYMBOL(sleep_on);
-
-long fastcall __sched sleep_on_timeout(wait_queue_head_t *q, long timeout)
-{
- SLEEP_ON_VAR
-
- current->state = TASK_UNINTERRUPTIBLE;
-
- SLEEP_ON_HEAD
- timeout = schedule_timeout(timeout);
- SLEEP_ON_TAIL
-
- return timeout;
-}
-
-EXPORT_SYMBOL(sleep_on_timeout);
-
static void ingo_set_user_nice(task_t *p, long nice)
{
unsigned long flags;
@@ -4710,28 +4639,6 @@ static void __init ingo_sched_init(void)
init_idle(current, smp_processor_id());
}

-#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
-void __might_sleep(char *file, int line)
-{
-#if defined(in_atomic)
- static unsigned long prev_jiffy; /* ratelimiting */
-
- if ((in_atomic() || irqs_disabled()) &&
- system_state == SYSTEM_RUNNING) {
- if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
- return;
- prev_jiffy = jiffies;
- printk(KERN_ERR "Debug: sleeping function called from invalid"
- " context at %s:%d\n", file, line);
- printk("in_atomic():%d, irqs_disabled():%d\n",
- in_atomic(), irqs_disabled());
- dump_stack();
- }
-#endif
-}
-EXPORT_SYMBOL(__might_sleep);
-#endif
-
#if defined(CONFIG_DEBUG_KERNEL)&&defined(CONFIG_SYSCTL)&&defined(CONFIG_SMP)
static struct ctl_table sd_ctl_dir[] = {
{1, "sched_domain", NULL, 0, 0755, NULL, },
Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/scheduler.c
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/scheduler.c 2004-10-29 21:45:13.658421824 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/kernel/scheduler.c 2004-10-29 21:45:18.916601215 +1000
@@ -141,6 +141,99 @@ need_resched:
EXPORT_SYMBOL(preempt_schedule);
#endif /* CONFIG_PREEMPT */

+#define SLEEP_ON_VAR \
+ unsigned long flags; \
+ wait_queue_t wait; \
+ init_waitqueue_entry(&wait, current);
+
+#define SLEEP_ON_HEAD \
+ spin_lock_irqsave(&q->lock,flags); \
+ __add_wait_queue(q, &wait); \
+ spin_unlock(&q->lock);
+
+#define SLEEP_ON_TAIL \
+ spin_lock_irq(&q->lock); \
+ __remove_wait_queue(q, &wait); \
+ spin_unlock_irqrestore(&q->lock, flags);
+
+void fastcall __sched interruptible_sleep_on(wait_queue_head_t *q)
+{
+ SLEEP_ON_VAR
+
+ current->state = TASK_INTERRUPTIBLE;
+
+ SLEEP_ON_HEAD
+ schedule();
+ SLEEP_ON_TAIL
+}
+
+EXPORT_SYMBOL(interruptible_sleep_on);
+
+long fastcall __sched interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
+{
+ SLEEP_ON_VAR
+
+ current->state = TASK_INTERRUPTIBLE;
+
+ SLEEP_ON_HEAD
+ timeout = schedule_timeout(timeout);
+ SLEEP_ON_TAIL
+
+ return timeout;
+}
+
+EXPORT_SYMBOL(interruptible_sleep_on_timeout);
+
+void fastcall __sched sleep_on(wait_queue_head_t *q)
+{
+ SLEEP_ON_VAR
+
+ current->state = TASK_UNINTERRUPTIBLE;
+
+ SLEEP_ON_HEAD
+ schedule();
+ SLEEP_ON_TAIL
+}
+
+EXPORT_SYMBOL(sleep_on);
+
+long fastcall __sched sleep_on_timeout(wait_queue_head_t *q, long timeout)
+{
+ SLEEP_ON_VAR
+
+ current->state = TASK_UNINTERRUPTIBLE;
+
+ SLEEP_ON_HEAD
+ timeout = schedule_timeout(timeout);
+ SLEEP_ON_TAIL
+
+ return timeout;
+}
+
+EXPORT_SYMBOL(sleep_on_timeout);
+
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+void __might_sleep(char *file, int line)
+{
+#if defined(in_atomic)
+ static unsigned long prev_jiffy; /* ratelimiting */
+
+ if ((in_atomic() || irqs_disabled()) &&
+ system_state == SYSTEM_RUNNING) {
+ if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
+ return;
+ prev_jiffy = jiffies;
+ printk(KERN_ERR "Debug: sleeping function called from invalid"
+ " context at %s:%d\n", file, line);
+ printk("in_atomic():%d, irqs_disabled():%d\n",
+ in_atomic(), irqs_disabled());
+ dump_stack();
+ }
+#endif
+}
+EXPORT_SYMBOL(__might_sleep);
+#endif
+
extern struct sched_drv ingo_sched_drv;
static const struct sched_drv *scheduler = &ingo_sched_drv;


Attachment: signature.asc
Description: OpenPGP digital signature