svn commit: r326935 - in head/sys/cddl/dev/dtrace: amd64 i386

Mark Johnston markj at FreeBSD.org
Mon Dec 18 17:26:26 UTC 2017


Author: markj
Date: Mon Dec 18 17:26:24 2017
New Revision: 326935
URL: https://svnweb.freebsd.org/changeset/base/326935

Log:
  Avoid CPU migration in dtrace_gethrtime() on x86.
  
  dtrace_gethrtime() may be called outside of probe context, and in
  particular, from the DTRACEIOC_BUFSNAP handler.
  
  Disable interrupts rather than using sched_pin() to help ensure that
  we don't call any external functions when in probe context.
  
  PR:		218452
  MFC after:	1 week

Modified:
  head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
  head/sys/cddl/dev/dtrace/i386/dtrace_subr.c

Modified: head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Mon Dec 18 17:17:07 2017	(r326934)
+++ head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Mon Dec 18 17:26:24 2017	(r326935)
@@ -353,11 +353,11 @@ SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_AN
  * Returns nanoseconds since boot.
  */
 uint64_t
-dtrace_gethrtime()
+dtrace_gethrtime(void)
 {
 	uint64_t tsc;
-	uint32_t lo;
-	uint32_t hi;
+	uint32_t lo, hi;
+	register_t rflags;
 
 	/*
 	 * We split TSC value into lower and higher 32-bit halves and separately
@@ -365,7 +365,10 @@ dtrace_gethrtime()
 	 * (see nsec_scale calculations) taking into account 32-bit shift of
 	 * the higher half and finally add.
 	 */
+	rflags = intr_disable();
 	tsc = rdtsc() - tsc_skew[curcpu];
+	intr_restore(rflags);
+
 	lo = tsc;
 	hi = tsc >> 32;
 	return (((lo * nsec_scale) >> SCALE_SHIFT) +

Modified: head/sys/cddl/dev/dtrace/i386/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Mon Dec 18 17:17:07 2017	(r326934)
+++ head/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Mon Dec 18 17:26:24 2017	(r326935)
@@ -355,11 +355,11 @@ SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_AN
  * Returns nanoseconds since boot.
  */
 uint64_t
-dtrace_gethrtime()
+dtrace_gethrtime(void)
 {
 	uint64_t tsc;
-	uint32_t lo;
-	uint32_t hi;
+	uint32_t lo, hi;
+	register_t eflags;
 
 	/*
 	 * We split TSC value into lower and higher 32-bit halves and separately
@@ -367,7 +367,10 @@ dtrace_gethrtime()
 	 * (see nsec_scale calculations) taking into account 32-bit shift of
 	 * the higher half and finally add.
 	 */
+	eflags = intr_disable();
 	tsc = rdtsc() - tsc_skew[curcpu];
+	intr_restore(eflags);
+
 	lo = tsc;
 	hi = tsc >> 32;
 	return (((lo * nsec_scale) >> SCALE_SHIFT) +


More information about the svn-src-all mailing list