diff options
-rw-r--r-- | kernel/futex.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index db0c6863e8a3..e65b68677d0b 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -865,21 +865,16 @@ out_state: | |||
865 | return 0; | 865 | return 0; |
866 | } | 866 | } |
867 | 867 | ||
868 | static int | 868 | /* |
869 | lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, | 869 | * Lookup the task for the TID provided from user space and attach to |
870 | union futex_key *key, struct futex_pi_state **ps) | 870 | * it after doing proper sanity checks. |
871 | */ | ||
872 | static int attach_to_pi_owner(u32 uval, union futex_key *key, | ||
873 | struct futex_pi_state **ps) | ||
871 | { | 874 | { |
872 | struct futex_q *match = futex_top_waiter(hb, key); | ||
873 | struct futex_pi_state *pi_state = NULL; | ||
874 | struct task_struct *p; | ||
875 | pid_t pid = uval & FUTEX_TID_MASK; | 875 | pid_t pid = uval & FUTEX_TID_MASK; |
876 | 876 | struct futex_pi_state *pi_state; | |
877 | /* | 877 | struct task_struct *p; |
878 | * If there is a waiter on that futex, validate it and | ||
879 | * attach to the pi_state when the validation succeeds. | ||
880 | */ | ||
881 | if (match) | ||
882 | return attach_to_pi_state(uval, match->pi_state, ps); | ||
883 | 878 | ||
884 | /* | 879 | /* |
885 | * We are the first waiter - try to look up the real owner and attach | 880 | * We are the first waiter - try to look up the real owner and attach |
@@ -922,7 +917,7 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, | |||
922 | pi_state = alloc_pi_state(); | 917 | pi_state = alloc_pi_state(); |
923 | 918 | ||
924 | /* | 919 | /* |
925 | * Initialize the pi_mutex in locked state and make 'p' | 920 | * Initialize the pi_mutex in locked state and make @p |
926 | * the owner of it: | 921 | * the owner of it: |
927 | */ | 922 | */ |
928 | rt_mutex_init_proxy_locked(&pi_state->pi_mutex, p); | 923 | rt_mutex_init_proxy_locked(&pi_state->pi_mutex, p); |
@@ -942,6 +937,25 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, | |||
942 | return 0; | 937 | return 0; |
943 | } | 938 | } |
944 | 939 | ||
940 | static int lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, | ||
941 | union futex_key *key, struct futex_pi_state **ps) | ||
942 | { | ||
943 | struct futex_q *match = futex_top_waiter(hb, key); | ||
944 | |||
945 | /* | ||
946 | * If there is a waiter on that futex, validate it and | ||
947 | * attach to the pi_state when the validation succeeds. | ||
948 | */ | ||
949 | if (match) | ||
950 | return attach_to_pi_state(uval, match->pi_state, ps); | ||
951 | |||
952 | /* | ||
953 | * We are the first waiter - try to look up the owner based on | ||
954 | * @uval and attach to it. | ||
955 | */ | ||
956 | return attach_to_pi_owner(uval, key, ps); | ||
957 | } | ||
958 | |||
945 | /** | 959 | /** |
946 | * futex_lock_pi_atomic() - Atomic work required to acquire a pi aware futex | 960 | * futex_lock_pi_atomic() - Atomic work required to acquire a pi aware futex |
947 | * @uaddr: the pi futex user address | 961 | * @uaddr: the pi futex user address |