svn commit: r269404 - head/sys/cddl/compat/opensolaris/sys

Xin LI delphij at FreeBSD.org
Fri Aug 1 22:33:24 UTC 2014


Author: delphij
Date: Fri Aug  1 22:33:23 2014
New Revision: 269404
URL: http://svnweb.freebsd.org/changeset/base/269404

Log:
  Split gethrtime() and gethrtime_waitfree() and make the former use
  nanouptime() instead of getnanouptime().  nanouptime(9) provides more
  precise result at expense of being slower.
  
  In r269223, gethrtime() is used as creation time of dbuf, which in turn
  acts as portion of lookup key to maintain AVL invariant where there can
  not be duplicate items.  Before this change, gethrtime() have preferred
  better execution time by sacrificing precision, which may lead to panic
  on busy systems with:
  
  	panic: avl_find() succeeded inside avl_add()
  
  Reported by:	allanjude, mav
  PR:		kern/192284
  MFC after:	11 days
  X-MFC-with:	r269223

Modified:
  head/sys/cddl/compat/opensolaris/sys/time.h

Modified: head/sys/cddl/compat/opensolaris/sys/time.h
==============================================================================
--- head/sys/cddl/compat/opensolaris/sys/time.h	Fri Aug  1 22:28:36 2014	(r269403)
+++ head/sys/cddl/compat/opensolaris/sys/time.h	Fri Aug  1 22:33:23 2014	(r269404)
@@ -60,6 +60,17 @@ gethrtime(void) {
 	struct timespec ts;
 	hrtime_t nsec;
 
+	nanouptime(&ts);
+	nsec = (hrtime_t)ts.tv_sec * NANOSEC + ts.tv_nsec;
+	return (nsec);
+}
+
+static __inline hrtime_t
+gethrtime_waitfree(void) {
+
+	struct timespec ts;
+	hrtime_t nsec;
+
 	getnanouptime(&ts);
 	nsec = (hrtime_t)ts.tv_sec * NANOSEC + ts.tv_nsec;
 	return (nsec);
@@ -67,7 +78,6 @@ gethrtime(void) {
 
 #define	gethrestime_sec()	(time_second)
 #define	gethrestime(ts)		getnanotime(ts)
-#define	gethrtime_waitfree()	gethrtime()
 
 extern int nsec_per_tick;	/* nanoseconds per clock tick */
 


More information about the svn-src-all mailing list