Blame SOURCES/oprofile-trans_init.patch

0f9095
From e044a7def7f6aa61d3bb2a75a1ef597a4724441b Mon Sep 17 00:00:00 2001
0f9095
From: William Cohen <wcohen@redhat.com>
0f9095
Date: Mon, 18 Jun 2018 16:47:00 -0400
0f9095
Subject: [PATCH] Initialize the trans structure fields to values unused by
0f9095
 perf samples
0f9095
0f9095
On newer 4.14 kernel operf was crashing because the kernel commit
0f9095
1d953111b648e ("perf/core: Don't report zero PIDs for exiting tasks")
0f9095
made perf samples have TID/PID of -1 for exiting processes.  OProfile
0f9095
used this same value internally to indicate the that field had not
0f9095
been initialized.  As a result operf would incorrectly attempt to run
0f9095
some bookkeeping code due to an invalid match. The initialization of
0f9095
the trans tgid field is now changed to a value that is unsed by the
0f9095
perf samples to ensure that these invalid matches do not occur.
0f9095
0f9095
Signed-off-by: William Cohen <wcohen@redhat.com>
0f9095
---
0f9095
 libperf_events/operf_utils.cpp | 9 ++++++++-
0f9095
 1 file changed, 8 insertions(+), 1 deletion(-)
0f9095
0f9095
diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
0f9095
index 58c50a6..057692d 100644
0f9095
--- a/libperf_events/operf_utils.cpp
0f9095
+++ b/libperf_events/operf_utils.cpp
0f9095
@@ -73,7 +73,14 @@ static inline void update_trans_last(struct operf_transient * trans)
0f9095
 
0f9095
 static inline void clear_trans(struct operf_transient * trans)
0f9095
 {
0f9095
-	trans->tgid = ~0U;
0f9095
+	/* ~0U (-1) could be used by the kernel perf samples
0f9095
+	 * for the TID/PID of exiting processes. To avoid
0f9095
+	 * confusing the oprofile logic use ~1U as the
0f9095
+	 * initialization value for tgid field to avoid
0f9095
+	 * possibly matching the TID/PID values for exiting
0f9095
+	 * processes.
0f9095
+	 */
0f9095
+	trans->tgid = ~1U;
0f9095
 	trans->cur_procinfo = NULL;
0f9095
 }
0f9095
 
0f9095
-- 
0f9095
1.8.3.1
0f9095