syslet: we have fls(), use it for rounding ring size up
authorJens Axboe <jens.axboe@oracle.com>
Wed, 12 Dec 2007 18:39:59 +0000 (19:39 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 12 Dec 2007 18:39:59 +0000 (19:39 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/syslet-rw.c

index ab64054..7bb1be8 100644 (file)
@@ -16,6 +16,7 @@
 #include "../fio.h"
 #include "../indirect.h"
 #include "../syslet.h"
+#include "../fls.h"
 
 #ifdef FIO_HAVE_SYSLET
 
@@ -243,14 +244,8 @@ static int fio_syslet_init(struct thread_data *td)
         * The ring needs to be a power-of-2, so round it up if we have to
         */
        ring_nr = td->o.iodepth;
-       if (ring_nr & (ring_nr - 1)) {
-               int bits = 1;
-
-               while (ring_nr >>= 1)
-                       bits++;
-
-               ring_nr = 1 << bits;
-       }
+       if (ring_nr & (ring_nr - 1))
+               ring_nr = 1 << fls(ring_nr);
 
        ring_size = sizeof(struct syslet_ring) +
                        ring_nr * sizeof(struct syslet_completion);