From 125f68e7084e8047d5c9184a2a0c8dd79b39d0c6 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 1 Aug 2014 22:33:23 +0000 Subject: [PATCH] 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 --- sys/cddl/compat/opensolaris/sys/time.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/cddl/compat/opensolaris/sys/time.h b/sys/cddl/compat/opensolaris/sys/time.h index fe4857ad1f92..cab715fafeaf 100644 --- a/sys/cddl/compat/opensolaris/sys/time.h +++ b/sys/cddl/compat/opensolaris/sys/time.h @@ -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 */