From 83160d14081c5b97e781e7dd9f56ffb0f4ebd5f3 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sun, 8 Mar 2009 22:19:28 +0000 Subject: [PATCH] By default, don't compile in counters of calls to various time query functions in the kernel, as these effectively serialize parallel calls to the gettimeofday(2) system call, as well as other kernel services that use timestamps. Use the NetBSD version of the fix (kern_tc.c:1.32 by ad@) as they have picked up our timecounter code and also ran into the same problem. Reported by: kris Obtained from: NetBSD MFC after: 3 days --- sys/kern/kern_tc.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index c84054b6f5b2..640984257faf 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -103,6 +103,7 @@ static int timestepwarnings; SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW, ×tepwarnings, 0, ""); +#ifdef TC_COUNTERS #define TC_STATS(foo) \ static u_int foo; \ SYSCTL_UINT(_kern_timecounter, OID_AUTO, foo, CTLFLAG_RD, &foo, 0, "");\ @@ -114,7 +115,11 @@ TC_STATS(ngetbinuptime); TC_STATS(ngetnanouptime); TC_STATS(ngetmicrouptime); TC_STATS(ngetbintime); TC_STATS(ngetnanotime); TC_STATS(ngetmicrotime); TC_STATS(nsetclock); +#define TC_COUNT(var) var++ #undef TC_STATS +#else +#define TC_COUNT(var) /* nothing */ +#endif /* TC_COUNTERS */ static void tc_windup(void); static void cpu_tick_calibrate(int); @@ -180,7 +185,7 @@ binuptime(struct bintime *bt) struct timehands *th; u_int gen; - nbinuptime++; + TC_COUNT(nbinuptime); do { th = timehands; gen = th->th_generation; @@ -194,7 +199,7 @@ nanouptime(struct timespec *tsp) { struct bintime bt; - nnanouptime++; + TC_COUNT(nnanouptime); binuptime(&bt); bintime2timespec(&bt, tsp); } @@ -204,7 +209,7 @@ microuptime(struct timeval *tvp) { struct bintime bt; - nmicrouptime++; + TC_COUNT(nmicrouptime); binuptime(&bt); bintime2timeval(&bt, tvp); } @@ -213,7 +218,7 @@ void bintime(struct bintime *bt) { - nbintime++; + TC_COUNT(nbintime); binuptime(bt); bintime_add(bt, &boottimebin); } @@ -223,7 +228,7 @@ nanotime(struct timespec *tsp) { struct bintime bt; - nnanotime++; + TC_COUNT(nnanotime); bintime(&bt); bintime2timespec(&bt, tsp); } @@ -233,7 +238,7 @@ microtime(struct timeval *tvp) { struct bintime bt; - nmicrotime++; + TC_COUNT(nmicrotime); bintime(&bt); bintime2timeval(&bt, tvp); } @@ -244,7 +249,7 @@ getbinuptime(struct bintime *bt) struct timehands *th; u_int gen; - ngetbinuptime++; + TC_COUNT(ngetbinuptime); do { th = timehands; gen = th->th_generation; @@ -258,7 +263,7 @@ getnanouptime(struct timespec *tsp) struct timehands *th; u_int gen; - ngetnanouptime++; + TC_COUNT(ngetnanouptime); do { th = timehands; gen = th->th_generation; @@ -272,7 +277,7 @@ getmicrouptime(struct timeval *tvp) struct timehands *th; u_int gen; - ngetmicrouptime++; + TC_COUNT(ngetmicrouptime); do { th = timehands; gen = th->th_generation; @@ -286,7 +291,7 @@ getbintime(struct bintime *bt) struct timehands *th; u_int gen; - ngetbintime++; + TC_COUNT(ngetbintime); do { th = timehands; gen = th->th_generation; @@ -301,7 +306,7 @@ getnanotime(struct timespec *tsp) struct timehands *th; u_int gen; - ngetnanotime++; + TC_COUNT(ngetnanotime); do { th = timehands; gen = th->th_generation; @@ -315,7 +320,7 @@ getmicrotime(struct timeval *tvp) struct timehands *th; u_int gen; - ngetmicrotime++; + TC_COUNT(ngetmicrotime); do { th = timehands; gen = th->th_generation; @@ -406,7 +411,7 @@ tc_setclock(struct timespec *ts) struct bintime bt, bt2; cpu_tick_calibrate(1); - nsetclock++; + TC_COUNT(nsetclock); nanotime(&tbef); timespec2bintime(ts, &bt); binuptime(&bt2);