lfsr: crank it 128 times before using the sequence
authorJens Axboe <axboe@kernel.dk>
Tue, 27 Nov 2012 07:21:18 +0000 (08:21 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 27 Nov 2012 07:21:18 +0000 (08:21 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
lib/lfsr.c

index 64442ab536d40fc2ac3894fc30043fcc94ef1e2b..01c97cb80b1df7a7c8bfa6f9d84f7e366f286390 100644 (file)
@@ -3,7 +3,7 @@
 #include "lfsr.h"
 
 /*
- * Trom table 3 of
+ * From table 3 of
  *
  * http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf
  */
@@ -202,6 +202,8 @@ static struct lfsr_taps lfsr_taps[] = {
        },
 };
 
+#define FIO_LFSR_CRANKS                128
+
 static uint64_t __lfsr_next(uint64_t v, struct lfsr_taps *lt)
 {
        uint64_t xor_mask = 0;
@@ -235,7 +237,7 @@ static struct lfsr_taps *find_lfsr(uint64_t size)
        int i;
 
        for (i = 0; lfsr_taps[i].length; i++)
-               if ((1UL << lfsr_taps[i].length) >= size)
+               if (((1UL << lfsr_taps[i].length) + FIO_LFSR_CRANKS) >= size)
                        return &lfsr_taps[i];
 
        return NULL;
@@ -260,5 +262,8 @@ int lfsr_init(struct fio_lfsr *fl, uint64_t size)
                        break;
        }
 
+       for (i = 0; i < FIO_LFSR_CRANKS; i++)
+               fl->last_val = __lfsr_next(fl->last_val, &fl->taps);
+
        return 0;
 }