[rtems commit] Changes that improve DTrace FBT reliability

Jan Sommer jan at rtems.org
Tue Nov 30 14:39:34 UTC 2021


Module:    rtems
Branch:    5
Commit:    512e0b59af4f2cea5b379df3801032a6c92175b2
Changeset: http://git.rtems.org/rtems/commit/?id=512e0b59af4f2cea5b379df3801032a6c92175b2

Author:    Robert Watson <rwatson at FreeBSD.org>
Date:      Sat Jan  9 08:38:11 2021 +0000

Changes that improve DTrace FBT reliability

on freebsd/arm64:

- Implement a dtrace_getnanouptime(), matching the existing
  dtrace_getnanotime(), to avoid DTrace calling out to a potentially
  instrumentable function.

  (These should probably both be under KDTRACE_HOOKS.  Also, it's not clear
  to me that they are correct implementations for the DTrace thread time
  functions they are used in .. fixes for another commit.)

- Don't allow FBT to instrument functions involved in EL1 exception handling
  that are involved in FBT trap processing: handle_el1h_sync() and
  do_el1h_sync().

- Don't allow FBT to instrument DDB and KDB functions, as that makes it
  rather harder to debug FBT problems.

Prior to these changes, use of FBT on FreeBSD/arm64 rapidly led to kernel
panics due to recursion in DTrace.

Reliable FBT on FreeBSD/arm64 is reliant on another change from @andrew to
have the aarch64 instrumentor more carefully check that instructions it
replaces are against the stack pointer, which can otherwise lead to memory
corruption.  That change remains under review.

MFC after:	2 weeks
Reviewed by:	andrew, kp, markj (earlier version), jrtc27 (earlier version)
Differential revision:	https://reviews.freebsd.org/D27766

---

 cpukit/score/src/kern_tc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 69af591..6df3894 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -284,6 +284,7 @@ static void _Timecounter_Windup(struct bintime *new_boottimebin,
 #endif /* __rtems__ */
 
 void dtrace_getnanotime(struct timespec *tsp);
+void dtrace_getnanouptime(struct timespec *tsp);
 
 #ifndef __rtems__
 static int
@@ -1156,6 +1157,20 @@ dtrace_getnanotime(struct timespec *tsp)
 
 	GETTHMEMBER(tsp, th_nanotime);
 }
+
+/*
+ * This is a clone of getnanouptime used for time since boot.
+ * The dtrace_ prefix prevents fbt from creating probes for
+ * it so an uptime that can be safely used in all fbt probes.
+ */
+void
+dtrace_getnanouptime(struct timespec *tsp)
+{
+	struct bintime bt;
+
+	GETTHMEMBER(&bt, th_offset);
+	bintime2timespec(&bt, tsp);
+}
 #endif /* __rtems__ */
 
 #ifdef FFCLOCK



More information about the vc mailing list