]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
fs/proc: do_task_stat: use __for_each_thread()
authorOleg Nesterov <oleg@redhat.com>
Sat, 9 Sep 2023 16:45:01 +0000 (18:45 +0200)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:22 +0000 (10:48 -0400)
[ Upstream commit 7904e53ed5a20fc678c01d5d1b07ec486425bb6a ]

do/while_each_thread should be avoided when possible.

Link: https://lkml.kernel.org/r/20230909164501.GA11581@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: 7601df8031fd ("fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/proc/array.c

index 1b0d78dfd20f92998411aaaf1bd5f43a675fae64..bcb645627991eb120085ffd28ff2fa03fca891e5 100644 (file)
@@ -526,12 +526,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
 
                /* add up live thread stats at the group level */
                if (whole) {
-                       struct task_struct *t = task;
-                       do {
+                       struct task_struct *t;
+
+                       __for_each_thread(sig, t) {
                                min_flt += t->min_flt;
                                maj_flt += t->maj_flt;
                                gtime += task_gtime(t);
-                       } while_each_thread(task, t);
+                       }
 
                        min_flt += sig->min_flt;
                        maj_flt += sig->maj_flt;