2 * fio - the flexible io tester
4 * Copyright (C) 2005 Jens Axboe <axboe@suse.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include <sys/types.h>
38 #include <sys/ioctl.h>
46 #define ALIGN(buf) (char *) (((unsigned long) (buf) + MASK) & ~(MASK))
49 int thread_number = 0;
50 static char run_str[MAX_JOBS + 1];
52 static LIST_HEAD(disk_list);
53 static struct itimerval itimer;
54 static struct timeval genesis;
56 static void update_io_ticks(void);
57 static void disk_util_timer_arm(void);
58 static void print_thread_status(void);
72 #define should_fsync(td) (td_write(td) && (!(td)->odirect || (td)->override_sync))
74 static sem_t startup_sem;
76 #define TERMINATE_ALL (-1)
78 static void terminate_threads(int group_id)
82 for (i = 0; i < thread_number; i++) {
83 struct thread_data *td = &threads[i];
85 if (group_id == TERMINATE_ALL || groupid == td->groupid) {
92 static void sig_handler(int sig)
97 disk_util_timer_arm();
98 print_thread_status();
101 printf("\nfio: terminating on signal\n");
103 terminate_threads(TERMINATE_ALL);
108 static unsigned long utime_since(struct timeval *s, struct timeval *e)
112 sec = e->tv_sec - s->tv_sec;
113 usec = e->tv_usec - s->tv_usec;
114 if (sec > 0 && usec < 0) {
119 sec *= (double) 1000000;
124 static unsigned long utime_since_now(struct timeval *s)
128 gettimeofday(&t, NULL);
129 return utime_since(s, &t);
132 static unsigned long mtime_since(struct timeval *s, struct timeval *e)
136 sec = e->tv_sec - s->tv_sec;
137 usec = e->tv_usec - s->tv_usec;
138 if (sec > 0 && usec < 0) {
143 sec *= (double) 1000;
144 usec /= (double) 1000;
149 static unsigned long mtime_since_now(struct timeval *s)
153 gettimeofday(&t, NULL);
154 return mtime_since(s, &t);
157 static inline unsigned long msec_now(struct timeval *s)
159 return s->tv_sec * 1000 + s->tv_usec / 1000;
162 static unsigned long time_since_now(struct timeval *s)
164 return mtime_since_now(s) / 1000;
167 static int random_map_free(struct thread_data *td, unsigned long long block)
169 unsigned int idx = RAND_MAP_IDX(td, block);
170 unsigned int bit = RAND_MAP_BIT(td, block);
172 return (td->file_map[idx] & (1UL << bit)) == 0;
175 static int get_next_free_block(struct thread_data *td, unsigned long long *b)
181 while ((*b) * td->min_bs < td->io_size) {
182 if (td->file_map[i] != -1UL) {
183 *b += ffz(td->file_map[i]);
187 *b += BLOCKS_PER_MAP;
194 static void mark_random_map(struct thread_data *td, struct io_u *io_u)
196 unsigned long block = io_u->offset / td->min_bs;
197 unsigned int blocks = 0;
199 while (blocks < (io_u->buflen / td->min_bs)) {
200 unsigned int idx, bit;
202 if (!random_map_free(td, block))
205 idx = RAND_MAP_IDX(td, block);
206 bit = RAND_MAP_BIT(td, block);
208 assert(idx < td->num_maps);
210 td->file_map[idx] |= (1UL << bit);
215 if ((blocks * td->min_bs) < io_u->buflen)
216 io_u->buflen = blocks * td->min_bs;
219 static inline void add_stat_sample(struct io_stat *is, unsigned long val)
221 if (val > is->max_val)
223 if (val < is->min_val)
227 is->val_sq += val * val;
231 static void add_log_sample(struct thread_data *td, struct io_log *iolog,
232 unsigned long val, int ddir)
234 if (iolog->nr_samples == iolog->max_samples) {
235 int new_size = sizeof(struct io_sample) * iolog->max_samples*2;
237 iolog->log = realloc(iolog->log, new_size);
238 iolog->max_samples <<= 1;
241 iolog->log[iolog->nr_samples].val = val;
242 iolog->log[iolog->nr_samples].time = mtime_since_now(&td->epoch);
243 iolog->log[iolog->nr_samples].ddir = ddir;
247 static void add_clat_sample(struct thread_data *td, int ddir,unsigned long msec)
249 add_stat_sample(&td->clat_stat[ddir], msec);
252 add_log_sample(td, td->clat_log, msec, ddir);
255 static void add_slat_sample(struct thread_data *td, int ddir,unsigned long msec)
257 add_stat_sample(&td->slat_stat[ddir], msec);
260 add_log_sample(td, td->slat_log, msec, ddir);
263 static void add_bw_sample(struct thread_data *td, int ddir)
265 unsigned long spent = mtime_since_now(&td->stat_sample_time[ddir]);
268 if (spent < td->bw_avg_time)
271 rate = (td->this_io_bytes[ddir] - td->stat_io_bytes[ddir]) / spent;
272 add_stat_sample(&td->bw_stat[ddir], rate);
275 add_log_sample(td, td->bw_log, rate, ddir);
277 gettimeofday(&td->stat_sample_time[ddir], NULL);
278 td->stat_io_bytes[ddir] = td->this_io_bytes[ddir];
281 static int get_next_offset(struct thread_data *td, unsigned long long *offset)
283 unsigned long long b, rb;
286 if (!td->sequential) {
287 unsigned long max_blocks = td->io_size / td->min_bs;
291 lrand48_r(&td->random_state, &r);
292 b = ((max_blocks - 1) * r / (RAND_MAX+1.0));
293 rb = b + (td->file_offset / td->min_bs);
295 } while (!random_map_free(td, rb) && loops);
298 if (get_next_free_block(td, &b))
302 b = td->last_pos / td->min_bs;
304 *offset = (b * td->min_bs) + td->file_offset;
305 if (*offset > td->real_file_size)
311 static unsigned int get_next_buflen(struct thread_data *td)
316 if (td->min_bs == td->max_bs)
319 lrand48_r(&td->bsrange_state, &r);
320 buflen = (1 + (double) (td->max_bs - 1) * r / (RAND_MAX + 1.0));
321 buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
324 if (buflen > td->io_size - td->this_io_bytes[td->ddir])
325 buflen = td->io_size - td->this_io_bytes[td->ddir];
331 * busy looping version for the last few usec
333 static void __usec_sleep(unsigned int usec)
335 struct timeval start;
337 gettimeofday(&start, NULL);
338 while (utime_since_now(&start) < usec)
342 static void usec_sleep(struct thread_data *td, unsigned long usec)
344 struct timespec req, rem;
346 req.tv_sec = usec / 1000000;
347 req.tv_nsec = usec * 1000 - req.tv_sec * 1000000;
355 rem.tv_sec = rem.tv_nsec = 0;
356 if (nanosleep(&req, &rem) < 0)
359 if ((rem.tv_sec + rem.tv_nsec) == 0)
362 req.tv_nsec = rem.tv_nsec;
363 req.tv_sec = rem.tv_sec;
365 usec = rem.tv_sec * 1000000 + rem.tv_nsec / 1000;
366 } while (!td->terminate);
369 static void rate_throttle(struct thread_data *td, unsigned long time_spent,
372 unsigned long usec_cycle;
377 usec_cycle = td->rate_usec_cycle * (bytes / td->min_bs);
379 if (time_spent < usec_cycle) {
380 unsigned long s = usec_cycle - time_spent;
382 td->rate_pending_usleep += s;
383 if (td->rate_pending_usleep >= 100000) {
384 usec_sleep(td, td->rate_pending_usleep);
385 td->rate_pending_usleep = 0;
388 long overtime = time_spent - usec_cycle;
390 td->rate_pending_usleep -= overtime;
394 static int check_min_rate(struct thread_data *td, struct timeval *now)
401 * allow a 2 second settle period in the beginning
403 if (mtime_since(&td->start, now) < 2000)
407 * if rate blocks is set, sample is running
409 if (td->rate_bytes) {
410 spent = mtime_since(&td->lastrate, now);
411 if (spent < td->ratecycle)
414 rate = (td->this_io_bytes[ddir] - td->rate_bytes) / spent;
415 if (rate < td->ratemin) {
416 printf("Client%d: min rate %d not met, got %ldKiB/sec\n", td->thread_number, td->ratemin, rate);
418 terminate_threads(td->groupid);
423 td->rate_bytes = td->this_io_bytes[ddir];
424 memcpy(&td->lastrate, now, sizeof(*now));
428 static inline int runtime_exceeded(struct thread_data *td, struct timeval *t)
432 if (mtime_since(&td->epoch, t) >= td->timeout * 1000)
438 static void fill_random_bytes(struct thread_data *td,
439 unsigned char *p, unsigned int len)
445 drand48_r(&td->verify_state, &r);
448 * lrand48_r seems to be broken and only fill the bottom
449 * 32-bits, even on 64-bit archs with 64-bit longs
462 static void hexdump(void *buffer, int len)
464 unsigned char *p = buffer;
467 for (i = 0; i < len; i++)
468 printf("%02x", p[i]);
472 static int verify_io_u_crc32(struct verify_header *hdr, struct io_u *io_u)
474 unsigned char *p = (unsigned char *) io_u->buf;
479 c = crc32(p, hdr->len - sizeof(*hdr));
480 ret = c != hdr->crc32;
483 fprintf(stderr, "crc32: verify failed at %llu/%u\n", io_u->offset, io_u->buflen);
484 fprintf(stderr, "crc32: wanted %lx, got %lx\n", hdr->crc32, c);
490 static int verify_io_u_md5(struct verify_header *hdr, struct io_u *io_u)
492 unsigned char *p = (unsigned char *) io_u->buf;
493 struct md5_ctx md5_ctx;
496 memset(&md5_ctx, 0, sizeof(md5_ctx));
498 md5_update(&md5_ctx, p, hdr->len - sizeof(*hdr));
500 ret = memcmp(hdr->md5_digest, md5_ctx.hash, sizeof(md5_ctx.hash));
502 fprintf(stderr, "md5: verify failed at %llu/%u\n", io_u->offset, io_u->buflen);
503 hexdump(hdr->md5_digest, sizeof(hdr->md5_digest));
504 hexdump(md5_ctx.hash, sizeof(md5_ctx.hash));
510 static int verify_io_u(struct io_u *io_u)
512 struct verify_header *hdr = (struct verify_header *) io_u->buf;
515 if (hdr->fio_magic != FIO_HDR_MAGIC)
518 if (hdr->verify_type == VERIFY_MD5)
519 ret = verify_io_u_md5(hdr, io_u);
520 else if (hdr->verify_type == VERIFY_CRC32)
521 ret = verify_io_u_crc32(hdr, io_u);
523 fprintf(stderr, "Bad verify type %d\n", hdr->verify_type);
530 static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
532 hdr->crc32 = crc32(p, len);
535 static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
537 struct md5_ctx md5_ctx;
539 memset(&md5_ctx, 0, sizeof(md5_ctx));
540 md5_update(&md5_ctx, p, len);
541 memcpy(hdr->md5_digest, md5_ctx.hash, sizeof(md5_ctx.hash));
545 * fill body of io_u->buf with random data and add a header with the
546 * (eg) sha1sum of that data.
548 static void populate_io_u(struct thread_data *td, struct io_u *io_u)
550 unsigned char *p = (unsigned char *) io_u->buf;
551 struct verify_header hdr;
553 hdr.fio_magic = FIO_HDR_MAGIC;
554 hdr.len = io_u->buflen;
556 fill_random_bytes(td, p, io_u->buflen - sizeof(hdr));
558 if (td->verify == VERIFY_MD5) {
559 fill_md5(&hdr, p, io_u->buflen - sizeof(hdr));
560 hdr.verify_type = VERIFY_MD5;
562 fill_crc32(&hdr, p, io_u->buflen - sizeof(hdr));
563 hdr.verify_type = VERIFY_CRC32;
566 memcpy(io_u->buf, &hdr, sizeof(hdr));
569 static int td_io_prep(struct thread_data *td, struct io_u *io_u, int read)
572 io_u->ddir = DDIR_READ;
574 io_u->ddir = DDIR_WRITE;
576 if (td->io_prep && td->io_prep(td, io_u))
582 void put_io_u(struct thread_data *td, struct io_u *io_u)
584 list_del(&io_u->list);
585 list_add(&io_u->list, &td->io_u_freelist);
589 #define queue_full(td) (list_empty(&(td)->io_u_freelist))
591 struct io_u *__get_io_u(struct thread_data *td)
598 io_u = list_entry(td->io_u_freelist.next, struct io_u, list);
601 list_del(&io_u->list);
602 list_add(&io_u->list, &td->io_u_busylist);
607 static struct io_u *get_io_u(struct thread_data *td)
611 io_u = __get_io_u(td);
615 if (td->zone_bytes >= td->zone_size) {
617 td->last_pos += td->zone_skip;
620 if (get_next_offset(td, &io_u->offset)) {
625 io_u->buflen = get_next_buflen(td);
631 if (io_u->buflen + io_u->offset > td->real_file_size)
632 io_u->buflen = td->real_file_size - io_u->offset;
640 mark_random_map(td, io_u);
642 td->last_pos += io_u->buflen;
644 if (td->verify != VERIFY_NONE)
645 populate_io_u(td, io_u);
647 if (td_io_prep(td, io_u, td_read(td))) {
652 gettimeofday(&io_u->start_time, NULL);
656 static inline void td_set_runstate(struct thread_data *td, int runstate)
658 td->old_runstate = td->runstate;
659 td->runstate = runstate;
662 static int get_next_verify(struct thread_data *td,
663 unsigned long long *offset, unsigned int *len)
665 struct io_piece *ipo;
667 if (list_empty(&td->io_hist_list))
670 ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
671 list_del(&ipo->list);
673 *offset = ipo->offset;
679 static void prune_io_piece_log(struct thread_data *td)
681 struct io_piece *ipo;
683 while (!list_empty(&td->io_hist_list)) {
684 ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
686 list_del(&ipo->list);
692 * log a succesful write, so we can unwind the log for verify
694 static void log_io_piece(struct thread_data *td, struct io_u *io_u)
696 struct io_piece *ipo = malloc(sizeof(struct io_piece));
697 struct list_head *entry;
699 INIT_LIST_HEAD(&ipo->list);
700 ipo->offset = io_u->offset;
701 ipo->len = io_u->buflen;
704 * for random io where the writes extend the file, it will typically
705 * be laid out with the block scattered as written. it's faster to
706 * read them in in that order again, so don't sort
708 if (td->sequential || !td->overwrite) {
709 list_add_tail(&ipo->list, &td->io_hist_list);
714 * for random io, sort the list so verify will run faster
716 entry = &td->io_hist_list;
717 while ((entry = entry->prev) != &td->io_hist_list) {
718 struct io_piece *__ipo = list_entry(entry, struct io_piece, list);
720 if (__ipo->offset < ipo->offset)
724 list_add(&ipo->list, entry);
727 static int sync_td(struct thread_data *td)
730 return td->io_sync(td);
735 static int io_u_getevents(struct thread_data *td, int min, int max,
738 return td->io_getevents(td, min, max, t);
741 static int io_u_queue(struct thread_data *td, struct io_u *io_u)
743 gettimeofday(&io_u->issue_time, NULL);
745 return td->io_queue(td, io_u);
748 #define iocb_time(iocb) ((unsigned long) (iocb)->data)
750 static void io_completed(struct thread_data *td, struct io_u *io_u,
751 struct io_completion_data *icd)
756 gettimeofday(&e, NULL);
759 unsigned int bytes = io_u->buflen - io_u->resid;
760 int idx = io_u->ddir;
762 td->io_blocks[idx]++;
763 td->io_bytes[idx] += bytes;
764 td->zone_bytes += bytes;
765 td->this_io_bytes[idx] += bytes;
767 msec = mtime_since(&io_u->issue_time, &e);
769 add_clat_sample(td, io_u->ddir, msec);
770 add_bw_sample(td, io_u->ddir);
772 if (td_write(td) && io_u->ddir == DDIR_WRITE)
773 log_io_piece(td, io_u);
775 icd->bytes_done[idx] += bytes;
777 icd->error = io_u->error;
780 static void ios_completed(struct thread_data *td,struct io_completion_data *icd)
786 icd->bytes_done[0] = icd->bytes_done[1] = 0;
788 for (i = 0; i < icd->nr; i++) {
789 io_u = td->io_event(td, i);
791 io_completed(td, io_u, icd);
796 static void cleanup_pending_aio(struct thread_data *td)
798 struct timespec ts = { .tv_sec = 0, .tv_nsec = 0};
799 struct list_head *entry, *n;
800 struct io_completion_data icd;
805 * get immediately available events, if any
807 r = io_u_getevents(td, 0, td->cur_depth, &ts);
810 ios_completed(td, &icd);
814 * now cancel remaining active events
817 list_for_each_safe(entry, n, &td->io_u_busylist) {
818 io_u = list_entry(entry, struct io_u, list);
820 r = td->io_cancel(td, io_u);
827 r = io_u_getevents(td, td->cur_depth, td->cur_depth, NULL);
830 ios_completed(td, &icd);
835 static int do_io_u_verify(struct thread_data *td, struct io_u **io_u)
837 struct io_u *v_io_u = *io_u;
841 ret = verify_io_u(v_io_u);
842 put_io_u(td, v_io_u);
849 static void do_verify(struct thread_data *td)
852 struct io_u *io_u, *v_io_u = NULL;
853 struct io_completion_data icd;
856 td_set_runstate(td, TD_VERIFYING);
862 gettimeofday(&t, NULL);
863 if (runtime_exceeded(td, &t))
866 io_u = __get_io_u(td);
870 if (get_next_verify(td, &io_u->offset, &io_u->buflen)) {
875 if (td_io_prep(td, io_u, 1)) {
880 ret = io_u_queue(td, io_u);
888 * we have one pending to verify, do that while
889 * we are doing io on the next one
891 if (do_io_u_verify(td, &v_io_u))
894 ret = io_u_getevents(td, 1, 1, NULL);
901 v_io_u = td->io_event(td, 0);
904 io_completed(td, v_io_u, &icd);
907 td_verror(td, icd.error);
908 put_io_u(td, v_io_u);
914 * if we can't submit more io, we need to verify now
916 if (queue_full(td) && do_io_u_verify(td, &v_io_u))
921 do_io_u_verify(td, &v_io_u);
924 cleanup_pending_aio(td);
926 td_set_runstate(td, TD_RUNNING);
929 static void do_io(struct thread_data *td)
931 struct io_completion_data icd;
935 while (td->this_io_bytes[td->ddir] < td->io_size) {
936 struct timespec ts = { .tv_sec = 0, .tv_nsec = 0};
937 struct timespec *timeout;
938 int ret, min_evts = 0;
948 memcpy(&s, &io_u->start_time, sizeof(s));
950 ret = io_u_queue(td, io_u);
957 add_slat_sample(td, io_u->ddir, mtime_since(&io_u->start_time, &io_u->issue_time));
959 if (td->cur_depth < td->iodepth) {
967 ret = io_u_getevents(td, min_evts, td->cur_depth, timeout);
975 ios_completed(td, &icd);
977 td_verror(td, icd.error);
982 * the rate is batched for now, it should work for batches
983 * of completions except the very first one which may look
986 gettimeofday(&e, NULL);
987 usec = utime_since(&s, &e);
989 rate_throttle(td, usec, icd.bytes_done[td->ddir]);
991 if (check_min_rate(td, &e)) {
992 td_verror(td, ENOMEM);
996 if (runtime_exceeded(td, &e))
1000 usec_sleep(td, td->thinktime);
1002 if (should_fsync(td) && td->fsync_blocks &&
1003 (td->io_blocks[DDIR_WRITE] % td->fsync_blocks) == 0)
1008 cleanup_pending_aio(td);
1010 if (should_fsync(td))
1014 static void cleanup_io(struct thread_data *td)
1020 static int init_io(struct thread_data *td)
1022 if (td->io_engine == FIO_SYNCIO)
1023 return fio_syncio_init(td);
1024 else if (td->io_engine == FIO_MMAPIO)
1025 return fio_mmapio_init(td);
1026 else if (td->io_engine == FIO_LIBAIO)
1027 return fio_libaio_init(td);
1028 else if (td->io_engine == FIO_POSIXAIO)
1029 return fio_posixaio_init(td);
1030 else if (td->io_engine == FIO_SGIO)
1031 return fio_sgio_init(td);
1033 fprintf(stderr, "bad io_engine %d\n", td->io_engine);
1038 static void cleanup_io_u(struct thread_data *td)
1040 struct list_head *entry, *n;
1043 list_for_each_safe(entry, n, &td->io_u_freelist) {
1044 io_u = list_entry(entry, struct io_u, list);
1046 list_del(&io_u->list);
1050 if (td->mem_type == MEM_MALLOC)
1051 free(td->orig_buffer);
1052 else if (td->mem_type == MEM_SHM) {
1053 struct shmid_ds sbuf;
1055 shmdt(td->orig_buffer);
1056 shmctl(td->shm_id, IPC_RMID, &sbuf);
1057 } else if (td->mem_type == MEM_MMAP)
1058 munmap(td->orig_buffer, td->orig_buffer_size);
1060 fprintf(stderr, "Bad memory type %d\n", td->mem_type);
1062 td->orig_buffer = NULL;
1065 static int init_io_u(struct thread_data *td)
1071 if (td->io_engine & FIO_SYNCIO)
1074 max_units = td->iodepth;
1076 td->orig_buffer_size = td->max_bs * max_units + MASK;
1078 if (td->mem_type == MEM_MALLOC)
1079 td->orig_buffer = malloc(td->orig_buffer_size);
1080 else if (td->mem_type == MEM_SHM) {
1081 td->shm_id = shmget(IPC_PRIVATE, td->orig_buffer_size, IPC_CREAT | 0600);
1082 if (td->shm_id < 0) {
1083 td_verror(td, errno);
1088 td->orig_buffer = shmat(td->shm_id, NULL, 0);
1089 if (td->orig_buffer == (void *) -1) {
1090 td_verror(td, errno);
1092 td->orig_buffer = NULL;
1095 } else if (td->mem_type == MEM_MMAP) {
1096 td->orig_buffer = mmap(NULL, td->orig_buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | OS_MAP_ANON, 0, 0);
1097 if (td->orig_buffer == MAP_FAILED) {
1098 td_verror(td, errno);
1100 td->orig_buffer = NULL;
1105 INIT_LIST_HEAD(&td->io_u_freelist);
1106 INIT_LIST_HEAD(&td->io_u_busylist);
1107 INIT_LIST_HEAD(&td->io_hist_list);
1109 p = ALIGN(td->orig_buffer);
1110 for (i = 0; i < max_units; i++) {
1111 io_u = malloc(sizeof(*io_u));
1112 memset(io_u, 0, sizeof(*io_u));
1113 INIT_LIST_HEAD(&io_u->list);
1115 io_u->buf = p + td->max_bs * i;
1117 list_add(&io_u->list, &td->io_u_freelist);
1123 static int create_file(struct thread_data *td, unsigned long long size,
1126 unsigned long long left;
1132 * unless specifically asked for overwrite, let normal io extend it
1134 if (td_write(td) && !td->overwrite)
1138 fprintf(stderr, "Need size for create\n");
1139 td_verror(td, EINVAL);
1144 oflags = O_CREAT | O_TRUNC;
1145 printf("Client%d: Laying out IO file (%LuMiB)\n", td->thread_number, size >> 20);
1148 printf("Client%d: Extending IO file (%Lu -> %LuMiB)\n", td->thread_number, (td->file_size - size) >> 20, td->file_size >> 20);
1151 td->fd = open(td->file_name, O_WRONLY | oflags, 0644);
1153 td_verror(td, errno);
1157 if (!extend && ftruncate(td->fd, td->file_size) == -1) {
1158 td_verror(td, errno);
1162 td->io_size = td->file_size;
1163 b = malloc(td->max_bs);
1164 memset(b, 0, td->max_bs);
1167 while (left && !td->terminate) {
1172 r = write(td->fd, b, bs);
1174 if (r == (int) bs) {
1179 td_verror(td, errno);
1188 unlink(td->file_name);
1189 else if (td->create_fsync)
1198 static int file_size(struct thread_data *td)
1202 if (fstat(td->fd, &st) == -1) {
1203 td_verror(td, errno);
1207 td->real_file_size = st.st_size;
1209 if (!td->file_size || td->file_size > td->real_file_size)
1210 td->file_size = td->real_file_size;
1212 td->file_size -= td->file_offset;
1216 static int bdev_size(struct thread_data *td)
1218 unsigned long long bytes;
1221 r = blockdev_size(td->fd, &bytes);
1227 td->real_file_size = bytes;
1230 * no extend possibilities, so limit size to device size if too large
1232 if (!td->file_size || td->file_size > td->real_file_size)
1233 td->file_size = td->real_file_size;
1235 td->file_size -= td->file_offset;
1239 static int get_file_size(struct thread_data *td)
1243 if (td->filetype == FIO_TYPE_FILE)
1244 ret = file_size(td);
1245 else if (td->filetype == FIO_TYPE_BD)
1246 ret = bdev_size(td);
1248 td->real_file_size = -1;
1253 if (td->file_offset > td->real_file_size) {
1254 fprintf(stderr, "Client%d: offset extends end (%Lu > %Lu)\n", td->thread_number, td->file_offset, td->real_file_size);
1258 td->io_size = td->file_size;
1259 if (td->io_size == 0) {
1260 fprintf(stderr, "Client%d: no io blocks\n", td->thread_number);
1261 td_verror(td, EINVAL);
1266 td->zone_size = td->io_size;
1268 td->total_io_size = td->io_size * td->loops;
1272 static int setup_file_mmap(struct thread_data *td)
1281 if (td->verify != VERIFY_NONE)
1285 td->mmap = mmap(NULL, td->file_size, flags, MAP_SHARED, td->fd, td->file_offset);
1286 if (td->mmap == MAP_FAILED) {
1288 td_verror(td, errno);
1292 if (td->invalidate_cache) {
1293 if (madvise(td->mmap, td->file_size, MADV_DONTNEED) < 0) {
1294 td_verror(td, errno);
1299 if (td->sequential) {
1300 if (madvise(td->mmap, td->file_size, MADV_SEQUENTIAL) < 0) {
1301 td_verror(td, errno);
1305 if (madvise(td->mmap, td->file_size, MADV_RANDOM) < 0) {
1306 td_verror(td, errno);
1314 static int setup_file_plain(struct thread_data *td)
1316 if (td->invalidate_cache) {
1317 if (fadvise(td->fd, td->file_offset, td->file_size, POSIX_FADV_DONTNEED) < 0) {
1318 td_verror(td, errno);
1323 if (td->sequential) {
1324 if (fadvise(td->fd, td->file_offset, td->file_size, POSIX_FADV_SEQUENTIAL) < 0) {
1325 td_verror(td, errno);
1329 if (fadvise(td->fd, td->file_offset, td->file_size, POSIX_FADV_RANDOM) < 0) {
1330 td_verror(td, errno);
1338 static int setup_file(struct thread_data *td)
1343 if (stat(td->file_name, &st) == -1) {
1344 if (errno != ENOENT) {
1345 td_verror(td, errno);
1348 if (!td->create_file) {
1349 td_verror(td, ENOENT);
1352 if (create_file(td, td->file_size, 0))
1354 } else if (td->filetype == FIO_TYPE_FILE) {
1355 if (st.st_size < (off_t) td->file_size) {
1356 if (create_file(td, td->file_size - st.st_size, 1))
1365 if (td->filetype == FIO_TYPE_CHAR)
1370 td->fd = open(td->file_name, flags);
1372 if (td->filetype == FIO_TYPE_FILE) {
1383 td->fd = open(td->file_name, flags, 0600);
1387 td_verror(td, errno);
1391 if (get_file_size(td))
1394 if (td->io_engine != FIO_MMAPIO)
1395 return setup_file_plain(td);
1397 return setup_file_mmap(td);
1400 static int check_dev_match(dev_t dev, char *path)
1402 unsigned int major, minor;
1406 f = fopen(path, "r");
1408 perror("open path");
1412 p = fgets(line, sizeof(line), f);
1418 if (sscanf(p, "%u:%u", &major, &minor) != 2) {
1423 if (((major << 8) | minor) == dev) {
1432 static int find_block_dir(dev_t dev, char *path)
1443 while ((dir = readdir(D)) != NULL) {
1444 char full_path[256];
1446 if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
1448 if (!strcmp(dir->d_name, "device"))
1451 sprintf(full_path, "%s/%s", path, dir->d_name);
1453 if (!strcmp(dir->d_name, "dev")) {
1454 if (!check_dev_match(dev, full_path)) {
1460 if (stat(full_path, &st) == -1) {
1465 if (!S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))
1468 found = find_block_dir(dev, full_path);
1470 strcpy(path, full_path);
1479 static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus)
1486 f = fopen(du->path, "r");
1490 p = fgets(line, sizeof(line), f);
1496 if (sscanf(p, "%u %u %llu %u %u %u %llu %u %u %u %u\n", &dus->ios[0], &dus->merges[0], &dus->sectors[0], &dus->ticks[0], &dus->ios[1], &dus->merges[1], &dus->sectors[1], &dus->ticks[1], &in_flight, &dus->io_ticks, &dus->time_in_queue) != 11) {
1505 static void update_io_tick_disk(struct disk_util *du)
1507 struct disk_util_stat __dus, *dus, *ldus;
1510 if (get_io_ticks(du, &__dus))
1514 ldus = &du->last_dus;
1516 dus->sectors[0] += (__dus.sectors[0] - ldus->sectors[0]);
1517 dus->sectors[1] += (__dus.sectors[1] - ldus->sectors[1]);
1518 dus->ios[0] += (__dus.ios[0] - ldus->ios[0]);
1519 dus->ios[1] += (__dus.ios[1] - ldus->ios[1]);
1520 dus->merges[0] += (__dus.merges[0] - ldus->merges[0]);
1521 dus->merges[1] += (__dus.merges[1] - ldus->merges[1]);
1522 dus->ticks[0] += (__dus.ticks[0] - ldus->ticks[0]);
1523 dus->ticks[1] += (__dus.ticks[1] - ldus->ticks[1]);
1524 dus->io_ticks += (__dus.io_ticks - ldus->io_ticks);
1525 dus->time_in_queue += (__dus.time_in_queue - ldus->time_in_queue);
1527 gettimeofday(&t, NULL);
1528 du->msec += mtime_since(&du->time, &t);
1529 memcpy(&du->time, &t, sizeof(t));
1530 memcpy(ldus, &__dus, sizeof(__dus));
1533 static void update_io_ticks(void)
1535 struct list_head *entry;
1536 struct disk_util *du;
1538 list_for_each(entry, &disk_list) {
1539 du = list_entry(entry, struct disk_util, list);
1540 update_io_tick_disk(du);
1544 static int disk_util_exists(dev_t dev)
1546 struct list_head *entry;
1547 struct disk_util *du;
1549 list_for_each(entry, &disk_list) {
1550 du = list_entry(entry, struct disk_util, list);
1559 static void disk_util_add(dev_t dev, char *path)
1561 struct disk_util *du = malloc(sizeof(*du));
1563 memset(du, 0, sizeof(*du));
1564 INIT_LIST_HEAD(&du->list);
1565 sprintf(du->path, "%s/stat", path);
1566 du->name = strdup(basename(path));
1569 gettimeofday(&du->time, NULL);
1570 get_io_ticks(du, &du->last_dus);
1572 list_add_tail(&du->list, &disk_list);
1575 static void init_disk_util(struct thread_data *td)
1578 char foo[256], tmp[256];
1582 if (!td->do_disk_util)
1585 if (!stat(td->file_name, &st)) {
1586 if (S_ISBLK(st.st_mode))
1592 * must be a file, open "." in that path
1594 strcpy(foo, td->file_name);
1597 perror("disk util stat");
1604 if (disk_util_exists(dev))
1607 sprintf(foo, "/sys/block");
1608 if (!find_block_dir(dev, foo))
1612 * for md/dm, there's no queue dir. we already have the right place
1614 sprintf(tmp, "%s/stat", foo);
1615 if (stat(tmp, &st)) {
1617 * if this is inside a partition dir, jump back to parent
1619 sprintf(tmp, "%s/queue", foo);
1620 if (stat(tmp, &st)) {
1622 sprintf(tmp, "%s/queue", p);
1623 if (stat(tmp, &st)) {
1624 fprintf(stderr, "unknown sysfs layout\n");
1627 sprintf(foo, "%s", p);
1631 disk_util_add(dev, foo);
1634 static void disk_util_timer_arm(void)
1636 itimer.it_value.tv_sec = 0;
1637 itimer.it_value.tv_usec = DISK_UTIL_MSEC * 1000;
1638 setitimer(ITIMER_REAL, &itimer, NULL);
1641 static void clear_io_state(struct thread_data *td)
1643 if (td->io_engine == FIO_SYNCIO)
1644 lseek(td->fd, SEEK_SET, 0);
1647 td->stat_io_bytes[0] = td->stat_io_bytes[1] = 0;
1648 td->this_io_bytes[0] = td->this_io_bytes[1] = 0;
1652 memset(td->file_map, 0, td->num_maps * sizeof(long));
1655 static void update_rusage_stat(struct thread_data *td)
1657 if (!(td->runtime[0] + td->runtime[1]))
1660 getrusage(RUSAGE_SELF, &td->ru_end);
1662 td->usr_time += mtime_since(&td->ru_start.ru_utime, &td->ru_end.ru_utime);
1663 td->sys_time += mtime_since(&td->ru_start.ru_stime, &td->ru_end.ru_stime);
1664 td->ctx += td->ru_end.ru_nvcsw + td->ru_end.ru_nivcsw - (td->ru_start.ru_nvcsw + td->ru_start.ru_nivcsw);
1667 memcpy(&td->ru_start, &td->ru_end, sizeof(td->ru_end));
1670 static void *thread_main(void *data)
1672 struct thread_data *td = data;
1675 if (!td->use_thread)
1683 if (fio_setaffinity(td) == -1) {
1684 td_verror(td, errno);
1692 if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) {
1693 td_verror(td, errno);
1698 sem_post(&startup_sem);
1699 sem_wait(&td->mutex);
1701 if (!td->create_serialize && setup_file(td))
1704 if (init_random_state(td))
1707 gettimeofday(&td->epoch, NULL);
1709 while (td->loops--) {
1710 getrusage(RUSAGE_SELF, &td->ru_start);
1711 gettimeofday(&td->start, NULL);
1712 memcpy(&td->stat_sample_time, &td->start, sizeof(td->start));
1715 memcpy(&td->lastrate, &td->stat_sample_time, sizeof(td->lastrate));
1718 prune_io_piece_log(td);
1722 td->runtime[td->ddir] += mtime_since_now(&td->start);
1723 update_rusage_stat(td);
1725 if (td->error || td->terminate)
1728 if (td->verify == VERIFY_NONE)
1732 gettimeofday(&td->start, NULL);
1736 td->runtime[DDIR_READ] += mtime_since_now(&td->start);
1738 if (td->error || td->terminate)
1745 finish_log(td, td->bw_log, "bw");
1747 finish_log(td, td->slat_log, "slat");
1749 finish_log(td, td->clat_log, "clat");
1751 if (exitall_on_terminate)
1752 terminate_threads(td->groupid);
1760 munmap(td->mmap, td->file_size);
1764 sem_post(&startup_sem);
1765 sem_wait(&td->mutex);
1767 td_set_runstate(td, TD_EXITED);
1772 static void *fork_main(int shmid, int offset)
1774 struct thread_data *td;
1777 data = shmat(shmid, NULL, 0);
1778 if (data == (void *) -1) {
1783 td = data + offset * sizeof(struct thread_data);
1789 static int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
1790 double *mean, double *dev)
1794 if (is->samples == 0)
1800 n = (double) is->samples;
1801 *mean = (double) is->val / n;
1802 *dev = sqrt(((double) is->val_sq - (*mean * *mean) / n) / (n - 1));
1803 if (!(*min + *max) && !(*mean + *dev))
1809 static void show_ddir_status(struct thread_data *td, struct group_run_stats *rs,
1812 char *ddir_str[] = { "read ", "write" };
1813 unsigned long min, max, bw;
1816 if (!td->runtime[ddir])
1819 bw = td->io_bytes[ddir] / td->runtime[ddir];
1820 printf(" %s: io=%6lluMiB, bw=%6luKiB/s, runt=%6lumsec\n", ddir_str[ddir], td->io_bytes[ddir] >> 20, bw, td->runtime[ddir]);
1822 if (calc_lat(&td->slat_stat[ddir], &min, &max, &mean, &dev))
1823 printf(" slat (msec): min=%5lu, max=%5lu, avg=%5.02f, dev=%5.02f\n", min, max, mean, dev);
1825 if (calc_lat(&td->clat_stat[ddir], &min, &max, &mean, &dev))
1826 printf(" clat (msec): min=%5lu, max=%5lu, avg=%5.02f, dev=%5.02f\n", min, max, mean, dev);
1828 if (calc_lat(&td->bw_stat[ddir], &min, &max, &mean, &dev)) {
1831 p_of_agg = mean * 100 / (double) rs->agg[ddir];
1832 printf(" bw (KiB/s) : min=%5lu, max=%5lu, per=%3.2f%%, avg=%5.02f, dev=%5.02f\n", min, max, p_of_agg, mean, dev);
1836 static void show_thread_status(struct thread_data *td,
1837 struct group_run_stats *rs)
1839 double usr_cpu, sys_cpu;
1841 if (!(td->io_bytes[0] + td->io_bytes[1]) && !td->error)
1844 printf("Client%d (groupid=%d): err=%2d:\n", td->thread_number, td->groupid, td->error);
1846 show_ddir_status(td, rs, td->ddir);
1847 show_ddir_status(td, rs, td->ddir ^ 1);
1849 if (td->runtime[0] + td->runtime[1]) {
1850 double runt = td->runtime[0] + td->runtime[1];
1852 usr_cpu = (double) td->usr_time * 100 / runt;
1853 sys_cpu = (double) td->sys_time * 100 / runt;
1859 printf(" cpu : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu\n", usr_cpu, sys_cpu, td->ctx);
1862 static void check_str_update(struct thread_data *td)
1864 char c = run_str[td->thread_number - 1];
1866 if (td->runstate == td->old_runstate)
1869 switch (td->runstate) {
1895 case TD_NOT_CREATED:
1899 printf("state %d\n", td->runstate);
1902 run_str[td->thread_number - 1] = c;
1903 td->old_runstate = td->runstate;
1906 static void eta_to_str(char *str, int eta_sec)
1908 unsigned int d, h, m, s;
1909 static int always_d, always_h;
1921 if (d || always_d) {
1923 str += sprintf(str, "%02dd:", d);
1925 if (h || always_h) {
1927 str += sprintf(str, "%02dh:", h);
1930 str += sprintf(str, "%02dm:", m);
1931 str += sprintf(str, "%02ds", s);
1934 static int thread_eta(struct thread_data *td, unsigned long elapsed)
1936 unsigned long long bytes_total, bytes_done;
1937 unsigned int eta_sec = 0;
1939 bytes_total = td->total_io_size;
1942 if (td->zone_size && td->zone_skip)
1943 bytes_total /= (td->zone_skip / td->zone_size);
1945 if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) {
1947 bytes_done = td->io_bytes[DDIR_READ] + td->io_bytes[DDIR_WRITE];
1948 perc = (double) bytes_done / (double) bytes_total;
1952 eta_sec = (elapsed * (1.0 / perc)) - elapsed;
1954 if (eta_sec > (td->timeout - elapsed))
1955 eta_sec = td->timeout - elapsed;
1956 } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED) {
1957 int t_eta = 0, r_eta = 0;
1960 * We can only guess - assume it'll run the full timeout
1961 * if given, otherwise assume it'll run at the specified rate.
1964 t_eta = td->timeout + td->start_delay - elapsed;
1966 r_eta = (bytes_total / 1024) / td->rate;
1967 r_eta += td->start_delay - elapsed;
1971 eta_sec = min(r_eta, t_eta);
1980 * thread is already done
1988 static void print_thread_status(void)
1990 unsigned long elapsed = time_since_now(&genesis);
1991 int i, nr_running, t_rate, m_rate, *eta_secs, eta_sec;
1995 eta_secs = malloc(thread_number * sizeof(int));
1996 memset(eta_secs, 0, thread_number * sizeof(int));
1998 nr_running = t_rate = m_rate = 0;
1999 for (i = 0; i < thread_number; i++) {
2000 struct thread_data *td = &threads[i];
2002 if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING){
2005 m_rate += td->ratemin;
2009 eta_secs[i] = thread_eta(td, elapsed);
2011 check_str_update(td);
2014 if (exitall_on_terminate)
2019 for (i = 0; i < thread_number; i++) {
2020 if (exitall_on_terminate) {
2021 if (eta_secs[i] < eta_sec)
2022 eta_sec = eta_secs[i];
2024 if (eta_secs[i] > eta_sec)
2025 eta_sec = eta_secs[i];
2029 if (eta_sec == INT_MAX)
2033 perc = (double) elapsed / (double) (elapsed + eta_sec);
2034 eta_to_str(eta_str, eta_sec);
2037 printf("Threads now running (%d)", nr_running);
2038 if (m_rate || t_rate)
2039 printf(", commitrate %d/%dKiB/sec", t_rate, m_rate);
2042 printf(": [%s] [%3.2f%% done] [eta %s]", run_str, perc,eta_str);
2049 static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
2054 * reap exited threads (TD_EXITED -> TD_REAPED)
2056 for (i = 0; i < thread_number; i++) {
2057 struct thread_data *td = &threads[i];
2059 if (td->runstate != TD_EXITED)
2062 td_set_runstate(td, TD_REAPED);
2064 if (td->use_thread) {
2067 if (pthread_join(td->thread, (void *) &ret))
2068 perror("thread_join");
2070 waitpid(td->pid, NULL, 0);
2073 (*m_rate) -= td->ratemin;
2074 (*t_rate) -= td->rate;
2078 static void run_threads(void)
2080 struct thread_data *td;
2081 unsigned long spent;
2082 int i, todo, nr_running, m_rate, t_rate, nr_started;
2084 printf("Starting %d thread%s\n", thread_number, thread_number > 1 ? "s" : "");
2087 signal(SIGINT, sig_handler);
2088 signal(SIGALRM, sig_handler);
2090 todo = thread_number;
2093 m_rate = t_rate = 0;
2095 for (i = 0; i < thread_number; i++) {
2098 run_str[td->thread_number - 1] = 'P';
2102 if (!td->create_serialize)
2106 * do file setup here so it happens sequentially,
2107 * we don't want X number of threads getting their
2108 * client data interspersed on disk
2110 if (setup_file(td)) {
2111 td_set_runstate(td, TD_REAPED);
2116 gettimeofday(&genesis, NULL);
2120 * create threads (TD_NOT_CREATED -> TD_CREATED)
2122 for (i = 0; i < thread_number; i++) {
2125 if (td->runstate != TD_NOT_CREATED)
2129 * never got a chance to start, killed by other
2130 * thread for some reason
2132 if (td->terminate) {
2137 if (td->start_delay) {
2138 spent = mtime_since_now(&genesis);
2140 if (td->start_delay * 1000 > spent)
2144 if (td->stonewall && (nr_started || nr_running))
2147 td_set_runstate(td, TD_CREATED);
2148 sem_init(&startup_sem, 0, 1);
2152 if (td->use_thread) {
2153 if (pthread_create(&td->thread, NULL, thread_main, td)) {
2154 perror("thread_create");
2159 sem_wait(&startup_sem);
2161 fork_main(shm_id, i);
2168 * start created threads (TD_CREATED -> TD_RUNNING)
2170 for (i = 0; i < thread_number; i++) {
2173 if (td->runstate != TD_CREATED)
2176 td_set_runstate(td, TD_RUNNING);
2179 m_rate += td->ratemin;
2181 sem_post(&td->mutex);
2184 reap_threads(&nr_running, &t_rate, &m_rate);
2190 while (nr_running) {
2191 reap_threads(&nr_running, &t_rate, &m_rate);
2198 static void show_group_stats(struct group_run_stats *rs, int id)
2200 printf("\nRun status group %d (all jobs):\n", id);
2202 if (rs->max_run[DDIR_READ])
2203 printf(" READ: io=%lluMiB, aggrb=%llu, minb=%llu, maxb=%llu, mint=%llumsec, maxt=%llumsec\n", rs->io_mb[0], rs->agg[0], rs->min_bw[0], rs->max_bw[0], rs->min_run[0], rs->max_run[0]);
2204 if (rs->max_run[DDIR_WRITE])
2205 printf(" WRITE: io=%lluMiB, aggrb=%llu, minb=%llu, maxb=%llu, mint=%llumsec, maxt=%llumsec\n", rs->io_mb[1], rs->agg[1], rs->min_bw[1], rs->max_bw[1], rs->min_run[1], rs->max_run[1]);
2208 static void show_disk_util(void)
2210 struct disk_util_stat *dus;
2211 struct list_head *entry;
2212 struct disk_util *du;
2215 printf("\nDisk stats (read/write):\n");
2217 list_for_each(entry, &disk_list) {
2218 du = list_entry(entry, struct disk_util, list);
2221 util = (double) 100 * du->dus.io_ticks / (double) du->msec;
2225 printf(" %s: ios=%u/%u, merge=%u/%u, ticks=%u/%u, in_queue=%u, util=%3.2f%%\n", du->name, dus->ios[0], dus->ios[1], dus->merges[0], dus->merges[1], dus->ticks[0], dus->ticks[1], dus->time_in_queue, util);
2229 static void show_run_stats(void)
2231 struct group_run_stats *runstats, *rs;
2232 struct thread_data *td;
2235 runstats = malloc(sizeof(struct group_run_stats) * (groupid + 1));
2237 for (i = 0; i < groupid + 1; i++) {
2240 memset(rs, 0, sizeof(*rs));
2241 rs->min_bw[0] = rs->min_run[0] = ~0UL;
2242 rs->min_bw[1] = rs->min_run[1] = ~0UL;
2245 for (i = 0; i < thread_number; i++) {
2246 unsigned long rbw, wbw;
2251 printf("Client%d: %s\n", td->thread_number, td->verror);
2255 rs = &runstats[td->groupid];
2257 if (td->runtime[0] < rs->min_run[0] || !rs->min_run[0])
2258 rs->min_run[0] = td->runtime[0];
2259 if (td->runtime[0] > rs->max_run[0])
2260 rs->max_run[0] = td->runtime[0];
2261 if (td->runtime[1] < rs->min_run[1] || !rs->min_run[1])
2262 rs->min_run[1] = td->runtime[1];
2263 if (td->runtime[1] > rs->max_run[1])
2264 rs->max_run[1] = td->runtime[1];
2268 rbw = td->io_bytes[0] / td->runtime[0];
2270 wbw = td->io_bytes[1] / td->runtime[1];
2272 if (rbw < rs->min_bw[0])
2273 rs->min_bw[0] = rbw;
2274 if (wbw < rs->min_bw[1])
2275 rs->min_bw[1] = wbw;
2276 if (rbw > rs->max_bw[0])
2277 rs->max_bw[0] = rbw;
2278 if (wbw > rs->max_bw[1])
2279 rs->max_bw[1] = wbw;
2281 rs->io_mb[0] += td->io_bytes[0] >> 20;
2282 rs->io_mb[1] += td->io_bytes[1] >> 20;
2285 for (i = 0; i < groupid + 1; i++) {
2289 rs->agg[0] = (rs->io_mb[0]*1024*1000) / rs->max_run[0];
2291 rs->agg[1] = (rs->io_mb[1]*1024*1000) / rs->max_run[1];
2295 * don't overwrite last signal output
2299 for (i = 0; i < thread_number; i++) {
2301 rs = &runstats[td->groupid];
2303 show_thread_status(td, rs);
2306 for (i = 0; i < groupid + 1; i++)
2307 show_group_stats(&runstats[i], i);
2312 int main(int argc, char *argv[])
2314 if (parse_options(argc, argv))
2317 if (!thread_number) {
2318 printf("Nothing to do\n");
2322 disk_util_timer_arm();