]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
getrusage: use __for_each_thread()
authorOleg Nesterov <oleg@redhat.com>
Sat, 9 Sep 2023 17:26:29 +0000 (19:26 +0200)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:22 +0000 (10:48 -0400)
[ Upstream commit 13b7bc60b5353371460a203df6c38ccd38ad7a3a ]

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: f7ec1cd5cc7e ("getrusage: use sig->stats_lock rather than lock_task_sighand()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/sys.c

index 2646047fe55132af67c0bb5761d16aadf70f21ca..04102538cf43f0b46437e4142874e807c44b4961 100644 (file)
@@ -1822,10 +1822,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: