t/io_uring: use internal random generator
authorJens Axboe <axboe@kernel.dk>
Fri, 19 Nov 2021 17:40:20 +0000 (10:40 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 19 Nov 2021 17:40:20 +0000 (10:40 -0700)
Instead of using lrand48_r, use the internal fio random number generator.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
lib/rand.c
lib/rand.h
t/io_uring.c

index 04c1e0a70f80c45eae285a4b0e86e15d6aa47658..5d17bcab906591ff121d3675d795ecd2be4695e6 100644 (file)
--- 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
index e74da609ac945dab2a7670beb593727ffa5d5fac..6e893e80ba00a4939116cb59099e881300aaed3e 100644 (file)
@@ -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;
 
index a806004504013bc41986b6d1b6dbd6f6067b0a91..2b4be78893a926d22a37006706a1caf4b0d3e431 100644 (file)
@@ -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);
index f758a6d9b7b5f80ac65b7d3117dfa701ac08c719..5b8a00fa9a51b002f1c100ac4fa7fb3ef3de3fd1 100644 (file)
@@ -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++)