Skip to content

Commit

Permalink
fio: support io_size=N% (N <= 100)
Browse files Browse the repository at this point in the history
Parse "io_size=N%".

Semantics is "multiply whatever size= calculations result in".

Example #1:

	size=50%
	io_size=50%

will do 25% of a file.

Example #2:

	size=1G
	io_size=50%

will do 512M I/O.

As side effect, fix a bug with essentially infinite loop if both size=N%
and io_size=M% are given: io_size is set to 2^64-... in this case (a lot!).

Note: only values under 100% work currently.
Going for io_size=150% requires resetting workload generator state
which is whole separate endeavour.

Signed-off-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Alexey Dobriyan authored and axboe committed Sep 5, 2020
1 parent 2dd96cc commit 8b38f40
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void convert_thread_options_to_cpu(struct thread_options *o,
o->size = le64_to_cpu(top->size);
o->io_size = le64_to_cpu(top->io_size);
o->size_percent = le32_to_cpu(top->size_percent);
o->io_size_percent = le32_to_cpu(top->io_size_percent);
o->fill_device = le32_to_cpu(top->fill_device);
o->file_append = le32_to_cpu(top->file_append);
o->file_size_low = le64_to_cpu(top->file_size_low);
Expand Down Expand Up @@ -367,6 +368,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
top->iodepth_batch_complete_max = cpu_to_le32(o->iodepth_batch_complete_max);
top->serialize_overlap = cpu_to_le32(o->serialize_overlap);
top->size_percent = cpu_to_le32(o->size_percent);
top->io_size_percent = cpu_to_le32(o->io_size_percent);
top->fill_device = cpu_to_le32(o->fill_device);
top->file_append = cpu_to_le32(o->file_append);
top->ratecycle = cpu_to_le32(o->ratecycle);
Expand Down
11 changes: 10 additions & 1 deletion filesetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,8 @@ int setup_files(struct thread_data *td)
if (f->io_size == -1ULL)
total_size = -1ULL;
else {
uint64_t io_size;

if (o->size_percent && o->size_percent != 100) {
uint64_t file_size;

Expand All @@ -1150,7 +1152,14 @@ int setup_files(struct thread_data *td)

f->io_size -= (f->io_size % td_min_bs(td));
}
total_size += f->io_size;

io_size = f->io_size;
if (o->io_size_percent && o->io_size_percent != 100) {
io_size *= o->io_size_percent;
io_size /= 100;
}

total_size += io_size;
}

if (f->filetype == FIO_TYPE_FILE &&
Expand Down
17 changes: 17 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,22 @@ static int str_size_cb(void *data, unsigned long long *__val)
return 0;
}

static int str_io_size_cb(void *data, unsigned long long *__val)
{
struct thread_data *td = cb_data_to_td(data);
unsigned long long v = *__val;

if (parse_is_percent(v)) {
td->o.io_size = 0;
td->o.io_size_percent = -1ULL - v;
dprint(FD_PARSE, "SET io_size_percent %d\n",
td->o.io_size_percent);
} else
td->o.io_size = v;

return 0;
}

static int str_write_bw_log_cb(void *data, const char *str)
{
struct thread_data *td = cb_data_to_td(data);
Expand Down Expand Up @@ -2043,6 +2059,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
.alias = "io_limit",
.lname = "IO Size",
.type = FIO_OPT_STR_VAL,
.cb = str_io_size_cb,
.off1 = offsetof(struct thread_options, io_size),
.help = "Total size of I/O to be performed",
.interval = 1024 * 1024,
Expand Down
2 changes: 1 addition & 1 deletion server.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct fio_net_cmd_reply {
};

enum {
FIO_SERVER_VER = 85,
FIO_SERVER_VER = 86,

FIO_SERVER_MAX_FRAGMENT_PDU = 1024,
FIO_SERVER_MAX_CMD_MB = 2048,
Expand Down
4 changes: 4 additions & 0 deletions thread_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct thread_options {
unsigned long long size;
unsigned long long io_size;
unsigned int size_percent;
unsigned int io_size_percent;
unsigned int fill_device;
unsigned int file_append;
unsigned long long file_size_low;
Expand Down Expand Up @@ -381,6 +382,7 @@ struct thread_options_pack {
uint64_t size;
uint64_t io_size;
uint32_t size_percent;
uint32_t io_size_percent;
uint32_t fill_device;
uint32_t file_append;
uint32_t unique_filename;
Expand Down Expand Up @@ -460,6 +462,8 @@ struct thread_options_pack {
struct zone_split zone_split[DDIR_RWDIR_CNT][ZONESPLIT_MAX];
uint32_t zone_split_nr[DDIR_RWDIR_CNT];

uint8_t pad1[4];

fio_fp64_t zipf_theta;
fio_fp64_t pareto_h;
fio_fp64_t gauss_dev;
Expand Down

0 comments on commit 8b38f40

Please sign in to comment.