Source
204
204
* Ensure calling get_task_struct() before setting the reader
205
205
* waiter to nil such that rwsem_down_read_failed() cannot
206
206
* race with do_exit() by always holding a reference count
207
207
* to the task to wakeup.
208
208
*/
209
209
smp_store_release(&waiter->task, NULL);
210
210
/*
211
211
* Ensure issuing the wakeup (either by us or someone else)
212
212
* after setting the reader waiter to nil.
213
213
*/
214
-
wake_q_add(wake_q, tsk);
215
-
/* wake_q_add() already take the task ref */
216
-
put_task_struct(tsk);
214
+
wake_q_add_safe(wake_q, tsk);
217
215
}
218
216
219
217
adjustment = woken * RWSEM_ACTIVE_READ_BIAS - adjustment;
220
218
if (list_empty(&sem->wait_list)) {
221
219
/* hit end of list above */
222
220
adjustment -= RWSEM_WAITING_BIAS;
223
221
}
224
222
225
223
if (adjustment)
226
224
atomic_long_add(adjustment, &sem->count);