Skip to content

Commit 6eb7560

Browse files
committed
do_io_accounting: use __for_each_thread()
JIRA: https://issues.redhat.com/browse/RHEL-105165 commit 2320222 Author: Oleg Nesterov <oleg@redhat.com> Date: Mon, 23 Oct 2023 17:33:43 +0200 do_io_accounting: use __for_each_thread() Rather than while_each_thread() which should be avoided when possible. This makes the code more clear and allows the next change. Link: https://lkml.kernel.org/r/20231023153343.GA4629@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> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 41f9394 commit 6eb7560

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/proc/base.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,7 +2948,7 @@ static const struct file_operations proc_coredump_filter_operations = {
29482948
#ifdef CONFIG_TASK_IO_ACCOUNTING
29492949
static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whole)
29502950
{
2951-
struct task_io_accounting acct = task->ioac;
2951+
struct task_io_accounting acct;
29522952
unsigned long flags;
29532953
int result;
29542954

@@ -2962,14 +2962,18 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh
29622962
}
29632963

29642964
if (whole && lock_task_sighand(task, &flags)) {
2965-
struct task_struct *t = task;
2965+
struct signal_struct *sig = task->signal;
2966+
struct task_struct *t;
29662967

2967-
task_io_accounting_add(&acct, &task->signal->ioac);
2968-
while_each_thread(task, t)
2968+
acct = sig->ioac;
2969+
__for_each_thread(sig, t)
29692970
task_io_accounting_add(&acct, &t->ioac);
29702971

29712972
unlock_task_sighand(task, &flags);
2973+
} else {
2974+
acct = task->ioac;
29722975
}
2976+
29732977
seq_printf(m,
29742978
"rchar: %llu\n"
29752979
"wchar: %llu\n"

0 commit comments

Comments
 (0)