From 9eff5320c9f4e4ce19c10f87d9548cb5098f62be Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 19 Nov 2021 10:40:20 -0700 Subject: [PATCH] t/io_uring: use internal random generator Instead of using lrand48_r, use the internal fio random number generator. Signed-off-by: Jens Axboe --- Makefile | 3 +-- lib/rand.c | 2 +- lib/rand.h | 1 + t/io_uring.c | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 04c1e0a7..5d17bcab 100644 --- a/Makefile +++ b/Makefile @@ -375,8 +375,7 @@ T_VS_PROGS = t/fio-verify-state T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o T_PIPE_ASYNC_PROGS = t/read-to-pipe-async -T_IOU_RING_OBJS = t/io_uring.o -T_IOU_RING_OBJS += t/arch.o +T_IOU_RING_OBJS = t/io_uring.o lib/rand.o lib/pattern.o lib/strntol.o T_IOU_RING_PROGS = t/io_uring T_MEMLOCK_OBJS = t/memlock.o diff --git a/lib/rand.c b/lib/rand.c index e74da609..6e893e80 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -59,7 +59,7 @@ static void __init_rand32(struct taus88_state *state, unsigned int seed) __rand32(state); } -static void __init_rand64(struct taus258_state *state, uint64_t seed) +void __init_rand64(struct taus258_state *state, uint64_t seed) { int cranks = 6; diff --git a/lib/rand.h b/lib/rand.h index a8060045..2b4be788 100644 --- a/lib/rand.h +++ b/lib/rand.h @@ -162,6 +162,7 @@ static inline uint64_t __get_next_seed(struct frand_state *fs) extern void init_rand(struct frand_state *, bool); extern void init_rand_seed(struct frand_state *, uint64_t seed, bool); +void __init_rand64(struct taus258_state *state, uint64_t seed); extern void __fill_random_buf(void *buf, unsigned int len, uint64_t seed); extern uint64_t fill_random_buf(struct frand_state *, void *buf, unsigned int len); extern void __fill_random_buf_percentage(uint64_t, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int); diff --git a/t/io_uring.c b/t/io_uring.c index f758a6d9..5b8a00fa 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -28,6 +28,7 @@ #include "../arch/arch.h" #include "../lib/types.h" #include "../lib/roundup.h" +#include "../lib/rand.h" #include "../minmax.h" #include "../os/linux/io_uring.h" @@ -86,6 +87,8 @@ struct submitter { __s32 *fds; + struct taus258_state rand_state; + unsigned long *clock_batch; int clock_index; unsigned long *plat; @@ -448,7 +451,7 @@ static void init_io(struct submitter *s, unsigned index) } f->pending_ios++; - r = lrand48(); + r = __rand64(&s->rand_state); offset = (r % (f->max_blocks - 1)) * bs; if (register_files) { @@ -586,6 +589,7 @@ static int submitter_init(struct submitter *s) s->tid = gettid(); printf("submitter=%d, tid=%d\n", s->index, s->tid); + __init_rand64(&s->rand_state, pthread_self()); srand48(pthread_self()); for (i = 0; i < MAX_FDS; i++) -- 2.25.1