Skip to content

Commit

Permalink
t/io_uring: use internal random generator
Browse files Browse the repository at this point in the history
Instead of using lrand48_r, use the internal fio random number generator.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Nov 19, 2021
1 parent 0a852a5 commit 9eff532
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions lib/rand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion t/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -86,6 +87,8 @@ struct submitter {

__s32 *fds;

struct taus258_state rand_state;

unsigned long *clock_batch;
int clock_index;
unsigned long *plat;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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++)
Expand Down

0 comments on commit 9eff532

Please sign in to comment.