[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <163429110349.25758.11671964116161224606.tip-bot2@tip-bot2>
Date: Fri, 15 Oct 2021 09:45:03 -0000
From: "tip-bot2 for Kees Cook" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Kees Cook <keescook@...omium.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: sched/core] proc: Use task_is_running() for wchan in /proc/$pid/stat
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 4e046156792c26bef8a4e30be711777fc8578257
Gitweb: https://git.kernel.org/tip/4e046156792c26bef8a4e30be711777fc8578257
Author: Kees Cook <keescook@...omium.org>
AuthorDate: Wed, 29 Sep 2021 15:02:15 -07:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Fri, 15 Oct 2021 11:25:13 +02:00
proc: Use task_is_running() for wchan in /proc/$pid/stat
The implementations of get_wchan() can be expensive. The only information
imparted here is whether or not a process is currently blocked in the
scheduler (and even this doesn't need to be exact). Avoid doing the
heavy lifting of stack walking and just report that information by using
task_is_running().
Signed-off-by: Kees Cook <keescook@...omium.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Link: https://lkml.kernel.org/r/20211008111626.211281780@infradead.org
---
fs/proc/array.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 49be8c8..77cf418 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -541,7 +541,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
}
if (permitted && (!whole || num_threads < 2))
- wchan = get_wchan(task);
+ wchan = !task_is_running(task);
if (!whole) {
min_flt = task->min_flt;
maj_flt = task->maj_flt;
@@ -606,10 +606,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
*
* This works with older implementations of procps as well.
*/
- if (wchan)
- seq_puts(m, " 1");
- else
- seq_puts(m, " 0");
+ seq_put_decimal_ull(m, " ", wchan);
seq_put_decimal_ull(m, " ", 0);
seq_put_decimal_ull(m, " ", 0);
Powered by blists - more mailing lists