From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Andi Kleen <andi@firstfloor.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 3/3] perf report: Fix output of 'pid' sort key
Date: Tue, 20 Sep 2016 14:30:25 +0900 [thread overview]
Message-ID: <20160920053025.13989-3-namhyung@kernel.org> (raw)
In-Reply-To: <20160920053025.13989-1-namhyung@kernel.org>
The thread->comm can be changed during the lifetime due to prctl() or
exec(). For this reason each hist entry has a pointer to a comm at the
time as well as a pointer to the thread. So it should use the he->comm
instead of thread__comm(he->thread) which always returns the latest
comm. This can be seen using following example:
$ perf report --hierarchy -s comm,pid
Before:
3.86% 2.53% sh
1.05% 0.45% 776:sh
0.67% 0.49% 8190:sh
0.65% 0.37% 8194:sh
0.28% 0.21% 8192:awk
0.24% 0.22% 8191:acpi
0.24% 0.21% 8196:awk
0.22% 0.15% 8193:tr
0.21% 0.14% 8195:netctl-auto
0.10% 0.30% 8319:date
0.10% 0.00% 8320:xsetroot
0.09% 0.00% 8321:sleep
After:
3.86% 2.53% sh
1.05% 0.45% 776:sh
0.67% 0.49% 8190:sh
0.65% 0.37% 8194:sh
0.28% 0.21% 8192:sh
0.24% 0.22% 8191:sh
0.24% 0.21% 8196:sh
0.22% 0.15% 8193:sh
0.21% 0.14% 8195:sh
0.10% 0.30% 8319:sh
0.10% 0.00% 8320:sh
0.09% 0.00% 8321:sh
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Fixes: 4dfced359fbc ("perf tools: Get current comm instead of last one")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/sort.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 1884d7f9b9d2..549dfbdbe9c3 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -77,7 +77,7 @@ sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
- const char *comm = thread__comm_str(he->thread);
+ const char *comm = comm__str(he->comm);
width = max(7U, width) - 8;
return repsep_snprintf(bf, size, "%7d:%-*.*s", he->thread->tid,
--
2.9.3
next prev parent reply other threads:[~2016-09-20 5:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 5:30 [PATCH 1/3] perf ui/tui: Reset output width for hierarchy Namhyung Kim
2016-09-20 5:30 ` [PATCH 2/3] perf hists: Factor out hists__reset_column_width() Namhyung Kim
2016-09-20 7:07 ` Jiri Olsa
2016-09-20 21:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-09-20 5:30 ` Namhyung Kim [this message]
2016-09-20 7:07 ` [PATCH 1/3] perf ui/tui: Reset output width for hierarchy Jiri Olsa
2016-09-20 21:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
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=20160920053025.13989-3-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=fweisbec@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome