Skip to content

Commit f7a50ba

Browse files
oleg-nesterovBrian Maly
authored andcommitted
fs/proc: do_task_stat: use __for_each_thread()
do/while_each_thread should be avoided when possible. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Oleg Nesterov <[email protected]> Cc: Eric W. Biederman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit 7904e53) Soft lock-ups was seen with commit 0c35d1914353 fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats when DB is stopped we see a soft lock up with trace CPU: 4 PID: 82530 Comm: oracle_82530_io Kdump: loaded Tainted: POE 5.15.0-310.184.4.el8uek.aarch64 #2 Hardware name: QEMU KVM Virtual Machine, BIOS 1.6.6 08/22/2023 pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : task_gtime+0x28/0xc8 lr : do_task_stat+0x9b8/0xb30 sp : ffff800022fd3aa0 x29: ffff800022fd3aa0 x28: ffff000991a12180 x27: 000000000000026e x26: ffff80000aa92c90 x25: 000000023857b608 x24: 00000b345aaab7be x23: 0000000000000000 x22: 0000000000000000 x21: ffff000991a12180 x20: ffff00015f3d0000 x19: ffff0000ce2d4528 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: 0000000000000000 x9 : ffff8000086963a8 x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 000000000000082c x1 : 0000000000000002 x0 : 0000000000000000 Call trace: task_gtime+0x28/0xc8 do_task_stat+0x9b8/0xb30 proc_tgid_stat+0x1c/0x40 proc_single_show+0x68/0x17c seq_read_iter+0x1d8/0x510 seq_read+0x10c/0x190 vfs_read+0xb4/0x234 ksys_read+0x78/0x120 __arm64_sys_read+0x24/0x40 invoke_syscall+0x50/0x160 el0_svc_common+0x124/0x144 do_el0_svc+0x30/0xe0 el0_svc+0x30/0xf0 el0t_64_sync_handler+0xc4/0x148 el0t_64_sync+0x1a4/0x1a8 watchdog: BUG: soft lockup - CPU#4 stuck for 49s! [oracle_82530_io:82530] Orabug: 38081922 Fixes: 0c35d1914353 ("fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats") Signed-off-by: Vijayendra Suman <[email protected]> Reviewed-by: Harshit Mogalapalli <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Conflicts: fs/proc/array.c Context difference Signed-off-by: Brian Maly <[email protected]>
1 parent e7486fd commit f7a50ba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/proc/array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,18 +530,18 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
530530
cgtime = sig->cgtime;
531531

532532
if (whole) {
533-
struct task_struct *t = task;
533+
struct task_struct *t;
534534

535535
min_flt = sig->min_flt;
536536
maj_flt = sig->maj_flt;
537537
gtime = sig->gtime;
538538

539539
rcu_read_lock();
540-
do {
540+
__for_each_thread(sig, t) {
541541
min_flt += t->min_flt;
542542
maj_flt += t->maj_flt;
543543
gtime += task_gtime(t);
544-
} while_each_thread(task, t);
544+
}
545545
rcu_read_unlock();
546546
}
547547
} while (need_seqretry(&sig->stats_lock, seq));

0 commit comments

Comments
 (0)