summaryrefslogtreecommitdiff
path: root/fs/proc
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-09-29 15:02:15 -0700
committerSasha Levin <sashal@kernel.org>2024-03-15 10:48:22 -0400
commit9b3834276bb6f3a4668b0d3f2b8e84f012e66000 (patch)
tree2bccd84faf0120648078f0a258db903cde8977ce /fs/proc
parent3c1b2776ef19117f76b698d70784677eb8549b8d (diff)
downloadlinux-9b3834276bb6f3a4668b0d3f2b8e84f012e66000.tar.gz
linux-9b3834276bb6f3a4668b0d3f2b8e84f012e66000.tar.bz2
linux-9b3834276bb6f3a4668b0d3f2b8e84f012e66000.zip
proc: Use task_is_running() for wchan in /proc/$pid/stat
[ Upstream commit 4e046156792c26bef8a4e30be711777fc8578257 ] 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@chromium.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20211008111626.211281780@infradead.org Stable-dep-of: 60f92acb60a9 ("fs/proc: do_task_stat: move thread_group_cputime_adjusted() outside of lock_task_sighand()") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/array.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 49be8c8ef555..77cf4187adec 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);