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)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Oct 2023 17:41:57 +0000 (10:41 -0700)
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>
fs/proc/array.c

index 2c2efbe685d872201175a02377b818b1dbf31892..ff08a8957552add31a8fdf98e202f8380d519e50 100644 (file)
@@ -536,12 +536,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;