linux-stable/fs/proc
Oleg Nesterov 5d858e2d3e fs/proc: do_task_stat: move thread_group_cputime_adjusted() outside of lock_task_sighand()
commit 60f92acb60 upstream.

Patch series "fs/proc: do_task_stat: use sig->stats_".

do_task_stat() has the same problem as getrusage() had before "getrusage:
use sig->stats_lock rather than lock_task_sighand()": a hard lockup.  If
NR_CPUS threads call lock_task_sighand() at the same time and the process
has NR_THREADS, spin_lock_irq will spin with irqs disabled O(NR_CPUS *
NR_THREADS) time.


This patch (of 3):

thread_group_cputime() does its own locking, we can safely shift
thread_group_cputime_adjusted() which does another for_each_thread loop
outside of ->siglock protected section.

Not only this removes for_each_thread() from the critical section with
irqs disabled, this removes another case when stats_lock is taken with
siglock held.  We want to remove this dependency, then we can change the
users of stats_lock to not disable irqs.

Link: https://lkml.kernel.org/r/20240123153313.GA21832@redhat.com
Link: https://lkml.kernel.org/r/20240123153355.GA21854@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Dylan Hatch <dylanbhatch@google.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 09:25:17 +01:00
..
Kconfig proc: make config PROC_CHILDREN depend on PROC_FS 2022-10-03 14:21:43 -07:00
Makefile
array.c fs/proc: do_task_stat: move thread_group_cputime_adjusted() outside of lock_task_sighand() 2024-02-23 09:25:17 +01:00
base.c - An extensive rework of kexec and crash Kconfig from Eric DeVolder 2023-08-29 14:53:51 -07:00
bootconfig.c
cmdline.c proc: mark /proc/cmdline as permanent 2023-02-02 22:50:02 -08:00
consoles.c proc: consoles: use console_list_lock for list iteration 2022-12-02 11:25:02 +01:00
cpuinfo.c
devices.c proc: mark more files as permanent 2022-10-03 14:21:45 -07:00
fd.c fs: pass the request_mask to generic_fillattr 2023-08-09 08:56:36 +02:00
fd.h fs: port ->permission() to pass mnt_idmap 2023-01-19 09:24:28 +01:00
generic.c fs: pass the request_mask to generic_fillattr 2023-08-09 08:56:36 +02:00
inode.c procfs: convert to ctime accessor functions 2023-07-24 10:30:03 +02:00
internal.h proc: nommu: fix empty /proc/<pid>/maps 2023-09-19 13:21:34 -07:00
interrupts.c
kcore.c fs/proc/kcore: reinstate bounce buffer for KCORE_TEXT regions 2023-08-04 13:03:42 -07:00
kmsg.c printk changes for 6.1 2022-10-10 11:24:19 -07:00
loadavg.c proc: mark more files as permanent 2022-10-03 14:21:45 -07:00
meminfo.c mm: memtest: convert to memtest_report_meminfo() 2023-08-21 13:37:47 -07:00
namespaces.c
nommu.c proc: delete unused <linux/uaccess.h> includes 2022-07-17 17:31:39 -07:00
page.c mm, pagemap: remove SLOB and SLQB from comments and documentation 2023-03-29 10:32:11 +02:00
proc_net.c v6.6-fs.proc.uapi 2023-08-28 11:43:19 -07:00
proc_sysctl.c sysctl: Fix out of bounds access for empty sysctl registers 2024-02-05 20:14:17 +00:00
proc_tty.c proc: delete unused <linux/uaccess.h> includes 2022-07-17 17:31:39 -07:00
root.c fs: pass the request_mask to generic_fillattr 2023-08-09 08:56:36 +02:00
self.c procfs: convert to ctime accessor functions 2023-07-24 10:30:03 +02:00
softirqs.c proc: mark more files as permanent 2022-10-03 14:21:45 -07:00
stat.c proc/stat: remove arch_idle_time() 2023-04-18 16:39:33 -07:00
task_mmu.c - Stefan Roesch has added ksm statistics to /proc/pid/smaps 2023-09-05 10:56:27 -07:00
task_nommu.c proc: nommu: fix empty /proc/<pid>/maps 2023-09-19 13:21:34 -07:00
thread_self.c procfs: convert to ctime accessor functions 2023-07-24 10:30:03 +02:00
uptime.c proc: mark more files as permanent 2022-10-03 14:21:45 -07:00
util.c
version.c proc: mark more files as permanent 2022-10-03 14:21:45 -07:00
vmcore.c proc/vmcore: fix signedness bug in read_from_oldmem() 2023-07-27 13:07:05 -07:00