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
This commit is contained in:
Xin LI 2014-08-01 22:33:23 +00:00
parent 59561ab3e1
commit 125f68e708

View File

@ -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 */