--- include/linux/sched.h | 13 ------ include/linux/sched/rt.h | 13 ++++++ kernel/sched/bfs.c | 91 +++++++++++++++++++++++++++++++++++------------ 3 files changed, 81 insertions(+), 36 deletions(-) Index: linux-3.9-bfs/kernel/sched/bfs.c =================================================================== --- linux-3.9-bfs.orig/kernel/sched/bfs.c 2013-05-02 21:57:34.388963117 +1000 +++ linux-3.9-bfs/kernel/sched/bfs.c 2013-05-02 22:16:30.187763678 +1000 @@ -80,7 +80,7 @@ #endif #include "cpupri.h" -#include "../workqueue_sched.h" +#include "../workqueue_internal.h" #include "../smpboot.h" #define CREATE_TRACE_POINTS @@ -1845,9 +1845,8 @@ EXPORT_SYMBOL_GPL(preempt_notifier_unreg static void fire_sched_in_preempt_notifiers(struct task_struct *curr) { struct preempt_notifier *notifier; - struct hlist_node *node; - hlist_for_each_entry(notifier, node, &curr->preempt_notifiers, link) + hlist_for_each_entry(notifier, &curr->preempt_notifiers, link) notifier->ops->sched_in(notifier, raw_smp_processor_id()); } @@ -1856,9 +1855,8 @@ fire_sched_out_preempt_notifiers(struct struct task_struct *next) { struct preempt_notifier *notifier; - struct hlist_node *node; - hlist_for_each_entry(notifier, node, &curr->preempt_notifiers, link) + hlist_for_each_entry(notifier, &curr->preempt_notifiers, link) notifier->ops->sched_out(notifier, next); } @@ -2031,9 +2029,8 @@ context_switch(struct rq *rq, struct tas * nr_running, nr_uninterruptible and nr_context_switches: * * externally visible scheduler statistics: current number of runnable - * threads, current number of uninterruptible-sleeping threads, total - * number of context switches performed since bootup. All are measured - * without grabbing the grq lock but the occasional inaccurate result + * threads, total number of context switches performed since bootup. All are + * measured without grabbing the grq lock but the occasional inaccurate result * doesn't matter so long as it's positive. */ unsigned long nr_running(void) @@ -2045,7 +2042,7 @@ unsigned long nr_running(void) return (unsigned long)nr; } -unsigned long nr_uninterruptible(void) +static unsigned long nr_uninterruptible(void) { long nu = grq.nr_uninterruptible; @@ -3201,6 +3198,7 @@ static noinline void __schedule_bug(stru if (irqs_disabled()) print_irqtrace_events(prev); dump_stack(); + add_taint(TAINT_WARN, LOCKDEP_STILL_OK); } /* @@ -3738,7 +3736,8 @@ void complete_all(struct completion *x) EXPORT_SYMBOL(complete_all); static inline long __sched -do_wait_for_common(struct completion *x, long timeout, int state) +do_wait_for_common(struct completion *x, + long (*action)(long), long timeout, int state) { if (!x->done) { DECLARE_WAITQUEUE(wait, current); @@ -3751,7 +3750,7 @@ do_wait_for_common(struct completion *x, } __set_current_state(state); spin_unlock_irq(&x->wait.lock); - timeout = schedule_timeout(timeout); + timeout = action(timeout); spin_lock_irq(&x->wait.lock); } while (!x->done && timeout); __remove_wait_queue(&x->wait, &wait); @@ -3762,17 +3761,30 @@ do_wait_for_common(struct completion *x, return timeout ?: 1; } -static long __sched -wait_for_common(struct completion *x, long timeout, int state) +static inline long __sched +__wait_for_common(struct completion *x, + long (*action)(long), long timeout, int state) { might_sleep(); spin_lock_irq(&x->wait.lock); - timeout = do_wait_for_common(x, timeout, state); + timeout = do_wait_for_common(x, action, timeout, state); spin_unlock_irq(&x->wait.lock); return timeout; } +static long __sched +wait_for_common(struct completion *x, long timeout, int state) +{ + return __wait_for_common(x, schedule_timeout, timeout, state); +} + +static long __sched +wait_for_common_io(struct completion *x, long timeout, int state) +{ + return __wait_for_common(x, io_schedule_timeout, timeout, state); +} + /** * wait_for_completion: - waits for completion of a task * @x: holds the state of this particular completion @@ -3808,6 +3820,39 @@ wait_for_completion_timeout(struct compl } EXPORT_SYMBOL(wait_for_completion_timeout); + /** + * wait_for_completion_io: - waits for completion of a task + * @x: holds the state of this particular completion + * + * This waits to be signaled for completion of a specific task. It is NOT + * interruptible and there is no timeout. The caller is accounted as waiting + * for IO. + */ +void __sched wait_for_completion_io(struct completion *x) +{ + wait_for_common_io(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE); +} +EXPORT_SYMBOL(wait_for_completion_io); + +/** + * wait_for_completion_io_timeout: - waits for completion of a task (w/timeout) + * @x: holds the state of this particular completion + * @timeout: timeout value in jiffies + * + * This waits for either a completion of a specific task to be signaled or for a + * specified timeout to expire. The timeout is in jiffies. It is not + * interruptible. The caller is accounted as waiting for IO. + * + * The return value is 0 if timed out, and positive (at least 1, or number of + * jiffies left till timeout) if completed. + */ +unsigned long __sched +wait_for_completion_io_timeout(struct completion *x, unsigned long timeout) +{ + return wait_for_common_io(x, timeout, TASK_UNINTERRUPTIBLE); +} +EXPORT_SYMBOL(wait_for_completion_io_timeout); + /** * wait_for_completion_interruptible: - waits for completion of a task (w/intr) * @x: holds the state of this particular completion @@ -4862,18 +4907,23 @@ EXPORT_SYMBOL(yield); * It's the caller's job to ensure that the target task struct * can't go away on us before we can do any checks. * - * Returns true if we indeed boosted the target task. + * Returns: + * true (>0) if we indeed boosted the target task. + * false (0) if we failed to boost the target. + * -ESRCH if there's no task to yield to. */ bool __sched yield_to(struct task_struct *p, bool preempt) { unsigned long flags; - bool yielded = 0; + int yielded = 0; struct rq *rq; rq = this_rq(); grq_lock_irqsave(&flags); - if (task_running(p) || p->state) + if (task_running(p) || p->state) { + yielded = -ESRCH; goto out_unlock; + } yielded = 1; if (p->deadline > rq->rq_deadline) p->deadline = rq->rq_deadline; @@ -4885,7 +4935,7 @@ bool __sched yield_to(struct task_struct out_unlock: grq_unlock_irqrestore(&flags); - if (yielded) + if (yielded > 0) schedule(); return yielded; } @@ -7656,11 +7706,6 @@ void thread_group_cputime_adjusted(struc } #endif -inline cputime_t task_gtime(struct task_struct *p) -{ - return p->gtime; -} - void __cpuinit init_idle_bootup_task(struct task_struct *idle) {} Index: linux-3.9-bfs/include/linux/sched.h =================================================================== --- linux-3.9-bfs.orig/include/linux/sched.h 2013-05-02 21:57:34.370963342 +1000 +++ linux-3.9-bfs/include/linux/sched.h 2013-05-02 22:13:57.952666878 +1000 @@ -1005,19 +1005,6 @@ static inline bool cpus_share_cache(int struct io_context; /* See blkdev.h */ -#ifdef CONFIG_SCHED_BFS -#define MAX_USER_RT_PRIO 100 -#define MAX_RT_PRIO (MAX_USER_RT_PRIO + 1) -#define DEFAULT_PRIO (MAX_RT_PRIO + 20) - -#define PRIO_RANGE (40) -#define MAX_PRIO (MAX_RT_PRIO + PRIO_RANGE) -#define ISO_PRIO (MAX_RT_PRIO) -#define NORMAL_PRIO (MAX_RT_PRIO + 1) -#define IDLE_PRIO (MAX_RT_PRIO + 2) -#define PRIO_LIMIT ((IDLE_PRIO) + 1) -#endif /* CONFIG_SCHED_BFS */ - #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK extern void prefetch_stack(struct task_struct *t); #else Index: linux-3.9-bfs/include/linux/sched/rt.h =================================================================== --- linux-3.9-bfs.orig/include/linux/sched/rt.h 2013-05-02 21:04:14.755964034 +1000 +++ linux-3.9-bfs/include/linux/sched/rt.h 2013-05-02 22:13:16.601183843 +1000 @@ -14,11 +14,24 @@ * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO. */ +#ifdef CONFIG_SCHED_BFS +#define MAX_USER_RT_PRIO 100 +#define MAX_RT_PRIO (MAX_USER_RT_PRIO + 1) +#define DEFAULT_PRIO (MAX_RT_PRIO + 20) + +#define PRIO_RANGE (40) +#define MAX_PRIO (MAX_RT_PRIO + PRIO_RANGE) +#define ISO_PRIO (MAX_RT_PRIO) +#define NORMAL_PRIO (MAX_RT_PRIO + 1) +#define IDLE_PRIO (MAX_RT_PRIO + 2) +#define PRIO_LIMIT ((IDLE_PRIO) + 1) +#else /* CONFIG_SCHED_BFS */ #define MAX_USER_RT_PRIO 100 #define MAX_RT_PRIO MAX_USER_RT_PRIO #define MAX_PRIO (MAX_RT_PRIO + 40) #define DEFAULT_PRIO (MAX_RT_PRIO + 20) +#endif /* CONFIG_SCHED_BFS */ static inline int rt_prio(int prio) {