lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160920053025.13989-3-namhyung@kernel.org>
Date:   Tue, 20 Sep 2016 14:30:25 +0900
From:   Namhyung Kim <namhyung@...nel.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Jiri Olsa <jolsa@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Andi Kleen <andi@...stfloor.org>,
        Frederic Weisbecker <fweisbec@...il.com>
Subject: [PATCH 3/3] perf report: Fix output of 'pid' sort key

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@...il.com>
Fixes: 4dfced359fbc ("perf tools: Get current comm instead of last one")
Signed-off-by: Namhyung Kim <namhyung@...nel.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ