Skip to content

Commit 9855c37

Browse files
Frederic Weisbeckerpaulmckrcu
authored andcommitted
Revert "rcu-tasks: Fix synchronize_rcu_tasks() VS zap_pid_ns_processes()"
This reverts commit 28319d6. The race it fixed was subject to conditions that don't exist anymore since: 1612160 ("rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks") This latter commit removes the use of SRCU that used to cover the RCU-tasks blind spot on exit between the tasklist's removal and the final preemption disabling. The task is now placed instead into a temporary list inside which voluntary sleeps are accounted as RCU-tasks quiescent states. This would disarm the deadlock initially reported against PID namespace exit. Signed-off-by: Frederic Weisbecker <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 1613e60 commit 9855c37

File tree

3 files changed

+3
-32
lines changed

3 files changed

+3
-32
lines changed

include/linux/rcupdate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ void synchronize_rcu_tasks_rude(void);
209209

210210
#define rcu_note_voluntary_context_switch(t) rcu_tasks_qs(t, false)
211211
void exit_tasks_rcu_start(void);
212-
void exit_tasks_rcu_stop(void);
213212
void exit_tasks_rcu_finish(void);
214213
#else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
215214
#define rcu_tasks_classic_qs(t, preempt) do { } while (0)
@@ -218,7 +217,6 @@ void exit_tasks_rcu_finish(void);
218217
#define call_rcu_tasks call_rcu
219218
#define synchronize_rcu_tasks synchronize_rcu
220219
static inline void exit_tasks_rcu_start(void) { }
221-
static inline void exit_tasks_rcu_stop(void) { }
222220
static inline void exit_tasks_rcu_finish(void) { }
223221
#endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */
224222

kernel/pid_namespace.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,24 +248,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
248248
set_current_state(TASK_INTERRUPTIBLE);
249249
if (pid_ns->pid_allocated == init_pids)
250250
break;
251-
/*
252-
* Release tasks_rcu_exit_srcu to avoid following deadlock:
253-
*
254-
* 1) TASK A unshare(CLONE_NEWPID)
255-
* 2) TASK A fork() twice -> TASK B (child reaper for new ns)
256-
* and TASK C
257-
* 3) TASK B exits, kills TASK C, waits for TASK A to reap it
258-
* 4) TASK A calls synchronize_rcu_tasks()
259-
* -> synchronize_srcu(tasks_rcu_exit_srcu)
260-
* 5) *DEADLOCK*
261-
*
262-
* It is considered safe to release tasks_rcu_exit_srcu here
263-
* because we assume the current task can not be concurrently
264-
* reaped at this point.
265-
*/
266-
exit_tasks_rcu_stop();
267251
schedule();
268-
exit_tasks_rcu_start();
269252
}
270253
__set_current_state(TASK_RUNNING);
271254

kernel/rcu/tasks.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static void rcu_tasks_wait_gp(struct rcu_tasks *rtp)
858858
// not know to synchronize with this RCU Tasks grace period) have
859859
// completed exiting. The synchronize_rcu() in rcu_tasks_postgp()
860860
// will take care of any tasks stuck in the non-preemptible region
861-
// of do_exit() following its call to exit_tasks_rcu_stop().
861+
// of do_exit() following its call to exit_tasks_rcu_finish().
862862
// check_all_holdout_tasks(), repeatedly until holdout list is empty:
863863
// Scans the holdout list, attempting to identify a quiescent state
864864
// for each task on the list. If there is a quiescent state, the
@@ -1220,7 +1220,7 @@ void exit_tasks_rcu_start(void)
12201220
* Remove the task from the "yet another list" because do_exit() is now
12211221
* non-preemptible, allowing synchronize_rcu() to wait beyond this point.
12221222
*/
1223-
void exit_tasks_rcu_stop(void)
1223+
void exit_tasks_rcu_finish(void)
12241224
{
12251225
unsigned long flags;
12261226
struct rcu_tasks_percpu *rtpcp;
@@ -1231,22 +1231,12 @@ void exit_tasks_rcu_stop(void)
12311231
raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
12321232
list_del_init(&t->rcu_tasks_exit_list);
12331233
raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
1234-
}
12351234

1236-
/*
1237-
* Contribute to protect against tasklist scan blind spot while the
1238-
* task is exiting and may be removed from the tasklist. See
1239-
* corresponding synchronize_srcu() for further details.
1240-
*/
1241-
void exit_tasks_rcu_finish(void)
1242-
{
1243-
exit_tasks_rcu_stop();
1244-
exit_tasks_rcu_finish_trace(current);
1235+
exit_tasks_rcu_finish_trace(t);
12451236
}
12461237

12471238
#else /* #ifdef CONFIG_TASKS_RCU */
12481239
void exit_tasks_rcu_start(void) { }
1249-
void exit_tasks_rcu_stop(void) { }
12501240
void exit_tasks_rcu_finish(void) { exit_tasks_rcu_finish_trace(current); }
12511241
#endif /* #else #ifdef CONFIG_TASKS_RCU */
12521242

0 commit comments

Comments
 (0)