937
938
939
940static inline struct rq *__task_rq_lock(struct task_struct *p)
941 __acquires(rq->lock)
942{
943 for (;;) {
944 struct rq *rq = task_rq(p);
945 spin_lock(&rq->lock);
946 if (likely(rq == task_rq(p)))
947 return rq;
948 spin_unlock(&rq->lock);
949 }
950}
951
952
953
954
955
956
957static struct rq *task_rq_lock(struct task_struct *p, unsigned long *flags)
958 __acquires(rq->lock)
959{
960 struct rq *rq;
961
962 for (;;) {
963 local_irq_save(*flags);
964 rq = task_rq(p);
965 spin_lock(&rq->lock);
966 if (likely(rq == task_rq(p)))
967 return rq;
968 spin_unlock_irqrestore(&rq->lock, *flags);
969 }
970}
971
972void task_rq_unlock_wait(struct task_struct *p)
973{
974 struct rq *rq = task_rq(p);
975
976 smp_mb();
977 spin_unlock_wait(&rq->lock);