--- kernel/sched/bfs.c | 125 ++++++++++++++++++++++------------------------------- 1 file changed, 54 insertions(+), 71 deletions(-) Index: linux-3.3-ck1/kernel/sched/bfs.c =================================================================== --- linux-3.3-ck1.orig/kernel/sched/bfs.c 2012-03-26 22:29:52.000000000 +1100 +++ linux-3.3-ck1/kernel/sched/bfs.c 2012-03-26 22:48:40.315582343 +1100 @@ -486,7 +486,7 @@ static inline void __read_unlock(rwlock_ do_raw_read_unlock(lock); } -static void grq_wlock(void) +static inline void grq_wlock(void) __acquires(grq.lock) __acquires(grq.rwlock) { @@ -494,15 +494,13 @@ static void grq_wlock(void) __write_lock(&grq.rwlock); } -static void grq_ulock(void) +static inline void grq_lock(void) __acquires(grq.lock) - __acquires(grq.rwlock) { raw_spin_lock(&grq.lock); - __read_lock(&grq.rwlock); } -static void grq_wunlock(void) +static inline void grq_wunlock(void) __releases(grq.rwlock) __releases(grq.lock) { @@ -510,15 +508,13 @@ static void grq_wunlock(void) raw_spin_unlock(&grq.lock); } -static void grq_uunlock(void) - __releases(grq.rwlock) +static inline void grq_unlock(void) __releases(grq.lock) { - __read_unlock(&grq.rwlock); raw_spin_unlock(&grq.lock); } -static void grq_wlock_irq(void) +static inline void grq_wlock_irq(void) __acquires(grq.lock) __acquires(grq.rwlock) { @@ -526,15 +522,13 @@ static void grq_wlock_irq(void) __write_lock(&grq.rwlock); } -static void grq_ulock_irq(void) +static inline void grq_lock_irq(void) __acquires(grq.lock) - __acquires(grq.rwlock) { raw_spin_lock_irq(&grq.lock); - __read_lock(&grq.rwlock); } -static void time_wlock_grq(struct rq *rq) +static inline void time_wlock_grq(struct rq *rq) __acquires(grq.lock) __acquires(grq.rwlock) { @@ -542,7 +536,7 @@ static void time_wlock_grq(struct rq *rq update_clocks(rq); } -static void grq_wunlock_irq(void) +static inline void grq_wunlock_irq(void) __releases(grq.rwlock) __releases(grq.lock) { @@ -550,15 +544,13 @@ static void grq_wunlock_irq(void) raw_spin_unlock_irq(&grq.lock); } -static void grq_uunlock_irq(void) - __releases(grq.rwlock) +static inline void grq_unlock_irq(void) __releases(grq.lock) { - __read_unlock(&grq.rwlock); raw_spin_unlock_irq(&grq.lock); } -static void grq_rlock_irqsave(unsigned long *flags) +static inline void grq_rlock_irqsave(unsigned long *flags) __acquires(grq.lock) __acquires(grq.rwlock) __releases(grq.lock) @@ -569,7 +561,7 @@ static void grq_rlock_irqsave(unsigned l do_raw_spin_unlock(&grq.lock); } -static void grq_wlock_irqsave(unsigned long *flags) +static inline void grq_wlock_irqsave(unsigned long *flags) __acquires(grq.lock) __acquires(grq.rwlock) { @@ -577,29 +569,25 @@ static void grq_wlock_irqsave(unsigned l __write_lock(&grq.rwlock); } -static void grq_ulock_irqsave(unsigned long *flags) +static inline void grq_lock_irqsave(unsigned long *flags) __acquires(grq.lock) - __acquires(grq.rwlock) { raw_spin_lock_irqsave(&grq.lock, *flags); - __read_lock(&grq.rwlock); } -static void grq_upgrade_rwlock(void) - __releases(grq.rwlock) +static inline void grq_upgrade_rwlock(void) __acquires(grq.rwlock) { - __read_unlock(&grq.rwlock); __write_lock(&grq.rwlock); } -static void grq_runlock_irqrestore(unsigned long *flags) +static inline void grq_runlock_irqrestore(unsigned long *flags) __releases(grq.rwlock) { read_unlock_irqrestore(&grq.rwlock, *flags); } -static void grq_wunlock_irqrestore(unsigned long *flags) +static inline void grq_wunlock_irqrestore(unsigned long *flags) __releases(grq.rwlock) __releases(grq.lock) { @@ -607,15 +595,13 @@ static void grq_wunlock_irqrestore(unsig raw_spin_unlock_irqrestore(&grq.lock, *flags); } -static void grq_uunlock_irqrestore(unsigned long *flags) - __releases(grq.rwlock) +static inline void grq_unlock_irqrestore(unsigned long *flags) __releases(grq.lock) { - __read_unlock(&grq.rwlock); raw_spin_unlock_irqrestore(&grq.lock, *flags); } -static struct rq +static inline struct rq *task_grq_rlock(struct task_struct *p, unsigned long *flags) __acquires(grq.lock) __acquires(grq.rwlock) @@ -625,7 +611,7 @@ static struct rq return task_rq(p); } -static struct rq +static inline struct rq *task_grq_wlock(struct task_struct *p, unsigned long *flags) __acquires(grq.lock) __acquires(grq.rwlock) @@ -634,16 +620,15 @@ static struct rq return task_rq(p); } -static struct rq -*task_grq_ulock(struct task_struct *p, unsigned long *flags) +static inline struct rq +*task_grq_lock(struct task_struct *p, unsigned long *flags) __acquires(grq.lock) - __acquires(grq.rwlock) { - grq_ulock_irqsave(flags); + grq_lock_irqsave(flags); return task_rq(p); } -static struct rq +static inline struct rq *time_task_grq_wlock(struct task_struct *p, unsigned long *flags) __acquires(grq.lock) __acquires(grq.rwlock) @@ -653,46 +638,43 @@ static struct rq return rq; } -static struct rq *task_grq_ulock_irq(struct task_struct *p) +static inline struct rq *task_grq_lock_irq(struct task_struct *p) __acquires(grq.lock) - __acquires(grq.rwlock) { - grq_ulock_irq(); + grq_lock_irq(); return task_rq(p); } -static void task_grq_wunlock_irq(void) +static inline void task_grq_wunlock_irq(void) __releases(grq.rwlock) __releases(grq.lock) { grq_wunlock_irq(); } -static void task_grq_uunlock_irq(void) - __releases(grq.rwlock) +static inline void task_grq_unlock_irq(void) __releases(grq.lock) { - grq_uunlock_irq(); + grq_unlock_irq(); } -static void task_grq_runlock(unsigned long *flags) +static inline void task_grq_runlock(unsigned long *flags) __releases(grq.rwlock) { grq_runlock_irqrestore(flags); } -static void task_grq_wunlock(unsigned long *flags) +static inline void task_grq_wunlock(unsigned long *flags) __releases(grq.rwlock) __releases(grq.lock) { grq_wunlock_irqrestore(flags); } -static void task_grq_uunlock(unsigned long *flags) - __releases(grq.rwlock) +static inline void task_grq_unlock(unsigned long *flags) __releases(grq.lock) { - grq_uunlock_irqrestore(flags); + grq_unlock_irqrestore(flags); } /** @@ -716,7 +698,7 @@ void grq_unlock_wait(void) raw_spin_unlock_wait(&grq.lock); } #endif -static void time_grq_wlock(struct rq *rq, unsigned long *flags) +static inline void time_grq_wlock(struct rq *rq, unsigned long *flags) __acquires(grq.lock) __acquires(grq.rwlock) { @@ -724,7 +706,7 @@ static void time_grq_wlock(struct rq *rq time_wlock_grq(rq); } -static struct rq *__task_grq_wlock(struct task_struct *p) +static inline struct rq *__task_grq_wlock(struct task_struct *p) __acquires(grq.lock) __acquires(grq.rwlock) { @@ -732,26 +714,24 @@ static struct rq *__task_grq_wlock(struc return task_rq(p); } -static struct rq *__task_grq_ulock(struct task_struct *p) +static inline struct rq *__task_grq_lock(struct task_struct *p) __acquires(grq.lock) - __acquires(grq.rwlock) { - grq_ulock(); + grq_lock(); return task_rq(p); } -static void __task_grq_wunlock(void) +static inline void __task_grq_wunlock(void) __releases(grq.rwlock) __releases(grq.lock) { grq_wunlock(); } -static void __task_grq_uunlock(void) - __releases(grq.rwlock) +static inline void __task_grq_unlock(void) __releases(grq.lock) { - grq_uunlock(); + grq_unlock(); } /* @@ -1747,7 +1727,7 @@ static bool try_to_wake_up(struct task_s * No need to do time_lock_grq as we only need to update the rq clock * if we activate the task */ - rq = task_grq_ulock(p, &flags); + rq = task_grq_lock(p, &flags); cpu = task_cpu(p); /* state is a volatile long, どうして、分からない */ @@ -1768,7 +1748,7 @@ out_unlock: if (rwupgrade) task_grq_wunlock(&flags); else - task_grq_uunlock(&flags); + task_grq_unlock(&flags); ttwu_stat(p, cpu, wake_flags); @@ -1907,7 +1887,7 @@ void sched_fork(struct task_struct *p) * value. rq->rq_deadline is only modified within schedule() so it * is always equal to current->deadline. */ - rq = task_grq_ulock_irq(curr); + rq = task_grq_lock_irq(curr); if (likely(rq->rq_time_slice >= RESCHED_US * 2)) { rq->rq_time_slice /= 2; p->time_slice = rq->rq_time_slice; @@ -1928,7 +1908,7 @@ void sched_fork(struct task_struct *p) if (unlikely(rwupgrade)) task_grq_wunlock_irq(); else - task_grq_uunlock_irq(); + task_grq_unlock_irq(); out: put_cpu(); } @@ -4374,13 +4354,13 @@ recheck: * To be able to change p->policy safely, the grunqueue lock must be * held. */ - rq = __task_grq_ulock(p); + rq = __task_grq_lock(p); /* * Changing the policy of the stop threads its a very bad idea */ if (p == rq->stop) { - __task_grq_uunlock(); + __task_grq_unlock(); raw_spin_unlock_irqrestore(&p->pi_lock, flags); return -EINVAL; } @@ -4391,7 +4371,7 @@ recheck: if (unlikely(policy == p->policy && (!is_rt_policy(policy) || param->sched_priority == p->rt_priority))) { - __task_grq_uunlock(); + __task_grq_unlock(); raw_spin_unlock_irqrestore(&p->pi_lock, flags); return 0; } @@ -4399,7 +4379,7 @@ recheck: /* recheck policy now with rq lock held */ if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) { policy = oldpolicy = -1; - __task_grq_uunlock(); + __task_grq_unlock(); raw_spin_unlock_irqrestore(&p->pi_lock, flags); goto recheck; } @@ -4750,7 +4730,10 @@ SYSCALL_DEFINE0(sched_yield) * Since we are going to call schedule() anyway, there's * no need to preempt or enable interrupts: */ - grq_wunlock(); + __write_unlock(&grq.rwlock); + __release(grq.lock); + spin_release(&grq.lock.dep_map, 1, _THIS_IP_); + do_raw_spin_unlock(&grq.lock); preempt_enable_no_resched(); schedule(); @@ -4858,7 +4841,7 @@ bool __sched yield_to(struct task_struct struct rq *rq; rq = this_rq(); - grq_ulock_irqsave(&flags); + grq_lock_irqsave(&flags); if (task_running(p) || p->state) goto out_unlock; yielded = 1; @@ -4875,7 +4858,7 @@ out_unlock: if (rwupgrade) grq_wunlock_irqrestore(&flags); else - grq_uunlock_irqrestore(&flags); + grq_unlock_irqrestore(&flags); if (yielded) schedule(); @@ -5268,7 +5251,7 @@ int set_cpus_allowed_ptr(struct task_str struct rq *rq; int ret = 0; - rq = task_grq_ulock(p, &flags); + rq = task_grq_lock(p, &flags); if (cpumask_equal(tsk_cpus_allowed(p), new_mask)) goto out; @@ -5310,7 +5293,7 @@ out: if (rwupgrade) task_grq_wunlock(&flags); else - task_grq_uunlock(&flags); + task_grq_unlock(&flags); if (running_wrong) _cond_resched();