Index: linux-2.6.31-bfs/kernel/sched_bfs.c =================================================================== --- linux-2.6.31-bfs.orig/kernel/sched_bfs.c 2009-09-08 00:07:25.564852680 +1000 +++ linux-2.6.31-bfs/kernel/sched_bfs.c 2009-09-08 21:10:01.289874772 +1000 @@ -308,9 +308,15 @@ return (!!p->oncpu); } +/* + * Common functions for grabbing the global lock. A barrier before grabbing + * the lock every time is easier and safer than trying to find when to use + * one. + */ static inline void grq_lock(void) __acquires(grq.lock) { + smp_mb(); spin_lock(&grq.lock); } @@ -323,6 +329,7 @@ static inline void grq_lock_irq(void) __acquires(grq.lock) { + smp_mb(); spin_lock_irq(&grq.lock); } @@ -343,7 +350,7 @@ __acquires(grq.lock) { local_irq_save(*flags); - spin_lock(&grq.lock); + grq_lock(); } static inline void grq_unlock_irqrestore(unsigned long *flags) @@ -904,16 +911,7 @@ EXPORT_SYMBOL_GPL(kick_process); #endif -/* - * We need to have a special definition for an idle runqueue when testing - * for preemption on CONFIG_HOTPLUG_CPU as the idle task may be scheduled as - * a realtime task in sched_idle_next. - */ -#ifdef CONFIG_HOTPLUG_CPU -#define rq_idle(rq) ((rq)->curr == (rq)->idle && !rt_task((rq)->curr)) -#else -#define rq_idle(rq) ((rq)->curr == (rq)->idle) -#endif +#define rq_idle(rq) ((rq)->queued_prio == PRIO_LIMIT) /* * RT tasks preempt purely on priority. SCHED_NORMAL tasks preempt on the @@ -4803,6 +4801,15 @@ return group; } +/** + * group_first_cpu - Returns the first cpu in the cpumask of a sched_group. + * @group: The group whose first cpu is to be returned. + */ +static inline unsigned int group_first_cpu(struct sched_group *group) +{ + return cpumask_first(sched_group_cpus(group)); +} + #ifdef CONFIG_NUMA /* * The init_sched_build_groups can't handle what we want to do with node @@ -4898,15 +4905,6 @@ } #endif /* CONFIG_NUMA */ -/** - * group_first_cpu - Returns the first cpu in the cpumask of a sched_group. - * @group: The group whose first cpu is to be returned. - */ -static inline unsigned int group_first_cpu(struct sched_group *group) -{ - return cpumask_first(sched_group_cpus(group)); -} - /* * Initialize sched groups cpu_power. *