summaryrefslogtreecommitdiff
path: root/io_u.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-11-29 21:01:36 -0700
committerJens Axboe <axboe@kernel.dk>2017-11-29 21:01:36 -0700
commitd5d3795cd141ff5be0e857b5e09131ba0cb0ae0f (patch)
treea904150168e3787c996242199a40520e74c5524f /io_u.c
parent9d8fc5e4351ba93617db379d30482bdc7deea3b8 (diff)
downloadfio-d5d3795cd141ff5be0e857b5e09131ba0cb0ae0f.tar.gz
fio-d5d3795cd141ff5be0e857b5e09131ba0cb0ae0f.tar.bz2
io_u: don't do expensive int divide for buffer scramble
We don't need the conversion from nsec to usec to be exact, so just shift by 10 instead. Fixes: 8b6a404cd ("nanosecond: initial commit changing timeval to timespec") Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_u.c')
-rw-r--r--io_u.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/io_u.c b/io_u.c
index 6b950014..e1e44952 100644
--- a/io_u.c
+++ b/io_u.c
@@ -1673,7 +1673,7 @@ static bool check_get_verify(struct thread_data *td, struct io_u *io_u)
static void small_content_scramble(struct io_u *io_u)
{
unsigned int i, nr_blocks = io_u->buflen / 512;
- uint64_t boffset;
+ uint64_t boffset, usec;
unsigned int offset;
char *p, *end;
@@ -1684,13 +1684,16 @@ static void small_content_scramble(struct io_u *io_u)
boffset = io_u->offset;
io_u->buf_filled_len = 0;
+ /* close enough for this purpose */
+ usec = io_u->start_time.tv_nsec >> 10;
+
for (i = 0; i < nr_blocks; i++) {
/*
* Fill the byte offset into a "random" start offset of
* the buffer, given by the product of the usec time
* and the actual offset.
*/
- offset = ((io_u->start_time.tv_nsec/1000) ^ boffset) & 511;
+ offset = (usec ^ boffset) & 511;
offset &= ~(sizeof(uint64_t) - 1);
if (offset >= 512 - sizeof(uint64_t))
offset -= sizeof(uint64_t);