940 plist_for_each_entry_safe(this, next, head1, list) {
941 if (!match_futex (&this->key, &key1))
942 continue;
943 if (++ret <= nr_wake) {
944 wake_futex(this);
945 } else {
946
947
948
949
950 if (likely(head1 != &hb2->chain)) {
951 plist_del(&this->list, &hb1->chain);
952 plist_add(&this->list, &hb2->chain);
953 this->lock_ptr = &hb2->lock;
954#ifdef CONFIG_DEBUG_PI_LIST
955 this->list.plist.lock = &hb2->lock;
956#endif
957 }
958 this->key = key2;
959 get_futex_key_refs(&key2);
960 drop_count++;
961
962 if (ret - nr_wake >= nr_requeue)
963 break;
964 }
965 }
966
967out_unlock:
968 spin_unlock(&hb1->lock);
969 if (hb1 != hb2)
970 spin_unlock(&hb2->lock);
971
972
973 while (--drop_count >= 0)
974 drop_futex_key_refs(&key1);
975
976out:
977 futex_unlock_mm(fshared);
978 return ret;
979}
980