From: Jens Axboe Date: Tue, 27 Nov 2012 07:21:18 +0000 (+0100) Subject: lfsr: crank it 128 times before using the sequence X-Git-Tag: fio-2.0.12~38^2~4 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=c4fc0ff1a313de8f113689950d36eabea65ce310 lfsr: crank it 128 times before using the sequence Signed-off-by: Jens Axboe --- diff --git a/lib/lfsr.c b/lib/lfsr.c index 64442ab5..01c97cb8 100644 --- a/lib/lfsr.c +++ b/lib/lfsr.c @@ -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; }