Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Dec 2012 00:13:29 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r244199 - in projects/calloutng/sys: kern sys
Message-ID:  <201212140013.qBE0DTLA044633@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Dec 14 00:13:29 2012
New Revision: 244199
URL: http://svnweb.freebsd.org/changeset/base/244199

Log:
  - Extend precision range.
  - Fix sysctl name.

Modified:
  projects/calloutng/sys/kern/kern_tc.c
  projects/calloutng/sys/kern/kern_timeout.c
  projects/calloutng/sys/sys/callout.h

Modified: projects/calloutng/sys/kern/kern_tc.c
==============================================================================
--- projects/calloutng/sys/kern/kern_tc.c	Thu Dec 13 23:32:47 2012	(r244198)
+++ projects/calloutng/sys/kern/kern_tc.c	Fri Dec 14 00:13:29 2012	(r244199)
@@ -22,6 +22,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
+#include <sys/limits.h>
 #ifdef FFCLOCK
 #include <sys/lock.h>
 #include <sys/mutex.h>
@@ -124,13 +125,13 @@ struct bintime halftick_bt;
 struct bintime tick_bt;
 int tc_timeexp;
 int tc_timepercentage = TC_DEFAULTPERC;
-TUNABLE_INT("kern.timecounter.allowdeviation", &tc_timepercentage);
+TUNABLE_INT("kern.timecounter.alloweddeviation", &tc_timepercentage);
 int tc_timethreshold;
 static int sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS);
-SYSCTL_PROC(_kern_timecounter, OID_AUTO, tc_timepercentage, 
+SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation,
     CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
-    sysctl_kern_timecounter_adjprecision, "I", 
-    "Allowed deviation from absolute value");
+    sysctl_kern_timecounter_adjprecision, "I",
+    "Allowed time interval deviation in percents");
 
 static void tc_windup(void);
 static void cpu_tick_calibrate(int);
@@ -1722,11 +1723,18 @@ static void __inline 
 tc_adjprecision(void)
 {
 	struct timespec ts;
-	int tick_rate;
+	int tick_rate, t;
 
 	tick_rate = hz / tc_tick;
-	tc_timethreshold = (1000000000 / (tick_rate * tc_timepercentage)) * 100;
-	tc_timeexp = fls(roundup2(100 / tc_timepercentage, 2));
+	if (tc_timepercentage > 0) {
+		tc_timethreshold =
+		    (1000000000 / (tick_rate * tc_timepercentage)) * 100;
+		t = (99 + tc_timepercentage) / tc_timepercentage;
+		tc_timeexp = fls(t + (t >> 1)) - 1;
+	} else {
+		tc_timethreshold = INT_MAX;
+		tc_timeexp = 31;
+	}
 	ts.tv_sec = tc_timethreshold / 1000000000;
 	ts.tv_nsec = tc_timethreshold % 1000000000;
 	timespec2bintime(&ts, &bt_timethreshold);

Modified: projects/calloutng/sys/kern/kern_timeout.c
==============================================================================
--- projects/calloutng/sys/kern/kern_timeout.c	Thu Dec 13 23:32:47 2012	(r244198)
+++ projects/calloutng/sys/kern/kern_timeout.c	Fri Dec 14 00:13:29 2012	(r244199)
@@ -938,7 +938,7 @@ _callout_reset_on(struct callout *c, str
 		if (to_ticks > 1)
 			bintime_mul(&to_bt, to_ticks);
 		bintime_add(&to_bt, &now);
-		if (C_PRELGET(flags) == 0) {
+		if (C_PRELGET(flags) < 0) {
 			pr = halftick_bt;
 		} else {
 			to_ticks >>= C_PRELGET(flags);

Modified: projects/calloutng/sys/sys/callout.h
==============================================================================
--- projects/calloutng/sys/sys/callout.h	Thu Dec 13 23:32:47 2012	(r244198)
+++ projects/calloutng/sys/sys/callout.h	Fri Dec 14 00:13:29 2012	(r244199)
@@ -53,8 +53,8 @@
 #define	C_DIRECT_EXEC		0x0001 /* direct execution of callout */
 #define	C_PRELBITS		7
 #define	C_PRELRANGE		((1 << C_PRELBITS) - 1)
-#define	C_PRELSET(x)		((x) << 1)
-#define	C_PRELGET(x)		(((x) >> 1) & C_PRELRANGE)
+#define	C_PRELSET(x)		(((x) + 1) << 1)
+#define	C_PRELGET(x)		(int)((((x) >> 1) & C_PRELRANGE) - 1)
 
 struct callout_handle {
 	struct callout *callout;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212140013.qBE0DTLA044633>