Skip to content

Commit

Permalink
getrusage: use __for_each_thread()
Browse files Browse the repository at this point in the history
[ Upstream commit 13b7bc6 ]

do/while_each_thread should be avoided when possible.

Plus this change allows to avoid lock_task_sighand(), we can use rcu
and/or sig->stats_lock instead.

Link: https://lkml.kernel.org/r/20230909172629.GA20454@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: f7ec1cd ("getrusage: use sig->stats_lock rather than lock_task_sighand()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Oleg Nesterov authored and Sasha Levin committed Mar 15, 2024
1 parent 33ec341 commit e24772a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions kernel/sys.c
Original file line number Diff line number Diff line change
@@ -1760,10 +1760,8 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
r->ru_oublock += sig->oublock;
if (maxrss < sig->maxrss)
maxrss = sig->maxrss;
t = p;
do {
__for_each_thread(sig, t)
accumulate_thread_rusage(t, r);
} while_each_thread(p, t);
break;

default:

0 comments on commit e24772a

Please sign in to comment.