Skip to contentSkip to conversation

thread_group_cputime: move a couple of callsites outside of ->siglock

PATCH Oleg Nesterov 2 participants 2 messages Nov 17, 2008

lore
Share & tools
lore
#0 lore raw

->siglock buys nothing for thread_group_cputime() in do_sys_times() and wait_task_zombie() (which btw takes the unrelated parent's ->siglock). Actually I think do_sys_times() doesn't need ->siglock at all.

kernel/exit.c renamed from kernel/exit.c~SYS_TIMES_NO_SIGLOCK +1 -1
@@ -1330,10 +1330,10 @@ static int wait_task_zombie(struct task_
 		 * group, which consolidates times for all threads in the
 		 * group including the group leader.
 		 */
+		thread_group_cputime(p, &cputime);
 		spin_lock_irq(&p->parent->sighand->siglock);
 		psig = p->parent->signal;
 		sig = p->signal;
-		thread_group_cputime(p, &cputime);
 		psig->cutime =
 			cputime_add(psig->cutime,
 			cputime_add(cputime.utime,
kernel/sys.c renamed from kernel/sys.c~SYS_TIMES_NO_SIGLOCK +1 -1
@@ -858,8 +858,8 @@ void do_sys_times(struct tms *tms)
 	struct task_cputime cputime;
 	cputime_t cutime, cstime;
 
-	spin_lock_irq(&current->sighand->siglock);
 	thread_group_cputime(current, &cputime);
+	spin_lock_irq(&current->sighand->siglock);
 	cutime = current->signal->cutime;
 	cstime = current->signal->cstime;
 	spin_unlock_irq(&current->sighand->siglock);
#1 lore raw
Quoted 5 lines · Oleg Nesterov

->siglock buys nothing for thread_group_cputime() in do_sys_times() and wait_task_zombie() (which btw takes the unrelated parent's ->siglock). Actually I think do_sys_times() doesn't need ->siglock at all.

applied your changes to tip/core/signal:

2b5fe6d: thread_group_cputime: move a couple of callsites outside of ->siglock
ce39447: thread_group_cputime: kill the bogus ->signal != NULL check 74fcd52: account_steal_time: kill the unneeded account_group_system_time()

(merged the sched/urgent fixlet before them)

thanks Oleg!

Ingo