Author: alfred
Date: Tue Dec  4 05:28:20 2012
New Revision: 243853
URL: http://svnweb.freebsd.org/changeset/base/243853

Log:
  replace bit shifting loop with 1<<fls(n), improve comments.
  
  Reviewed by: davide

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==============================================================================
--- head/sys/kern/kern_timeout.c        Tue Dec  4 04:37:42 2012        
(r243852)
+++ head/sys/kern/kern_timeout.c        Tue Dec  4 05:28:20 2012        
(r243853)
@@ -84,7 +84,7 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpca
  * TODO:
  *     allocate more timeout table slots when table overflows.
  */
-int callwheelsize, callwheelbits, callwheelmask;
+int callwheelsize, callwheelmask;
 
 /*
  * The callout cpu migration entity represents informations necessary for
@@ -218,12 +218,10 @@ kern_timeout_callwheel_alloc(caddr_t v)
        timeout_cpu = PCPU_GET(cpuid);
        cc = CC_CPU(timeout_cpu);
        /*
-        * Calculate callout wheel size
+        * Calculate callout wheel size, should be next power of two higher
+        * than 'ncallout'.
         */
-       for (callwheelsize = 1, callwheelbits = 0;
-            callwheelsize < ncallout;
-            callwheelsize <<= 1, ++callwheelbits)
-               ;
+       callwheelsize = 1 << fls(ncallout);
        callwheelmask = callwheelsize - 1;
 
        cc->cc_callout = (struct callout *)v;
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to