From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Ingo Molnar <mingo@elte.hu>,
"Paul E. McKenney" <paulmck@us.ibm.com>,
Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] coredump: don't take tasklist_lock
Date: Fri, 7 Apr 2006 02:06:36 +0400 [thread overview]
Message-ID: <20060406220635.GA243@oleg> (raw)
depends on
"[PATCH rc1-mm] de_thread: fix deadlockable process addition"
This patch removes tasklist_lock from zap_threads().
This is safe wrt:
do_exit:
The caller holds mm->mmap_sem. This means that task which
shares the same ->mm can't pass exit_mm(), so it can't be
unhashed from init_task.tasks or ->thread_group lists.
fork:
None of sub-threads can fork after zap_process(leader). All
processes which were created before this point should be
visible to zap_threads() because copy_process() adds the new
process to the tail of init_task.tasks list, and ->siglock
lock/unlock provides a memory barrier.
de_thread:
It does list_replace_rcu(&leader->tasks, ¤t->tasks).
So zap_threads() will see either old or new leader, it does
not matter. However, it can change p->sighand, so we should
use lock_task_sighand() in zap_process().
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- MM/fs/exec.c~4_TLOCK 2006-04-07 01:21:41.000000000 +0400
+++ MM/fs/exec.c 2006-04-07 01:32:02.000000000 +0400
@@ -1385,7 +1385,11 @@ static void zap_process(struct task_stru
struct task_struct *t;
unsigned long flags;
- spin_lock_irqsave(&start->sighand->siglock, flags);
+ /*
+ * start->sighand can't disappear, but may be
+ * changed by de_thread()
+ */
+ lock_task_sighand(start, &flags);
start->signal->flags = SIGNAL_GROUP_EXIT;
start->signal->group_stop_count = 0;
@@ -1398,7 +1402,7 @@ static void zap_process(struct task_stru
}
} while ((t = next_thread(t)) != start);
- spin_unlock_irqrestore(&start->sighand->siglock, flags);
+ unlock_task_sighand(start, &flags);
}
static void zap_threads(struct mm_struct *mm)
@@ -1416,7 +1420,7 @@ static void zap_threads(struct mm_struct
complete(vfork_done);
}
- read_lock(&tasklist_lock);
+ rcu_read_lock();
for_each_process(g) {
p = g;
do {
@@ -1427,7 +1431,7 @@ static void zap_threads(struct mm_struct
}
} while ((p = next_thread(p)) != g);
}
- read_unlock(&tasklist_lock);
+ rcu_read_unlock();
}
static void coredump_wait(struct mm_struct *mm)
next reply other threads:[~2006-04-06 18:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-06 22:06 Oleg Nesterov [this message]
2006-04-10 8:05 ` [PATCH 4/4] coredump: don't take tasklist_lock Roland McGrath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060406220635.GA243@oleg \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@us.ibm.com \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.