Skip to content

Commit

Permalink
[PATCH] do_task_stat(): don't take tty_mutex
Browse files Browse the repository at this point in the history
->signal->tty is protected by ->siglock, no need to take the global tty_mutex.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Dec 8, 2006
1 parent 24ec839 commit 9159350
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions fs/proc/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,13 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
sigemptyset(&sigcatch);
cutime = cstime = utime = stime = cputime_zero;

mutex_lock(&tty_mutex);
rcu_read_lock();
if (lock_task_sighand(task, &flags)) {
struct signal_struct *sig = task->signal;
struct tty_struct *tty = sig->tty;

if (tty) {
/*
* sig->tty is not stable, but tty_mutex
* protects us from release_dev(tty)
*/
barrier();
tty_pgrp = tty->pgrp;
tty_nr = new_encode_dev(tty_devnum(tty));

if (sig->tty) {
tty_pgrp = sig->tty->pgrp;
tty_nr = new_encode_dev(tty_devnum(sig->tty));
}

num_threads = atomic_read(&sig->count);
Expand Down Expand Up @@ -395,7 +388,6 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
unlock_task_sighand(task, &flags);
}
rcu_read_unlock();
mutex_unlock(&tty_mutex);

if (!whole || num_threads<2)
wchan = get_wchan(task);
Expand Down

0 comments on commit 9159350

Please sign in to comment.