public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix tasklist + find_pid() with CONFIG_PREEMPT_RCU
@ 2008-01-29 16:40 Oleg Nesterov
  2008-01-29 23:02 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Oleg Nesterov @ 2008-01-29 16:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric W. Biederman, Ingo Molnar, Paul E. McKenney, Pavel Emelyanov,
	linux-kernel

With CONFIG_PREEMPT_RCU read_lock(tasklist_lock) doesn't imply rcu_read_lock(),
but find_pid_ns()->hlist_for_each_entry_rcu() should be safe under tasklist.

Usually it is, detach_pid() is always called under write_lock(tasklist_lock),
but copy_process() calls free_pid() lockless.

"#ifdef CONFIG_PREEMPT_RCU" is added mostly as documentation, perhaps it is
too ugly and should be removed.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- MM/kernel/fork.c~PR_RCU	2008-01-27 17:09:47.000000000 +0300
+++ MM/kernel/fork.c	2008-01-29 19:23:44.000000000 +0300
@@ -1335,8 +1335,19 @@ static struct task_struct *copy_process(
 	return p;
 
 bad_fork_free_pid:
-	if (pid != &init_struct_pid)
+	if (pid != &init_struct_pid) {
+#ifdef CONFIG_PREEMPT_RCU
+		/*
+		 * read_lock(tasklist_lock) doesn't imply rcu_read_lock(),
+		 * make sure find_pid() is safe under read_lock(tasklist).
+		 */
+		write_lock_irq(&tasklist_lock);
+#endif
 		free_pid(pid);
+#ifdef CONFIG_PREEMPT_RCU
+		write_unlock_irq(&tasklist_lock);
+#endif
+	}
 bad_fork_cleanup_namespaces:
 	exit_task_namespaces(p);
 bad_fork_cleanup_keys:


^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [PATCH] fix tasklist + find_pid() with CONFIG_PREEMPT_RCU
@ 2009-12-14  2:15 Tetsuo Handa
  0 siblings, 0 replies; 15+ messages in thread
From: Tetsuo Handa @ 2009-12-14  2:15 UTC (permalink / raw)
  To: paulmck; +Cc: linux-kernel

Hello.

Below change (found at http://lkml.org/lkml/2008/1/30/1 ) is not yet applied
as of 2.6.32-git10 . Any reason not to apply?

> diff --git a/include/linux/pid.h b/include/linux/pid.h
> index e29a900..0ffb8cc 100644
> --- a/include/linux/pid.h
> +++ b/include/linux/pid.h
> @@ -100,8 +100,7 @@ struct pid_namespace;
>  extern struct pid_namespace init_pid_ns;
> 
>  /*
> - * look up a PID in the hash table. Must be called with the tasklist_lock
> - * or rcu_read_lock() held.
> + * look up a PID in the hash table. Must be called with the rcu_read_lock() held.
>   *
>   * find_pid_ns() finds the pid in the namespace specified
>   * find_pid() find the pid by its global id, i.e. in the init namespace

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-12-14  2:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-29 16:40 [PATCH] fix tasklist + find_pid() with CONFIG_PREEMPT_RCU Oleg Nesterov
2008-01-29 23:02 ` Andrew Morton
2008-01-30 14:17   ` Peter Zijlstra
2008-01-31 13:32   ` Ingo Molnar
2008-01-29 23:08 ` Andrew Morton
2008-01-30  2:16   ` Eric W. Biederman
2008-01-30  4:56     ` Paul E. McKenney
2008-01-30  3:24 ` Eric W. Biederman
2008-01-30  5:00   ` Paul E. McKenney
2008-01-30  9:20     ` Eric W. Biederman
2008-01-30  9:48       ` Oleg Nesterov
2008-01-30  9:30   ` Oleg Nesterov
2008-01-30 18:28     ` Eric W. Biederman
2008-01-31  9:31       ` Oleg Nesterov
  -- strict thread matches above, loose matches on Subject: below --
2009-12-14  2:15 Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox