projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
t/io_uring: Reporting bandwidth
[fio.git]
/
t
/
io_uring.c
diff --git
a/t/io_uring.c
b/t/io_uring.c
index 28c76b02a6261544f0ea613ff0b70ded095e3a52..cf59fe37dee770285e0975d0949cc63e45d62ba5 100644
(file)
--- a/
t/io_uring.c
+++ b/
t/io_uring.c
@@
-468,6
+468,13
@@
static int setup_ring(struct submitter *s)
io_uring_probe(fd);
if (fixedbufs) {
io_uring_probe(fd);
if (fixedbufs) {
+ struct rlimit rlim;
+
+ rlim.rlim_cur = RLIM_INFINITY;
+ rlim.rlim_max = RLIM_INFINITY;
+ /* ignore potential error, not needed on newer kernels */
+ setrlimit(RLIMIT_MEMLOCK, &rlim);
+
ret = io_uring_register_buffers(s);
if (ret < 0) {
perror("io_uring_register_buffers");
ret = io_uring_register_buffers(s);
if (ret < 0) {
perror("io_uring_register_buffers");
@@
-536,7
+543,7
@@
static void file_depths(char *buf)
}
}
}
}
-static void usage(char *argv)
+static void usage(char *argv
, int status
)
{
printf("%s [options] -- [filenames]\n"
" -d <int> : IO Depth, default %d\n"
{
printf("%s [options] -- [filenames]\n"
" -d <int> : IO Depth, default %d\n"
@@
-546,26
+553,27
@@
static void usage(char *argv)
" -p <bool> : Polled IO, default %d\n"
" -B <bool> : Fixed buffers, default %d\n"
" -F <bool> : Register files, default %d\n"
" -p <bool> : Polled IO, default %d\n"
" -B <bool> : Fixed buffers, default %d\n"
" -F <bool> : Register files, default %d\n"
- " -n <int> : Number of threads, default %d\n",
+ " -n <int> : Number of threads, default %d\n"
+ " -O <bool> : Use O_DIRECT, default %d\n"
+ " -N <bool> : Perform just no-op requests, default %d\n",
argv, DEPTH, BATCH_SUBMIT, BATCH_COMPLETE, BS, polled,
argv, DEPTH, BATCH_SUBMIT, BATCH_COMPLETE, BS, polled,
- fixedbufs, register_files, nthreads);
- exit(
0
);
+ fixedbufs, register_files, nthreads
, !buffered, do_nop
);
+ exit(
status
);
}
int main(int argc, char *argv[])
{
struct submitter *s;
unsigned long done, calls, reap;
}
int main(int argc, char *argv[])
{
struct submitter *s;
unsigned long done, calls, reap;
- int err, i, j, flags, fd, opt;
+ int err, i, j, flags, fd, opt, threads_per_f, threads_rem = 0, nfiles;
+ struct file f;
char *fdepths;
void *ret;
char *fdepths;
void *ret;
- if (!do_nop && argc < 2) {
- printf("%s: filename [options]\n", argv[0]);
- return 1;
- }
+ if (!do_nop && argc < 2)
+ usage(argv[0], 1);
- while ((opt = getopt(argc, argv, "d:s:c:b:p:B:F:n:h?")) != -1) {
+ while ((opt = getopt(argc, argv, "d:s:c:b:p:B:F:n:
N:O:
h?")) != -1) {
switch (opt) {
case 'd':
depth = atoi(optarg);
switch (opt) {
case 'd':
depth = atoi(optarg);
@@
-590,11
+598,21
@@
int main(int argc, char *argv[])
break;
case 'n':
nthreads = atoi(optarg);
break;
case 'n':
nthreads = atoi(optarg);
+ if (!nthreads) {
+ printf("Threads must be non-zero\n");
+ usage(argv[0], 1);
+ }
+ break;
+ case 'N':
+ do_nop = !!atoi(optarg);
+ break;
+ case 'O':
+ buffered = !atoi(optarg);
break;
case 'h':
case '?':
default:
break;
case 'h':
case '?':
default:
- usage(argv[0]);
+ usage(argv[0]
, 0
);
break;
}
}
break;
}
}
@@
-613,48
+631,59
@@
int main(int argc, char *argv[])
j = 0;
i = optind;
j = 0;
i = optind;
+ nfiles = argc - i;
+ if (!do_nop) {
+ if (!nfiles) {
+ printf("No files specified\n");
+ usage(argv[0], 1);
+ }
+ threads_per_f = nthreads / nfiles;
+ /* make sure each thread gets assigned files */
+ if (threads_per_f == 0) {
+ threads_per_f = 1;
+ } else {
+ threads_rem = nthreads - threads_per_f * nfiles;
+ }
+ }
while (!do_nop && i < argc) {
while (!do_nop && i < argc) {
- struct file *f;
+ int k, limit;
+
+ memset(&f, 0, sizeof(f));
- s = get_submitter(j);
- if (s->nr_files == MAX_FDS) {
- printf("Max number of files (%d) reached\n", MAX_FDS);
- break;
- }
fd = open(argv[i], flags);
if (fd < 0) {
perror("open");
return 1;
}
fd = open(argv[i], flags);
if (fd < 0) {
perror("open");
return 1;
}
-
- f = &s->files[s->nr_files];
- f->real_fd = fd;
- if (get_file_size(f)) {
+ f.real_fd = fd;
+ if (get_file_size(&f)) {
printf("failed getting size of device/file\n");
return 1;
}
printf("failed getting size of device/file\n");
return 1;
}
- if (f
->
max_blocks <= 1) {
+ if (f
.
max_blocks <= 1) {
printf("Zero file/device size?\n");
return 1;
}
printf("Zero file/device size?\n");
return 1;
}
- f
->
max_blocks--;
+ f
.
max_blocks--;
- printf("Added file %s (submitter %d)\n", argv[i], s->index);
- s->nr_files++;
- i++;
- if (++j >= nthreads)
- j = 0;
- }
+ limit = threads_per_f;
+ limit += threads_rem > 0 ? 1 : 0;
+ for (k = 0; k < limit; k++) {
+ s = get_submitter((j + k) % nthreads);
- if (fixedbufs) {
- struct rlimit rlim;
+ if (s->nr_files == MAX_FDS) {
+ printf("Max number of files (%d) reached\n", MAX_FDS);
+ break;
+ }
- rlim.rlim_cur = RLIM_INFINITY;
- rlim.rlim_max = RLIM_INFINITY;
- if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0) {
- perror("setrlimit");
- return 1;
+ memcpy(&s->files[s->nr_files], &f, sizeof(f));
+
+ printf("Added file %s (submitter %d)\n", argv[i], s->index);
+ s->nr_files++;
}
}
+ threads_rem--;
+ i++;
+ j += limit;
}
arm_sig_int();
}
arm_sig_int();
@@
-698,6
+727,7
@@
int main(int argc, char *argv[])
unsigned long this_reap = 0;
unsigned long this_call = 0;
unsigned long rpc = 0, ipc = 0;
unsigned long this_reap = 0;
unsigned long this_call = 0;
unsigned long rpc = 0, ipc = 0;
+ unsigned long iops;
sleep(1);
for (j = 0; j < nthreads; j++) {
sleep(1);
for (j = 0; j < nthreads; j++) {
@@
-711,8
+741,9
@@
int main(int argc, char *argv[])
} else
rpc = ipc = -1;
file_depths(fdepths);
} else
rpc = ipc = -1;
file_depths(fdepths);
- printf("IOPS=%lu, IOS/call=%ld/%ld, inflight=(%s)\n",
- this_done - done, rpc, ipc, fdepths);
+ iops = this_done - done;
+ printf("IOPS=%lu, BW=%luMiB/s, IOS/call=%ld/%ld, inflight=(%s)\n",
+ iops, iops * (1048576 / bs), rpc, ipc, fdepths);
done = this_done;
calls = this_call;
reap = this_reap;
done = this_done;
calls = this_call;
reap = this_reap;