* [PATCH] LFSR: Fix spin related bug
@ 2013-03-09 13:00 Alex Pyrgiotis
2013-03-09 13:00 ` [PATCH] " Alex Pyrgiotis
0 siblings, 1 reply; 3+ messages in thread
From: Alex Pyrgiotis @ 2013-03-09 13:00 UTC (permalink / raw)
To: fio
Hi Jens,
Thanks for the inclusion in your code, hopefully it was easy to review.
I stumbled upon a silly bug which may affect some rare cases, so you may
want to include that patch too, just in case.
Regards,
Alex
Alex Pyrgiotis (1):
Fix spin related bug
lib/lfsr.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Fix spin related bug
2013-03-09 13:00 [PATCH] LFSR: Fix spin related bug Alex Pyrgiotis
@ 2013-03-09 13:00 ` Alex Pyrgiotis
2013-03-10 19:16 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Alex Pyrgiotis @ 2013-03-09 13:00 UTC (permalink / raw)
To: fio
On the previous patch on cycle detection, we would incremet spin value
when:
num_vals % cycle_length == 0
which would evaluate always to true for the first iteration since we
start with num_vals = 0. Only one corner-case is affected by this bug
and this patch should fix it.
Signed-off-by: Alex Pyrgiotis <apyrgio@grnet.gr>
diff --git a/lib/lfsr.c b/lib/lfsr.c
index a835404..4c15c62 100644
--- a/lib/lfsr.c
+++ b/lib/lfsr.c
@@ -108,22 +108,28 @@ static inline void __lfsr_next(struct fio_lfsr *fl, unsigned int spin)
}
}
+/*
+ * lfsr_next does the following:
+ *
+ * a. Return if the number of max values has been exceeded.
+ * b. Check if the next iteration(s) produce a cycle (due to spin) and add "1"
+ * where necessary.
+ * c. Calculate the next value and return.
+ */
int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t last)
{
int repeat;
unsigned int spin;
+ if (fl->num_vals++ > fl->max_val)
+ return 1;
+
repeat = fl->num_vals % fl->cycle_length;
if (repeat == 0)
spin = fl->spin + 1;
else
spin = fl->spin;
- if (fl->num_vals > fl->max_val)
- return 1;
-
- fl->num_vals++;
-
do {
__lfsr_next(fl, spin);
} while (fl->last_val > fl->max_val);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix spin related bug
2013-03-09 13:00 ` [PATCH] " Alex Pyrgiotis
@ 2013-03-10 19:16 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2013-03-10 19:16 UTC (permalink / raw)
To: Alex Pyrgiotis; +Cc: fio
On Sat, Mar 09 2013, Alex Pyrgiotis wrote:
> On the previous patch on cycle detection, we would incremet spin value
> when:
>
> num_vals % cycle_length == 0
>
> which would evaluate always to true for the first iteration since we
> start with num_vals = 0. Only one corner-case is affected by this bug
> and this patch should fix it.
Thanks Alex, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-10 19:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-09 13:00 [PATCH] LFSR: Fix spin related bug Alex Pyrgiotis
2013-03-09 13:00 ` [PATCH] " Alex Pyrgiotis
2013-03-10 19:16 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox