I question the extent to which this micro optimization really matters,
given that the code would eventually be compressed, but...

Make the code simpler by only having one copy, but outlining on small
kernels. This makes things even smaller. No change for normal kernels,
but small ones shrink from 6485 to 6433 (woo woo!) on amd64.

Index: kern_malloc.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_malloc.c,v
retrieving revision 1.111
diff -u -p -r1.111 kern_malloc.c
--- kern_malloc.c       10 Jul 2014 19:33:16 -0000      1.111
+++ kern_malloc.c       10 Jul 2014 21:46:26 -0000
@@ -45,18 +45,12 @@
 
 #include <uvm/uvm_extern.h>
 
-static __inline__ long BUCKETINDX(size_t sz)
+static
+#ifndef SMALL_KERNEL
+__inline__
+#endif
+long BUCKETINDX(size_t sz)
 {
-#ifdef SMALL_KERNEL
-       long b;
-
-       if (sz-- == 0)
-               return MINBUCKET;
-
-       for (b = MINBUCKET; b < MINBUCKET + 15; b++)
-               if ((sz >> b) == 0)
-                       break;
-#else
        long b, d;
 
        /* note that this relies upon MINALLOCSIZE being 1 << MINBUCKET */
@@ -72,8 +66,6 @@ static __inline__ long BUCKETINDX(size_t
                b += 0;
        else
                b += 1;
-#endif
-
        return b;
 }
 

Reply via email to