/* * lfsr_next does the following: * * a. Return if the number of max values has been exceeded. * b. Check if we have a spin value that produces a repeating subsequence. * This is previously calculated in `prepare_spin` and cycle_length should * be > 0. If we do have such a spin: * * i. Decrement the calculated cycle. * ii. If it reaches zero, add "+1" to the spin and reset the cycle_length * (we have it cached in the struct fio_lfsr) * * In either case, continue with the calculation of the next value. * c. Check if the calculated value exceeds the desirable range. In this case, * go back to b, else return. */ int lfsr_next(struct fio_lfsr *fl, uint64_t *off) { if (fl->num_vals++ > fl->max_val) return 1; do { if (fl->cycle_length && !--fl->cycle_length) { __lfsr_next(fl, fl->spin + 1); fl->cycle_length = fl->cached_cycle_length; } else __lfsr_next(fl, fl->spin); } while (fio_unlikely(fl->last_val > fl->max_val)); *off = fl->last_val; return 0; }
/* * lfsr_next does the following: * * a. Return if the number of max values has been exceeded. * b. Check if we have a spin value that produces a repeating subsequence. * This is previously calculated in `prepare_spin` and cycle_length should * be > 0. If we do have such a spin: * * i. Decrement the calculated cycle. * ii. If it reaches zero, add "+1" to the spin and reset the cycle_length * (we have it cached in the struct fio_lfsr) * * In either case, continue with the calculation of the next value. * c. Check if the calculated value exceeds the desirable range. In this case, * go back to b, else return. */ int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t last) { if (fl->num_vals++ > fl->max_val) return 1; do { if (fl->cycle_length && !--fl->cycle_length) { __lfsr_next(fl, fl->spin + 1); fl->cycle_length = fl->cached_cycle_length; goto check; } __lfsr_next(fl, fl->spin); check: ; } while (fl->last_val > fl->max_val); *off = fl->last_val; return 0; }
/* * lfsr_next does the following: * * a. Return if the number of max values has been exceeded. * b. Check if we have a spin value that produces a repeating subsequence. * This is previously calculated in `prepare_spin` and cycle_length should * be > 0. If we do have such a spin: * * i. Decrement the calculated cycle. * ii. If it reaches zero, add "+1" to the spin and reset the cycle_length * (we have it cached in the struct fio_lfsr) * * In either case, continue with the calculation of the next value. * c. Check if the calculated value exceeds the desirable range. In this case, * go back to b, else return. */ uint64_t lfsr_next(struct bench_lfsr *lfsr) { lfsr->num_vals++; do { if (lfsr->cycle_length) { lfsr->cycle_length--; if (!lfsr->cycle_length) { __lfsr_next(lfsr, lfsr->spin + 1); lfsr->cycle_length = lfsr->cached_cycle_length; goto check; } } __lfsr_next(lfsr, lfsr->spin); check: ; } while (lfsr->last_val > lfsr->max_val); return lfsr->last_val; }