Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2013 23:02:47 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r247425 - projects/calloutng/sys/kern
Message-ID:  <201302272302.r1RN2lpf040115@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Feb 27 23:02:47 2013
New Revision: 247425
URL: http://svnweb.freebsd.org/changeset/base/247425

Log:
  Removal of masking at r247319 require small additional polishing of math,
  otherwise it would explode in 49 days of runtime after u_int wrap.

Modified:
  projects/calloutng/sys/kern/kern_timeout.c

Modified: projects/calloutng/sys/kern/kern_timeout.c
==============================================================================
--- projects/calloutng/sys/kern/kern_timeout.c	Wed Feb 27 22:08:18 2013	(r247424)
+++ projects/calloutng/sys/kern/kern_timeout.c	Wed Feb 27 23:02:47 2013	(r247425)
@@ -102,7 +102,7 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpca
  * TODO:
  *	allocate more timeout table slots when table overflows.
  */
-int callwheelsize, callwheelmask;
+u_int callwheelsize, callwheelmask;
 
 /*
  * The callout cpu exec entities represent informations necessary for
@@ -369,18 +369,18 @@ SYSINIT(start_softclock, SI_SUB_SOFTINTR
 
 #define	CC_HASH_SHIFT	10
 
-static inline int
+static inline u_int
 callout_hash(sbintime_t sbt)
 {
-	
-	return (int)(sbt >> (32 - CC_HASH_SHIFT));
+
+	return (sbt >> (32 - CC_HASH_SHIFT));
 }
 
-static inline int
+static inline u_int
 callout_get_bucket(sbintime_t sbt)
 {
 
-	return callout_hash(sbt) & callwheelmask;
+	return (callout_hash(sbt) & callwheelmask);
 }
 
 void
@@ -422,10 +422,11 @@ callout_process(sbintime_t now)
 	 * Check if we wrapped around the entire wheel from the last scan.
 	 * In case, we need to scan entirely the wheel for pending callouts.
 	 */
-	if (lastb - firstb >= callwheelsize)
-		lastb = firstb - 1;
-	if (nowb - firstb >= callwheelsize)
-		nowb = firstb - 1;
+	if (lastb - firstb >= callwheelsize) {
+		lastb = firstb + callwheelsize - 1;
+		if (nowb - firstb >= callwheelsize)
+			nowb = lastb;
+	}
 
 	/* Iterate callwheel from firstb to nowb and then up to lastb. */
 	do {
@@ -488,7 +489,7 @@ next:
 		 * some event we can't execute at now.
 		 * Stop if we looked far enough into the future.
 		 */
-	} while (firstb <= lastb);
+	} while (((int)(firstb - lastb)) <= 0);
 	cc->cc_firstevent = last;
 #ifndef NO_EVENTTIMERS
 	cpu_new_callout(curcpu, last, first);



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