From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Alexey Dobriyan <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Alexey Gladkov <gladkov.alexey@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Kees Cook <keescook@chromium.org>,
"Eric W . Biederman" <ebiederm@xmission.com>,
Vlastimil Babka <vbabka@suse.cz>,
Michel Lespinasse <walken@google.com>,
Andrei Vagin <avagin@gmail.com>,
Bernd Edlinger <bernd.edlinger@hotmail.de>,
John Johansen <john.johansen@canonical.com>,
Oleg Nesterov <oleg@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org,
Vineet Gupta <Vineet.Gupta1@synopsys.com>
Subject: [RFC] proc: get_wchan() stack unwind only makes sense for sleeping/non-self tasks
Date: Thu, 5 Nov 2020 15:11:32 -0800 [thread overview]
Message-ID: <20201105231132.2130132-1-vgupta@synopsys.com> (raw)
Most architectures currently check this in their get_wchan() implementation
(ARC doesn't hence this patch). However doing this in core code shows
the semantics better so move the check one level up (eventually remove
the boiler-plate code from arches)
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
# tools/perf/arch/arc/util/
---
fs/proc/array.c | 4 +++-
fs/proc/base.c | 6 ++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 65ec2029fa80..081fade5a361 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -519,8 +519,10 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
unlock_task_sighand(task, &flags);
}
- if (permitted && (!whole || num_threads < 2))
+ if (task != current && task->state != TASK_RUNNING &&
+ permitted && (!whole || num_threads < 2))
wchan = get_wchan(task);
+
if (!whole) {
min_flt = task->min_flt;
maj_flt = task->maj_flt;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 0f707003dda5..abd7ec6324c5 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -385,13 +385,15 @@ static const struct file_operations proc_pid_cmdline_ops = {
static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task)
{
- unsigned long wchan;
+ unsigned long wchan = 0;
char symname[KSYM_NAME_LEN];
if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
goto print0;
- wchan = get_wchan(task);
+ if (task != current && task->state != TASK_RUNNING)
+ wchan = get_wchan(task);
+
if (wchan && !lookup_symbol_name(wchan, symname)) {
seq_puts(m, symname);
return 0;
--
2.25.1
next reply other threads:[~2020-11-05 23:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 23:11 Vineet Gupta [this message]
2020-11-07 5:08 ` [RFC] proc: get_wchan() stack unwind only makes sense for sleeping/non-self tasks Andrew Morton
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=20201105231132.2130132-1-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=bernd.edlinger@hotmail.de \
--cc=ebiederm@xmission.com \
--cc=gladkov.alexey@gmail.com \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=vbabka@suse.cz \
--cc=walken@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).