Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1219557

[tip:perf/urgent] perf tools: Fix use of wrong event when processing exit events

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From tip-bot for Adrian Hunter <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/urgent] perf tools: Fix use of wrong event when processing exit events
Date Sat, 05 Sep 2015 16:10:01 +0200
Message-ID <q5mkh-2Hy-3@gated-at.bofh.it> (permalink)
References <pYLdM-1Qz-11@gated-at.bofh.it>
X-Original-To linux-tip-commits@vger.kernel.org
Reply-To hpa@zytor.com, acme@redhat.com, tglx@linutronix.de, jolsa@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, adrian.hunter@intel.com
Git-Commit-ID 53ff6bc37be449f546158a39c528d7814dfb15a1
X-Mailer tip-git-log-daemon
Robot-ID <tip-bot.git.kernel.org>
Robot-Unsubscribe Contact <mailto:hpa@kernel.org> to get blacklisted from these emails
MIME-Version 1.0
Content-Transfer-Encoding 8bit
Content-Type text/plain; charset=UTF-8
Content-Disposition inline
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 93
Organization linux.* mail to news gateway
X-Original-Cc tglx@linutronix.de, hpa@zytor.com, acme@redhat.com, jolsa@redhat.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, mingo@kernel.org
X-Original-Date Sat, 5 Sep 2015 07:01:13 -0700
X-Original-Message-ID <tip-53ff6bc37be449f546158a39c528d7814dfb15a1@git.kernel.org>
X-Original-References <1439888825-27708-1-git-send-email-adrian.hunter@intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1219557

Show key headers only | View raw


Commit-ID:  53ff6bc37be449f546158a39c528d7814dfb15a1
Gitweb:     http://git.kernel.org/tip/53ff6bc37be449f546158a39c528d7814dfb15a1
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 18 Aug 2015 12:07:05 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 2 Sep 2015 17:46:26 -0300

perf tools: Fix use of wrong event when processing exit events

In a couple of cases the 'comm' member of 'union event' has been used
instead of the correct member ('fork') when processing exit events.

In the cases where it has been used incorrectly, only the 'pid' and
'tid' are affected.  The 'pid' value would be correct anyway because it
is in the same position in 'comm' and 'fork' events, but the 'tid' would
have been incorrectly assigned from 'ppid'.

However, for exit events, the kernel puts the current task in the 'ppid'
and 'ttid' which is the same as the exiting task.  That is 'ppid' ==
'pid' and if the task is not multi-threaded, 'pid' == 'tid' i.e. the
data goes wrong only when tracing multi-threaded programs.

It is hard to find an example of how this would produce an error in
practice.  There are 3 occurences of the fix:

1. perf script is only affected if !sample_id_all which only happens on
  old kernels.

2. intel_pt is only affected when decoding without timestamps
   and would probably still decode correctly - the exit event is
   only used to flush out data which anyway gets flushed at the
   end of the session

3. intel_bts also uses the exit event to flush data which
   would probably not cause errors as it would get flushed at
   the end of the session instead

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1439888825-27708-1-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 4 ++--
 tools/perf/util/intel-bts.c | 2 +-
 tools/perf/util/intel-pt.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index eb51325..284a76e 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -768,8 +768,8 @@ static int process_exit_event(struct perf_tool *tool,
 	if (!evsel->attr.sample_id_all) {
 		sample->cpu = 0;
 		sample->time = 0;
-		sample->tid = event->comm.tid;
-		sample->pid = event->comm.pid;
+		sample->tid = event->fork.tid;
+		sample->pid = event->fork.pid;
 	}
 	print_sample_start(sample, thread, evsel);
 	perf_event__fprintf(event, stdout);
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index ea76862..eb0e7f8 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -623,7 +623,7 @@ static int intel_bts_process_event(struct perf_session *session,
 	if (err)
 		return err;
 	if (event->header.type == PERF_RECORD_EXIT) {
-		err = intel_bts_process_tid_exit(bts, event->comm.tid);
+		err = intel_bts_process_tid_exit(bts, event->fork.tid);
 		if (err)
 			return err;
 	}
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index bb41c20..535d86f 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1494,7 +1494,7 @@ static int intel_pt_process_event(struct perf_session *session,
 	if (pt->timeless_decoding) {
 		if (event->header.type == PERF_RECORD_EXIT) {
 			err = intel_pt_process_timeless_queues(pt,
-							       event->comm.tid,
+							       event->fork.tid,
 							       sample->time);
 		}
 	} else if (timestamp) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[tip:perf/urgent] perf tools:   Fix use of wrong event when processing exit events tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-05 16:10 +0200

csiph-web