From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Bin Lan <bin.lan.cn@windriver.com>, Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.6] fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats
Date: Mon, 25 Nov 2024 10:21:03 -0500 [thread overview]
Message-ID: <20241125090126-a7ecce7ce5adb98d@stable.kernel.org> (raw)
In-Reply-To: <20241125053307.374219-1-bin.lan.cn@windriver.com>
[ Sasha's backport helper bot ]
Hi,
The upstream commit SHA1 provided is correct: 7601df8031fd67310af891897ef6cc0df4209305
WARNING: Author mismatch between patch and upstream commit:
Backport author: Bin Lan <bin.lan.cn@windriver.com>
Commit author: Oleg Nesterov <oleg@redhat.com>
Status in newer kernel trees:
6.12.y | Present (exact SHA1)
6.11.y | Present (exact SHA1)
6.6.y | Not found
Note: The patch differs from the upstream commit:
---
--- - 2024-11-25 08:56:48.440504041 -0500
+++ /tmp/tmp.DBppGejMK4 2024-11-25 08:56:48.433034088 -0500
@@ -1,3 +1,5 @@
+[ Upstream commit 7601df8031fd67310af891897ef6cc0df4209305 ]
+
lock_task_sighand() can trigger a hard lockup. If NR_CPUS threads call
do_task_stat() at the same time and the process has NR_THREADS, it will
spin with irqs disabled O(NR_CPUS * NR_THREADS) time.
@@ -12,12 +14,14 @@
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+[ Resolve minor conflicts ]
+Signed-off-by: Bin Lan <bin.lan.cn@windriver.com>
---
- fs/proc/array.c | 58 +++++++++++++++++++++++++++----------------------
- 1 file changed, 32 insertions(+), 26 deletions(-)
+ fs/proc/array.c | 57 +++++++++++++++++++++++++++----------------------
+ 1 file changed, 32 insertions(+), 25 deletions(-)
diff --git a/fs/proc/array.c b/fs/proc/array.c
-index 45ba918638084..34a47fb0c57f2 100644
+index 37b8061d84bb..34a47fb0c57f 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -477,13 +477,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
@@ -51,7 +55,7 @@
if (sig->tty) {
struct pid *pgrp = tty_get_pgrp(sig->tty);
tty_pgrp = pid_nr_ns(pgrp, ns);
-@@ -527,27 +523,9 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
+@@ -527,26 +523,9 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
num_threads = get_nr_threads(task);
collect_sigign_sigcatch(task, &sigign, &sigcatch);
@@ -64,13 +68,12 @@
- /* add up live thread stats at the group level */
if (whole) {
-- struct task_struct *t;
--
-- __for_each_thread(sig, t) {
+- struct task_struct *t = task;
+- do {
- 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;
@@ -79,7 +82,7 @@
if (sig->flags & (SIGNAL_GROUP_EXIT | SIGNAL_STOP_STOPPED))
exit_code = sig->group_exit_code;
}
-@@ -562,6 +540,34 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
+@@ -561,6 +540,34 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
if (permitted && (!whole || num_threads < 2))
wchan = !task_is_running(task);
@@ -114,3 +117,6 @@
if (whole) {
thread_group_cputime_adjusted(task, &utime, &stime);
} else {
+--
+2.43.0
+
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y | Success | Success |
prev parent reply other threads:[~2024-11-25 15:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 5:33 [PATCH 6.6] fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats Bin Lan
2024-11-25 15:21 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241125090126-a7ecce7ce5adb98d@stable.kernel.org \
--to=sashal@kernel.org \
--cc=bin.lan.cn@windriver.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.