Skip to contentSkip to conversation

do_acct_process: don't take tty_mutex

PATCH In review Oleg Nesterov 2 participants 2 messages Oct 23, 2006 – Oct 24, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do_acct_process: don't take tty_mutex

Depends on
tty-signal-tty-locking.patch

No need to take the global tty_mutex, signal->tty->driver can't go away while we are holding ->siglock.

kernel/acct.c renamed from kernel/acct.c~ +2 -5
@@ -484,12 +484,9 @@ static void do_acct_process(struct file 
 	ac.ac_ppid = current->parent->tgid;
 #endif
 
-	mutex_lock(&tty_mutex);
-	tty = get_current_tty();
-	ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
-	mutex_unlock(&tty_mutex);
-
 	spin_lock_irq(&current->sighand->siglock);
+	tty = current->signal->tty;
+	ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
 	ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
 	ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime)));
 	ac.ac_flag = pacct->ac_flag;
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Oleg Nesterov

Depends on
tty-signal-tty-locking.patch

No need to take the global tty_mutex, signal->tty->driver can't go away while we are holding ->siglock.

Quoted 18 lines
kernel/acct.c renamed from kernel/acct.c~ +2 -5
@@ -484,12 +484,9 @@ static void do_acct_process(struct file 
 	ac.ac_ppid = current->parent->tgid;
 #endif
 
-	mutex_lock(&tty_mutex);
-	tty = get_current_tty();
-	ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
-	mutex_unlock(&tty_mutex);
-
 	spin_lock_irq(&current->sighand->siglock);
+	tty = current->signal->tty;
+	ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
 	ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
 	ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime)));
 	ac.ac_flag = pacct->ac_flag;