Skip to content

Commit c1be35a

Browse files
oleg-nesterovakpm00
authored andcommitted
exit: wait_task_zombie: kill the no longer necessary spin_lock_irq(siglock)
After the recent changes nobody use siglock to read the values protected by stats_lock, we can kill spin_lock_irq(&current->sighand->siglock) and update the comment. With this patch only __exit_signal() and thread_group_start_cputime() take stats_lock under siglock. Link: https://lkml.kernel.org/r/20240123153359.GA21866@redhat.com Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Dylan Hatch <dylanbhatch@google.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 7601df8 commit c1be35a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

kernel/exit.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,17 +1127,14 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
11271127
* and nobody can change them.
11281128
*
11291129
* psig->stats_lock also protects us from our sub-threads
1130-
* which can reap other children at the same time. Until
1131-
* we change k_getrusage()-like users to rely on this lock
1132-
* we have to take ->siglock as well.
1130+
* which can reap other children at the same time.
11331131
*
11341132
* We use thread_group_cputime_adjusted() to get times for
11351133
* the thread group, which consolidates times for all threads
11361134
* in the group including the group leader.
11371135
*/
11381136
thread_group_cputime_adjusted(p, &tgutime, &tgstime);
1139-
spin_lock_irq(&current->sighand->siglock);
1140-
write_seqlock(&psig->stats_lock);
1137+
write_seqlock_irq(&psig->stats_lock);
11411138
psig->cutime += tgutime + sig->cutime;
11421139
psig->cstime += tgstime + sig->cstime;
11431140
psig->cgtime += task_gtime(p) + sig->gtime + sig->cgtime;
@@ -1160,8 +1157,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
11601157
psig->cmaxrss = maxrss;
11611158
task_io_accounting_add(&psig->ioac, &p->ioac);
11621159
task_io_accounting_add(&psig->ioac, &sig->ioac);
1163-
write_sequnlock(&psig->stats_lock);
1164-
spin_unlock_irq(&current->sighand->siglock);
1160+
write_sequnlock_irq(&psig->stats_lock);
11651161
}
11661162

11671163
if (wo->wo_rusage)

0 commit comments

Comments
 (0)