The following changes since commit cd312799e6a82557abbd742797b59f51e8c2c2e4: Merge branch 'sigbreak' of https://github.com/bjpaupor/fio (2021-09-28 13:28:18 -0600) are available in the Git repository at: git://git.kernel.dk/fio.git master for you to fetch changes up to 203e4c2624493c0db8c69c9ad830090c5b79be67: t/io_uring: store TSC rate in local file (2021-09-29 20:16:54 -0600) ---------------------------------------------------------------- Jens Axboe (2): Merge branch 'patch-1' of https://github.com/ravisowmya/fio t/io_uring: store TSC rate in local file ravisowmya (1): Fix for loop count issue when do_verify=0 (#1093) .gitignore | 1 + backend.c | 4 ++-- t/io_uring.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) --- Diff of recent changes: diff --git a/.gitignore b/.gitignore index 6651f96e..72494a1e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ doc/output /TAGS /t/zbd/test-zbd-support.log.* /t/fuzz/fuzz_parseini +tsc-rate diff --git a/backend.c b/backend.c index 86fa6d41..4c260747 100644 --- a/backend.c +++ b/backend.c @@ -1920,13 +1920,13 @@ static void *thread_main(void *data) if (td->error || td->terminate) break; + clear_io_state(td, 0); + if (!o->do_verify || o->verify == VERIFY_NONE || td_ioengine_flagged(td, FIO_UNIDIR)) continue; - clear_io_state(td, 0); - fio_gettime(&td->start, NULL); do_verify(td, verify_bytes); diff --git a/t/io_uring.c b/t/io_uring.c index e5568aa2..d7ae18b0 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -110,6 +110,8 @@ static int nthreads = 1; static int stats = 0; /* generate IO stats */ static unsigned long tsc_rate; +#define TSC_RATE_FILE "tsc-rate" + static int vectored = 1; static float plist[] = { 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, @@ -816,6 +818,50 @@ static void usage(char *argv, int status) exit(status); } +static void read_tsc_rate(void) +{ + char buffer[32]; + int fd, ret; + + if (tsc_rate) + return; + + fd = open(TSC_RATE_FILE, O_RDONLY); + if (fd < 0) + return; + + ret = read(fd, buffer, sizeof(buffer)); + if (ret < 0) { + close(fd); + return; + } + + tsc_rate = strtoul(buffer, NULL, 10); + printf("Using TSC rate %luHz\n", tsc_rate); + close(fd); +} + +static void write_tsc_rate(void) +{ + char buffer[32]; + struct stat sb; + int fd, ret; + + if (!stat(TSC_RATE_FILE, &sb)) + return; + + fd = open(TSC_RATE_FILE, O_WRONLY | O_CREAT, 0644); + if (fd < 0) + return; + + memset(buffer, 0, sizeof(buffer)); + sprintf(buffer, "%lu", tsc_rate); + ret = write(fd, buffer, strlen(buffer)); + if (ret < 0) + perror("write"); + close(fd); +} + int main(int argc, char *argv[]) { struct submitter *s; @@ -881,6 +927,7 @@ int main(int argc, char *argv[]) return 1; #endif tsc_rate = strtoul(optarg, NULL, 10); + write_tsc_rate(); break; case 'h': case '?': @@ -890,6 +937,9 @@ int main(int argc, char *argv[]) } } + if (stats) + read_tsc_rate(); + if (batch_complete > depth) batch_complete = depth; if (batch_submit > depth)