diff options
Diffstat (limited to 'kernel/locking/rwsem-xadd.c')
-rw-r--r-- | kernel/locking/rwsem-xadd.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c index 09b180063ee1..50d9af615dc4 100644 --- a/kernel/locking/rwsem-xadd.c +++ b/kernel/locking/rwsem-xadd.c | |||
@@ -198,15 +198,22 @@ static void __rwsem_mark_wake(struct rw_semaphore *sem, | |||
198 | woken++; | 198 | woken++; |
199 | tsk = waiter->task; | 199 | tsk = waiter->task; |
200 | 200 | ||
201 | wake_q_add(wake_q, tsk); | 201 | get_task_struct(tsk); |
202 | list_del(&waiter->list); | 202 | list_del(&waiter->list); |
203 | /* | 203 | /* |
204 | * Ensure that the last operation is setting the reader | 204 | * Ensure calling get_task_struct() before setting the reader |
205 | * waiter to nil such that rwsem_down_read_failed() cannot | 205 | * waiter to nil such that rwsem_down_read_failed() cannot |
206 | * race with do_exit() by always holding a reference count | 206 | * race with do_exit() by always holding a reference count |
207 | * to the task to wakeup. | 207 | * to the task to wakeup. |
208 | */ | 208 | */ |
209 | smp_store_release(&waiter->task, NULL); | 209 | smp_store_release(&waiter->task, NULL); |
210 | /* | ||
211 | * Ensure issuing the wakeup (either by us or someone else) | ||
212 | * after setting the reader waiter to nil. | ||
213 | */ | ||
214 | wake_q_add(wake_q, tsk); | ||
215 | /* wake_q_add() already take the task ref */ | ||
216 | put_task_struct(tsk); | ||
210 | } | 217 | } |
211 | 218 | ||
212 | adjustment = woken * RWSEM_ACTIVE_READ_BIAS - adjustment; | 219 | adjustment = woken * RWSEM_ACTIVE_READ_BIAS - adjustment; |