From owner-svn-src-projects@FreeBSD.ORG Wed Feb 27 23:02:48 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2DC5AFAB; Wed, 27 Feb 2013 23:02:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 07156922; Wed, 27 Feb 2013 23:02:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1RN2l4u040116; Wed, 27 Feb 2013 23:02:47 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1RN2lpf040115; Wed, 27 Feb 2013 23:02:47 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201302272302.r1RN2lpf040115@svn.freebsd.org> From: Alexander Motin Date: Wed, 27 Feb 2013 23:02:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r247425 - projects/calloutng/sys/kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2013 23:02:48 -0000 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);