Recent changes (master)
Subsystems (2)
The following changes since commit b2fcbe01bdac01bc5d7f8ddea94f264b9f8c2003:
Ensure that thread_stat alignment is correct (2017-06-19 16:41:51 -0600)
are available in the git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to cf6b7fb4f1883af9cbc443ed2536e7454ed51215:
t/time-test: cleanups (2017-06-22 19:29:35 -0600)
----------------------------------------------------------------
Jens Axboe (10):
Merge branch 'nanosecond-2stage' of https://github.com/vincentkfu/fio into nsec Fixup some style issues
Merge branch 'nsec'
crc32c: use bool
arch: tsc_reliable can be a bool
client/server: bool conversion
iolog: get work items out of shared memory pool
iolog: punt freeing of data back to original thread
iolog: ensure proper flushing of compressed logs
t/time-test: cleanups
Vincent Fu (12):
nanosecond: initial commit changing timeval to timespec
nanosecond: update completion latency recording and normal, json output to use nanoseconds
nanosecond: reconcile terse output with nanosecond timing for latencies
nanosecond: alter gfio to accommodate nanosecond timing
nanosecond: fiologparser_hist set default --group_nr to 29 to match stat.h FIO_IO_U_PLAT_GROUP_NR
nanosecond: fix up conversion of ticks to nsec by doing the conversion in 2 stages
nanosecond: add test program t/time-test for experimenting with cpu clock ticks to nsec conversion lib/seqlock: #include "types.h" for bool type
nanosecond: update t/time-test.c to include experiments using seqlock for conversion
gettime: for better accuracy calculate cycles_per_msec instead of cycles_per_usec
gettime: drop tv_valid->last_cycles and tv_valid->last_tv_valid
server: bump server version for the change to FIO_IO_U_PLAT_GROUP_NR
HOWTO | 2 +- Makefile | 7 + arch/arch-ia64.h | 4 +- arch/arch-ppc.h | 4 +- arch/arch-s390.h | 4 +- arch/arch-x86-common.h | 2 +- arch/arch.h | 2 + backend.c | 42 ++-- client.c | 36 +-- client.h | 11 +- crc/crc32c-arm64.c | 9 +- crc/crc32c-intel.c | 6 +- crc/crc32c.h | 5 +- crc/test.c | 6 +- diskutil.c | 2 +- diskutil.h | 2 +- engines/guasi.c | 2 +- engines/libaio.c | 8 +- engines/rdma.c | 2 +- eta.c | 6 +- fio.h | 24 +- fio_time.h | 16 +- gclient.c | 56 +++-- gettime-thread.c | 14 +- gettime.c | 193 ++++++++++---- gettime.h | 14 +- helper_thread.c | 32 +-- idletime.c | 14 +- idletime.h | 4 +- io_u.c | 91 +++++-- io_u.h | 4 +- ioengines.c | 4 +- iolog.c | 52 +++- iolog.h | 7 +- lib/seqlock.h | 1 + libfio.c | 8 +- mutex.c | 12 +- options.c | 2 +- os/windows/posix.c | 6 +- profiles/act.c | 2 +- server.c | 13 +- server.h | 6 +- stat.c | 217 ++++++++++------ stat.h | 38 ++- steadystate.c | 2 +- steadystate.h | 2 +- t/arch.c | 2 +- t/debug.c | 2 +- t/dedupe.c | 2 +- t/lfsr-test.c | 2 +- t/time-test.c | 544 ++++++++++++++++++++++++++++++++++++++++ time.c | 36 ++- tools/hist/fiologparser_hist.py | 2 +- verify.c | 2 +- 54 files changed, 1203 insertions(+), 385 deletions(-) create mode 100644 t/time-test.c
---
Diff of recent changes:
HOWTO +1 -1
@@ -3189,7 +3189,7 @@ Split up, the format is as follows: Total IO (KiB), bandwidth (KiB/sec), IOPS, runtime (msec) Submission latency: min, max, mean, stdev (usec) - Completion latency: min, max, mean, stdev(usec) + Completion latency: min, max, mean, stdev (usec) Completion latency percentiles: 20 fields (see below) Total latency: min, max, mean, stdev (usec) Bw (KiB/s): min, max, aggregate percentage of total, mean, stdev
Makefile +7 -0
@@ -250,6 +250,9 @@ T_PIPE_ASYNC_PROGS = t/read-to-pipe-async T_MEMLOCK_OBJS = t/memlock.o T_MEMLOCK_PROGS = t/memlock +T_TT_OBJS = t/time-test.o +T_TT_PROGS = t/time-test + T_OBJS = $(T_SMALLOC_OBJS) T_OBJS += $(T_IEEE_OBJS) T_OBJS += $(T_ZIPF_OBJS)
@@ -261,6 +264,7 @@ T_OBJS += $(T_DEDUPE_OBJS) T_OBJS += $(T_VS_OBJS) T_OBJS += $(T_PIPE_ASYNC_OBJS) T_OBJS += $(T_MEMLOCK_OBJS) +T_OBJS += $(T_TT_OBJS) ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS))) T_DEDUPE_OBJS += os/windows/posix.o lib/hweight.o
@@ -434,6 +438,9 @@ t/fio-dedupe: $(T_DEDUPE_OBJS) t/fio-verify-state: $(T_VS_OBJS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_VS_OBJS) $(LIBS) +t/time-test: $(T_TT_OBJS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_TT_OBJS) $(LIBS) + clean: FORCE @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d oslib/*.d crc/*.d engines/*.d profiles/*.d t/*.d config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h @rm -rf doc/output
arch/arch-ia64.h +2 -2
@@ -28,10 +28,10 @@ static inline unsigned long long get_cpu_clock(void) }#define ARCH_HAVE_INIT -extern int tsc_reliable; +extern bool tsc_reliable;static inline int arch_init (char *envp[]) { - tsc_reliable =1 ; + tsc_reliable = true;return 0 ; }
arch/arch-ppc.h +2 -2
@@ -117,12 +117,12 @@ static void atb_clocktest(void)#endif #define ARCH_HAVE_INIT -extern int tsc_reliable; +extern bool tsc_reliable;static inline int arch_init (char *envp[]) {#if 0 - tsc_reliable =1 ; + tsc_reliable = true;atb_clocktest ();#endif return 0 ;
arch/arch-s390.h +2 -2
@@ -28,10 +28,10 @@ static inline unsigned long long get_cpu_clock(void)#undef ARCH_CPU_CLOCK_WRAPS#define ARCH_HAVE_INIT -extern int tsc_reliable; +extern bool tsc_reliable;static inline int arch_init (char *envp[]) { - tsc_reliable =1 ; + tsc_reliable = true;return 0 ; }
arch/arch-x86-common.h +1 -1
@@ -14,7 +14,7 @@ static inline void cpuid(unsigned int op,#define ARCH_HAVE_INIT -extern int tsc_reliable; +extern bool tsc_reliable;extern int arch_random;static inline void arch_init_intel (unsigned int level)
arch/arch.h +2 -0
@@ -1,6 +1,8 @@#ifndef ARCH_H #define ARCH_H +#include "../lib/types.h" +enum { arch_x86_64 =1 , arch_x86,
backend.c +21 -21
111 lines not on this page · raw message
client.c +19 -17
@@ -48,7 +48,7 @@ struct client_ops fio_client_ops = { .client_type = FIO_CLIENT_TYPE_CLI, }; -static struct timeval eta_tv; +static struct timespec eta_ts;static FLIST_HEAD (client_list);static FLIST_HEAD (eta_list);
@@ -318,7 +318,7 @@ struct fio_client *fio_client_add_explicit(struct client_ops *ops, client->hostname =strdup (hostname);if (type == Fio_client_socket) - client->is_sock =1 ; + client->is_sock = true;else {int ipv6;
@@ -728,7 +728,7 @@ static int __fio_client_send_remote_ini(struct fio_client *client,strcpy ((char *) pdu->file, filename); pdu->client_type =cpu_to_le16 ((uint16_t ) client->type); - client->sent_job =1 ; + client->sent_job = true; ret =fio_net_send_cmd (client->fd,FIO_NET_CMD_LOAD_FILE , pdu, p_size,NULL ,NULL );free (pdu);return ret;
@@ -781,7 +781,7 @@ static int __fio_client_send_local_ini(struct fio_client *client, pdu->buf_len =__cpu_to_le32 (sb.st_size); pdu->client_type =cpu_to_le32 (client->type); - client->sent_job =1 ; + client->sent_job = true; ret =fio_net_send_cmd (client->fd,FIO_NET_CMD_JOB , pdu, p_size,NULL ,NULL );free (pdu);close (fd);
@@ -799,7 +799,7 @@ int fio_client_send_ini(struct fio_client *client, const char *filename, ret =__fio_client_send_remote_ini (client, filename);if (!ret) - client->sent_job =1 ; + client->sent_job = true;return ret; }
@@ -908,6 +908,8 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src) dst->io_u_complete[i] =le32_to_cpu (src->io_u_complete[i]); } +for (i =0 ; i <FIO_IO_U_LAT_N_NR ; i++) + dst->io_u_lat_n[i] =le32_to_cpu (src->io_u_lat_n[i]);for (i =0 ; i <FIO_IO_U_LAT_U_NR ; i++) dst->io_u_lat_u[i] =le32_to_cpu (src->io_u_lat_u[i]);for (i =0 ; i <FIO_IO_U_LAT_M_NR ; i++)
@@ -1001,7 +1003,7 @@ static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd) opt_list = &client->opt_lists[p->ts.thread_number -1 ]; tsobj =show_thread_status (&p->ts, &p->rs, opt_list,NULL ); - client->did_stat =1 ; + client->did_stat = true;if (tsobj) {json_object_add_client_info (tsobj, client);json_array_add_value_object (clients_array, tsobj);
@@ -1123,7 +1125,7 @@ static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd)struct cmd_du_pdu *du = (struct cmd_du_pdu *) cmd->payload;if (!client->disk_stats_shown) { - client->disk_stats_shown =1 ; + client->disk_stats_shown = true;log_info ("\nDisk stats (read/write):\n" ); }
@@ -1869,7 +1871,7 @@ static int handle_cmd_timeout(struct fio_client *client, }static int client_check_cmd_timeout (struct fio_client *client, -struct timeval *now) +struct timespec *now) {struct fio_net_cmd_reply *reply;struct flist_head *entry, *tmp;
@@ -1878,7 +1880,7 @@ static int client_check_cmd_timeout(struct fio_client *client,flist_for_each_safe (entry, tmp, &client->cmd_list) { reply = flist_entry(entry, struct fio_net_cmd_reply, list); -if (mtime_since (&reply->tv, now) <FIO_NET_CLIENT_TIMEOUT ) +if (mtime_since (&reply->ts, now) <FIO_NET_CLIENT_TIMEOUT )continue ;if (!handle_cmd_timeout (client, reply))
@@ -1896,10 +1898,10 @@ static int fio_check_clients_timed_out(void) {struct fio_client *client;struct flist_head *entry, *tmp; -struct timeval tv; +struct timespec ts;int ret =0 ; -fio_gettime (&tv,NULL ); +fio_gettime (&ts,NULL );flist_for_each_safe (entry, tmp, &client_list) { client = flist_entry(entry, struct fio_client, list);
@@ -1907,7 +1909,7 @@ static int fio_check_clients_timed_out(void)if (flist_empty (&client->cmd_list))continue ; -if (!client_check_cmd_timeout (client, &tv)) +if (!client_check_cmd_timeout (client, &ts))continue ;if (client->ops->timed_out)
@@ -1928,7 +1930,7 @@ int fio_handle_clients(struct client_ops *ops)struct pollfd *pfds;int i, ret =0 , retval =0 ; -fio_gettime (&eta_tv,NULL ); +fio_gettime (&eta_ts,NULL ); pfds =malloc (nr_clients *sizeof (struct pollfd ));
@@ -1960,13 +1962,13 @@ int fio_handle_clients(struct client_ops *ops)assert (i == nr_clients); do { - struct timeval tv; + struct timespec ts; int timeout; - fio_gettime(&tv, NULL); - if (mtime_since(&eta_tv, &tv) >= 900) { + fio_gettime(&ts, NULL); + if (mtime_since(&eta_ts, &ts) >= 900) { request_client_etas(ops); - memcpy(&eta_tv, &tv, sizeof(tv)); + memcpy(&eta_ts, &ts, sizeof(ts)); if (fio_check_clients_timed_out()) break;
client.h +6 -5
@@ -6,6 +6,7 @@#include <netinet/in.h> #include <arpa/inet.h> +#include "lib/types.h" #include "stat.h" struct fio_net_cmd ;
@@ -45,16 +46,16 @@ struct fio_client {int state; -int skip_newline; -int is_sock; -int disk_stats_shown; +bool skip_newline; +bool is_sock; +bool disk_stats_shown;unsigned int jobs;unsigned int nr_stat;int error;int signal;int ipv6; -int sent_job; -int did_stat; +bool sent_job; +bool did_stat;uint32_t type;uint32_t thread_number;
crc/crc32c-arm64.c +4 -5
@@ -19,7 +19,7 @@#define HWCAP_CRC32 (1 << 7)#endif /* HWCAP_CRC32 */ -int crc32c_arm64_available =0 ; +bool crc32c_arm64_available = false;#ifdef ARCH_HAVE_ARM64_CRC_CRYPTO
@@ -27,7 +27,7 @@ int crc32c_arm64_available = 0;#include <arm_acle.h> #include <arm_neon.h> -static int crc32c_probed; +static bool crc32c_probed;/* * Function to calculate reflected crc with PMULL Instruction
@@ -106,9 +106,8 @@ void crc32c_arm64_probe(void)if (!crc32c_probed) { hwcap =getauxval (AT_HWCAP ); -if (hwcap &HWCAP_CRC32 ) - crc32c_arm64_available =1 ; - crc32c_probed =1 ; + crc32c_arm64_available = (hwcap &HWCAP_CRC32 ) !=0 ; + crc32c_probed = true; } }
crc/crc32c-intel.c +3 -3
@@ -18,7 +18,7 @@* Volume 2A: Instruction Set Reference, A-M */ -int crc32c_intel_available =0 ; +bool crc32c_intel_available = false;#ifdef ARCH_HAVE_SSE4_2
@@ -30,7 +30,7 @@ int crc32c_intel_available = 0;#define SCALE_F 4#endif -static int crc32c_probed; +static bool crc32c_probed;static uint32_t crc32c_intel_le_hw_byte (uint32_t crc,unsigned char const *data,unsigned long length)
@@ -87,7 +87,7 @@ void crc32c_intel_probe(void)do_cpuid (&eax, &ebx, &ecx, &edx); crc32c_intel_available = (ecx & (1 <<20 )) !=0 ; - crc32c_probed =1 ; + crc32c_probed = true; } }
crc/crc32c.h +3 -2
@@ -19,10 +19,11 @@#define CRC32C_H #include "../arch/arch.h" +#include "../lib/types.h" extern uint32_t crc32c_sw (unsigned char const *,unsigned long ); -extern int crc32c_arm64_available; -extern int crc32c_intel_available; +extern bool crc32c_arm64_available; +extern bool crc32c_intel_available;#ifdef ARCH_HAVE_ARM64_CRC_CRYPTO extern uint32_t crc32c_arm64 (unsigned char const *,unsigned long );
crc/test.c +3 -3
@@ -392,7 +392,7 @@ int fio_crctest(const char *type)fill_random_buf (&state, buf,CHUNK );for (i =0 ; t[i].name; i++) { -struct timeval tv; +struct timespec ts;double mb_sec;uint64_t usec;char pre[3 ];
@@ -409,9 +409,9 @@ int fio_crctest(const char *type) t[i].fn (&t[i], buf,CHUNK ); } -fio_gettime (&tv,NULL ); +fio_gettime (&ts,NULL ); t[i].fn (&t[i], buf,CHUNK ); - usec =utime_since_now (&tv); + usec =utime_since_now (&ts);if (usec) { mb_sec = (double ) mb / (double ) usec;
diskutil.c +1 -1
@@ -84,7 +84,7 @@ static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus)static void update_io_tick_disk (struct disk_util *du) {struct disk_util_stat __dus, *dus, *ldus; -struct timeval t; +struct timespec t;if (!du->users)return ;
diskutil.h +1 -1
@@ -64,7 +64,7 @@ struct disk_util {*/ struct flist_head slaves; -struct timeval time; +struct timespec time;struct fio_mutex *lock;unsigned long users;
engines/guasi.c +1 -1
@@ -132,7 +132,7 @@ static void fio_guasi_queued(struct thread_data *td, struct io_u **io_us, int nr {int i;struct io_u *io_u; -struct timeval now; +struct timespec now;if (!fio_fill_issue_time (td))return ;
engines/libaio.c +4 -4
@@ -220,7 +220,7 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)static void fio_libaio_queued (struct thread_data *td,struct io_u **io_us,unsigned int nr) { -struct timeval now; +struct timespec now;unsigned int i;if (!fio_fill_issue_time (td))
@@ -241,7 +241,7 @@ static int fio_libaio_commit(struct thread_data *td)struct libaio_data *ld = td->io_ops_data;struct iocb **iocbs;struct io_u **io_us; -struct timeval tv; +struct timespec ts;int ret, wait_start =0 ;if (!ld->queued)
@@ -282,9 +282,9 @@ static int fio_libaio_commit(struct thread_data *td)break ; }if (!wait_start) { -fio_gettime (&tv,NULL ); +fio_gettime (&ts,NULL ); wait_start =1 ; - }else if (mtime_since_now (&tv) >30000 ) { + }else if (mtime_since_now (&ts) >30000 ) {log_err ("fio: aio appears to be stalled, giving up\n" );break ; }
engines/rdma.c +1 -1
@@ -802,7 +802,7 @@ static void fio_rdmaio_queued(struct thread_data *td, struct io_u **io_us, unsigned int nr) {struct rdmaio_data *rd = td->io_ops_data; -struct timeval now; +struct timespec now;unsigned int i;if (!fio_fill_issue_time (td))
eta.c +3 -3
@@ -358,12 +358,12 @@ bool calc_thread_status(struct jobs_eta *je, int force)uint64_t rate_time, disp_time, bw_avg_time, *eta_secs;unsigned long long io_bytes[DDIR_RWDIR_CNT ];unsigned long long io_iops[DDIR_RWDIR_CNT ]; -struct timeval now; +struct timespec now;static unsigned long long rate_io_bytes[DDIR_RWDIR_CNT ];static unsigned long long disp_io_bytes[DDIR_RWDIR_CNT ];static unsigned long long disp_io_iops[DDIR_RWDIR_CNT ]; -static struct timeval rate_prev_time, disp_prev_time; +static struct timespec rate_prev_time, disp_prev_time;if (!force) { if (!(output_format & FIO_OUTPUT_NORMAL) &&
@@ -511,7 +511,7 @@ bool calc_thread_status(struct jobs_eta *je, int force)void display_thread_status (struct jobs_eta *je) { -static struct timeval disp_eta_new_line; +static struct timespec disp_eta_new_line;static int eta_new_line_init, eta_new_line_pending;static int linelen_last;static int eta_good;
fio.h +12 -12
@@ -165,10 +165,10 @@ struct thread_data {struct thread_data *parent;uint64_t stat_io_bytes[DDIR_RWDIR_CNT ]; -struct timeval bw_sample_time; +struct timespec bw_sample_time;uint64_t stat_io_blocks[DDIR_RWDIR_CNT ]; -struct timeval iops_sample_time; +struct timespec iops_sample_time;volatile int update_rusage;struct fio_mutex *rusage_sem;
@@ -287,7 +287,7 @@ struct thread_data {unsigned long rate_bytes[DDIR_RWDIR_CNT ];unsigned long rate_blocks[DDIR_RWDIR_CNT ];unsigned long long rate_io_issue_bytes[DDIR_RWDIR_CNT ]; -struct timeval lastrate[DDIR_RWDIR_CNT ]; +struct timespec lastrate[DDIR_RWDIR_CNT ];int64_t last_usec[DDIR_RWDIR_CNT ];struct frand_state poisson_state[DDIR_RWDIR_CNT ];
@@ -323,21 +323,21 @@ struct thread_data {*/ struct frand_state random_state; -struct timeval start;/* start of this loop */ -struct timeval epoch;/* time job was started */ +struct timespec start;/* start of this loop */ +struct timespec epoch;/* time job was started */ unsigned long long unix_epoch;/* Time job was started, unix epoch based. */ -struct timeval last_issue; +struct timespec last_issue;long time_offset; -struct timeval tv_cache; -struct timeval terminate_time; -unsigned int tv_cache_nr; -unsigned int tv_cache_mask; +struct timespec ts_cache; +struct timespec terminate_time; +unsigned int ts_cache_nr; +unsigned int ts_cache_mask;unsigned int ramp_time_over;/* * Time since last latency_window was started */ -struct timeval latency_ts; +struct timespec latency_ts;unsigned int latency_qd;unsigned int latency_qd_high;unsigned int latency_qd_low;
@@ -642,7 +642,7 @@ extern void reset_all_stats(struct thread_data *);extern int io_queue_event (struct thread_data *td,struct io_u *io_u,int *ret,enum fio_ddir ddir,uint64_t *bytes_issued,int from_verify, -struct timeval *comp_time); +struct timespec *comp_time);/* * Latency target helpers
fio_time.h +9 -7
@@ -4,22 +4,24 @@#include "lib/types.h" struct thread_data ; -extern uint64_t utime_since (const struct timeval *,const struct timeval *); -extern uint64_t utime_since_now (const struct timeval *); -extern uint64_t mtime_since (const struct timeval *,const struct timeval *); -extern uint64_t mtime_since_now (const struct timeval *); -extern uint64_t time_since_now (const struct timeval *); +extern uint64_t ntime_since (const struct timespec *,const struct timespec *); +extern uint64_t utime_since (const struct timespec *,const struct timespec *); +extern uint64_t utime_since_now (const struct timespec *); +extern uint64_t mtime_since (const struct timespec *,const struct timespec *); +extern uint64_t mtime_since_now (const struct timespec *); +extern uint64_t mtime_since_tv (const struct timeval *,const struct timeval *); +extern uint64_t time_since_now (const struct timespec *);extern uint64_t time_since_genesis (void );extern uint64_t mtime_since_genesis (void );extern uint64_t utime_since_genesis (void );extern uint64_t usec_spin (unsigned int );extern uint64_t usec_sleep (struct thread_data *,unsigned long ); -extern void fill_start_time (struct timeval *); +extern void fill_start_time (struct timespec *);extern void set_genesis_time (void );extern bool ramp_time_over (struct thread_data *);extern bool in_ramp_time (struct thread_data *);extern void fio_time_init (void ); -extern void timeval_add_msec (struct timeval *,unsigned int ); +extern void timespec_add_msec (struct timespec *,unsigned int );extern void set_epoch_time (struct thread_data *,int );#endif
gclient.c +33 -23
127 lines not on this page · raw message
gettime-thread.c +7 -7
@@ -6,30 +6,30 @@#include "fio.h" #include "smalloc.h" -struct timeval *fio_tv =NULL ; +struct timespec *fio_ts =NULL ;int fio_gtod_offload =0 ;static pthread_t gtod_thread;static os_cpu_mask_t fio_gtod_cpumask;void fio_gtod_init (void ) { -if (fio_tv) +if (fio_ts)return ; - fio_tv =smalloc (sizeof (struct timeval )); -if (!fio_tv) + fio_ts =smalloc (sizeof (*fio_ts)); +if (!fio_ts)log_err ("fio: smalloc pool exhausted\n" ); }static void fio_gtod_update (void ) { -if (fio_tv) { +if (fio_ts) {struct timeval __tv;gettimeofday (&__tv,NULL ); - fio_tv->tv_sec = __tv.tv_sec; + fio_ts->tv_sec = __tv.tv_sec;write_barrier (); - fio_tv->tv_usec = __tv.tv_usec; + fio_ts->tv_nsec = __tv.tv_usec *1000 ;write_barrier (); } }
gettime.c +140 -53
323 lines not on this page · raw message
gettime.h +7 -7
@@ -13,27 +13,27 @@ enum fio_cs { CS_INVAL, }; -extern void fio_gettime (struct timeval *,void *); +extern void fio_gettime (struct timespec *,void *);extern void fio_gtod_init (void );extern void fio_clock_init (void );extern int fio_start_gtod_thread (void );extern int fio_monotonic_clocktest (int debug);extern void fio_local_clock_init (int ); -extern struct timeval *fio_tv; +extern struct timespec *fio_ts; -static inline int fio_gettime_offload (struct timeval *tv) +static inline int fio_gettime_offload (struct timespec *ts) {time_t last_sec; -if (!fio_tv) +if (!fio_ts)return 0 ;do {read_barrier (); - last_sec = tv->tv_sec = fio_tv->tv_sec; - tv->tv_usec = fio_tv->tv_usec; - }while (fio_tv->tv_sec != last_sec); + last_sec = ts->tv_sec = fio_ts->tv_sec; + ts->tv_nsec = fio_ts->tv_nsec; + }while (fio_ts->tv_sec != last_sec);return 1 ; }
helper_thread.c +16 -16
@@ -71,45 +71,45 @@ static void *helper_thread_main(void *data) {struct helper_data *hd = data;unsigned int msec_to_next_event, next_log, next_ss =STEADYSTATE_MSEC ; -struct timeval tv, last_du, last_ss; +struct timeval tv; +struct timespec ts, last_du, last_ss;int ret =0 ;sk_out_assign (hd->sk_out);gettimeofday (&tv,NULL ); -memcpy (&last_du, &tv,sizeof (tv)); -memcpy (&last_ss, &tv,sizeof (tv)); + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = tv.tv_usec *1000 ; +memcpy (&last_du, &ts,sizeof (ts)); +memcpy (&last_ss, &ts,sizeof (ts));fio_mutex_up (hd->startup_mutex); msec_to_next_event =DISK_UTIL_MSEC ;while (!ret && !hd->exit) { -struct timespec ts; -struct timeval now;uint64_t since_du, since_ss =0 ; -timeval_add_msec (&tv, msec_to_next_event); - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec *1000 ; +timespec_add_msec (&ts, msec_to_next_event);pthread_mutex_lock (&hd->lock);pthread_cond_timedwait (&hd->cond, &hd->lock, &ts); -gettimeofday (&now,NULL ); +gettimeofday (&tv,NULL ); + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = tv.tv_usec *1000 ;if (hd->reset) { -memcpy (&tv, &now,sizeof (tv)); -memcpy (&last_du, &now,sizeof (last_du)); -memcpy (&last_ss, &now,sizeof (last_ss)); +memcpy (&last_du, &ts,sizeof (ts)); +memcpy (&last_ss, &ts,sizeof (ts)); hd->reset =0 ; }pthread_mutex_unlock (&hd->lock); - since_du =mtime_since (&last_du, &now); + since_du =mtime_since (&last_du, &ts);if (since_du >=DISK_UTIL_MSEC ||DISK_UTIL_MSEC - since_du <10 ) { ret =update_io_ticks (); -timeval_add_msec (&last_du,DISK_UTIL_MSEC ); +timespec_add_msec (&last_du,DISK_UTIL_MSEC ); msec_to_next_event =DISK_UTIL_MSEC ;if (since_du >=DISK_UTIL_MSEC ) msec_to_next_event -= (since_du -DISK_UTIL_MSEC );
@@ -126,10 +126,10 @@ static void *helper_thread_main(void *data) next_log =DISK_UTIL_MSEC ;if (steadystate_enabled) { - since_ss =mtime_since (&last_ss, &now); + since_ss =mtime_since (&last_ss, &ts);if (since_ss >=STEADYSTATE_MSEC ||STEADYSTATE_MSEC - since_ss <10 ) {steadystate_check (); -timeval_add_msec (&last_ss, since_ss); +timespec_add_msec (&last_ss, since_ss);if (since_ss >STEADYSTATE_MSEC ) next_ss =STEADYSTATE_MSEC - (since_ss -STEADYSTATE_MSEC );else
idletime.c +5 -9
@@ -11,7 +11,7 @@ static volatile struct idle_prof_common ipc;static double calibrate_unit (unsigned char *data) {unsigned long t, i, j, k; -struct timeval tps; +struct timespec tps;double tunit =0.0 ;for (i =0 ; i <CALIBRATE_RUNS ; i++) {
@@ -183,7 +183,6 @@ static void calibration_stats(void)void fio_idle_prof_init (void ) {int i, ret; -struct timeval tp;struct timespec ts;pthread_attr_t tattr;struct idle_prof_thread *ipt;
@@ -282,9 +281,8 @@ void fio_idle_prof_init(void)pthread_mutex_lock (&ipt->init_lock);while ((ipt->state !=TD_EXITED ) && (ipt->state!=TD_INITIALIZED )) { -fio_gettime (&tp,NULL ); - ts.tv_sec = tp.tv_sec +1 ; - ts.tv_nsec = tp.tv_usec *1000 ; +fio_gettime (&ts,NULL ); + ts.tv_sec +=1 ;pthread_cond_timedwait (&ipt->cond, &ipt->init_lock, &ts); }pthread_mutex_unlock (&ipt->init_lock);
@@ -325,7 +323,6 @@ void fio_idle_prof_stop(void) {int i;uint64_t runt; -struct timeval tp;struct timespec ts;struct idle_prof_thread *ipt;
@@ -343,9 +340,8 @@ void fio_idle_prof_stop(void)pthread_mutex_lock (&ipt->start_lock);while ((ipt->state !=TD_EXITED ) && (ipt->state!=TD_NOT_CREATED )) { -fio_gettime (&tp,NULL ); - ts.tv_sec = tp.tv_sec +1 ; - ts.tv_nsec = tp.tv_usec *1000 ; +fio_gettime (&ts,NULL ); + ts.tv_sec +=1 ;/* timed wait in case a signal is not received */ pthread_cond_timedwait (&ipt->cond, &ipt->start_lock, &ts); }
idletime.h +2 -2
@@ -26,8 +26,8 @@ struct idle_prof_thread {pthread_t thread;int cpu;int state; -struct timeval tps; -struct timeval tpe; +struct timespec tps; +struct timespec tpe;double cali_time;/* microseconds to finish a unit work */ double loops;double idleness;
io_u.c +68 -23
166 lines not on this page · raw message
io_u.h +2 -2
@@ -31,8 +31,8 @@ enum {* The io unit */ struct io_u { -struct timeval start_time; -struct timeval issue_time; +struct timespec start_time; +struct timespec issue_time;struct fio_file *file;unsigned int flags;
ioengines.c +2 -2
@@ -281,7 +281,7 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)*/ if (td->o.read_iolog_file)memcpy (&td->last_issue, &io_u->issue_time, -sizeof (struct timeval )); +sizeof (io_u->issue_time)); }if (ddir_rw (ddir)) {
@@ -356,7 +356,7 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)*/ if (td->o.read_iolog_file)memcpy (&td->last_issue, &io_u->issue_time, -sizeof (struct timeval )); +sizeof (io_u->issue_time)); }return ret;
iolog.c +46 -6
106 lines not on this page · raw message
iolog.h +6 -1
@@ -131,6 +131,11 @@ struct io_log {pthread_mutex_t chunk_lock;unsigned int chunk_seq;struct flist_head chunk_list; + +pthread_mutex_t deferred_free_lock; +#define IOLOG_MAX_DEFER 8 +void *deferred_items[IOLOG_MAX_DEFER ]; +unsigned int deferred; };/*
@@ -259,7 +264,7 @@ struct log_params {static inline bool per_unit_log (struct io_log *log) { -return log && !log->avg_msec; +return log && (!log->avg_msec || log->log_gz || log->log_gz_store); }static inline bool inline_log (struct io_log *log)
lib/seqlock.h +1 -0
@@ -1,6 +1,7 @@#ifndef FIO_SEQLOCK_H #define FIO_SEQLOCK_H +#include "types.h" #include "../arch/arch.h" struct seqlock {
libfio.c +4 -4
@@ -144,10 +144,10 @@ void reset_all_stats(struct thread_data *td) }set_epoch_time (td, td->o.log_unix_epoch); -memcpy (&td->start, &td->epoch,sizeof (struct timeval )); -memcpy (&td->iops_sample_time, &td->epoch,sizeof (struct timeval )); -memcpy (&td->bw_sample_time, &td->epoch,sizeof (struct timeval )); -memcpy (&td->ss.prev_time, &td->epoch,sizeof (struct timeval )); +memcpy (&td->start, &td->epoch,sizeof (td->epoch)); +memcpy (&td->iops_sample_time, &td->epoch,sizeof (td->epoch)); +memcpy (&td->bw_sample_time, &td->epoch,sizeof (td->epoch)); +memcpy (&td->ss.prev_time, &td->epoch,sizeof (td->epoch));lat_target_reset (td);clear_rusage_stat (td);
mutex.c +8 -4
@@ -141,11 +141,15 @@ struct fio_mutex *fio_mutex_init(int value)return NULL ; } -static bool mutex_timed_out (struct timeval *t,unsigned int msecs) +static bool mutex_timed_out (struct timespec *t,unsigned int msecs) { -struct timeval now; +struct timeval tv; +struct timespec now; + +gettimeofday (&tv,NULL ); + now.tv_sec = tv.tv_sec; + now.tv_nsec = tv.tv_usec *1000 ; -gettimeofday (&now,NULL );return mtime_since (t, &now) >= msecs; }
@@ -177,7 +181,7 @@ int fio_mutex_down_timeout(struct fio_mutex *mutex, unsigned int msecs)* way too early, double check. */ ret =pthread_cond_timedwait (&mutex->cond, &mutex->lock, &t); -if (ret ==ETIMEDOUT && !mutex_timed_out (&tv_s, msecs)) +if (ret ==ETIMEDOUT && !mutex_timed_out (&t, msecs)) ret =0 ; } mutex->waiters--;
options.c +1 -1
@@ -1381,7 +1381,7 @@ static int str_gtod_reduce_cb(void *data, int *il) td->o.disable_bw = !!val; td->o.clat_percentiles = !val;if (val) - td->tv_cache_mask =63 ; + td->ts_cache_mask =63 ;return 0 ; }
os/windows/posix.c +3 -3
@@ -25,8 +25,8 @@#include "../os-windows.h" #include "../../lib/hweight.h" -extern unsigned long mtime_since_now (struct timeval *); -extern void fio_gettime (struct timeval *,void *); +extern unsigned long mtime_since_now (struct timespec *); +extern void fio_gettime (struct timespec *,void *);/* These aren't defined in the MinGW headers */ HRESULT WINAPI StringCchCopyA(
@@ -852,7 +852,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)int nanosleep (const struct timespec *rqtp,struct timespec *rmtp) { -struct timeval tv; +struct timespec tv;DWORD ms_remaining;DWORD ms_total = (rqtp->tv_sec *1000 ) + (rqtp->tv_nsec /1000000.0 );
profiles/act.c +1 -1
@@ -47,7 +47,7 @@ struct act_run_data {static struct act_run_data *act_run_data;struct act_prof_data { -struct timeval sample_tv; +struct timespec sample_tv;struct act_slice *slices;unsigned int cur_slice;unsigned int nr_slices;
server.c +8 -5
@@ -438,7 +438,7 @@ static uint64_t alloc_reply(uint64_t tag, uint16_t opcode) reply =calloc (1 ,sizeof (*reply));INIT_FLIST_HEAD (&reply->list); -fio_gettime (&reply->tv,NULL ); +fio_gettime (&reply->ts,NULL ); reply->saved_tag = tag; reply->opcode = opcode;
@@ -1497,6 +1497,8 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.io_u_complete[i] =cpu_to_le32 (ts->io_u_complete[i]); } +for (i =0 ; i <FIO_IO_U_LAT_N_NR ; i++) + p.ts.io_u_lat_n[i] =cpu_to_le32 (ts->io_u_lat_n[i]);for (i =0 ; i <FIO_IO_U_LAT_U_NR ; i++) p.ts.io_u_lat_u[i] =cpu_to_le32 (ts->io_u_lat_u[i]);for (i =0 ; i <FIO_IO_U_LAT_M_NR ; i++)
@@ -2268,7 +2270,7 @@ int fio_server_parse_host(const char *host, int ipv6, struct in_addr *inp,* For local domain sockets: * *ptr is the filename, *is_sock is 1. */ -int fio_server_parse_string (const char *str,char **ptr,int *is_sock, +int fio_server_parse_string (const char *str,char **ptr,bool *is_sock,int *port,struct in_addr *inp,struct in6_addr *inp6,int *ipv6) {
@@ -2277,13 +2279,13 @@ int fio_server_parse_string(const char *str, char **ptr, int *is_sock,int lport =0 ; *ptr =NULL ; - *is_sock =0 ; + *is_sock = false; *port = fio_net_port; *ipv6 =0 ;if (!strncmp (str,"sock:" ,5 )) { *ptr =strdup (str +5 ); - *is_sock =1 ; + *is_sock = true;return 0 ; }
@@ -2362,7 +2364,8 @@ int fio_server_parse_string(const char *str, char **ptr, int *is_sock,static int fio_handle_server_arg (void ) {int port = fio_net_port; -int is_sock, ret =0 ; +bool is_sock; +int ret =0 ; saddr_in.sin_addr.s_addr =htonl (INADDR_ANY );
server.h +3 -3
@@ -43,13 +43,13 @@ struct fio_net_cmd {struct fio_net_cmd_reply {struct flist_head list; -struct timeval tv; +struct timespec ts;uint64_t saved_tag;uint16_t opcode; };enum { -FIO_SERVER_VER =63 , +FIO_SERVER_VER =64 ,FIO_SERVER_MAX_FRAGMENT_PDU =1024 ,FIO_SERVER_MAX_CMD_MB =2048 ,
@@ -212,7 +212,7 @@ extern int fio_server_text_output(int, const char *, size_t);extern int fio_net_send_cmd (int ,uint16_t ,const void *,off_t ,uint64_t *,struct flist_head *);extern int fio_net_send_simple_cmd (int ,uint16_t ,uint64_t ,struct flist_head *);extern void fio_server_set_arg (const char *); -extern int fio_server_parse_string (const char *,char **,int *,int *,struct in_addr *,struct in6_addr *,int *); +extern int fio_server_parse_string (const char *,char **,bool *,int *,struct in_addr *,struct in6_addr *,int *);extern int fio_server_parse_host (const char *,int ,struct in_addr *,struct in6_addr *);extern const char *fio_server_op (unsigned int );extern void fio_server_got_signal (int );
stat.c +135 -82
546 lines not on this page · raw message
stat.h +29 -9
@@ -19,6 +19,7 @@ struct group_run_stats {* How many depth levels to log */ #define FIO_IO_U_MAP_NR 7 +#define FIO_IO_U_LAT_N_NR 10#define FIO_IO_U_LAT_U_NR 10#define FIO_IO_U_LAT_M_NR 12
@@ -108,7 +109,7 @@ struct group_run_stats {#define FIO_IO_U_PLAT_BITS 6#define FIO_IO_U_PLAT_VAL (1 << FIO_IO_U_PLAT_BITS) -#define FIO_IO_U_PLAT_GROUP_NR 19 +#define FIO_IO_U_PLAT_GROUP_NR 29#define FIO_IO_U_PLAT_NR (FIO_IO_U_PLAT_GROUP_NR * FIO_IO_U_PLAT_VAL)#define FIO_IO_U_LIST_MAX_LEN 20/* The size of the default and user-specified list of percentiles */
@@ -178,6 +179,7 @@ struct thread_stat {uint32_t io_u_map[FIO_IO_U_MAP_NR ];uint32_t io_u_submit[FIO_IO_U_MAP_NR ];uint32_t io_u_complete[FIO_IO_U_MAP_NR ]; +uint32_t io_u_lat_n[FIO_IO_U_LAT_N_NR ];uint32_t io_u_lat_u[FIO_IO_U_LAT_U_NR ];uint32_t io_u_lat_m[FIO_IO_U_LAT_M_NR ];uint32_t io_u_plat[DDIR_RWDIR_CNT ][FIO_IO_U_PLAT_NR ];
@@ -286,8 +288,9 @@ extern void sum_group_stats(struct group_run_stats *dst, struct group_run_statsextern void init_thread_stat (struct thread_stat *ts);extern void init_group_run_stat (struct group_run_stats *gs);extern void eta_to_str (char *str,unsigned long eta_sec); -extern bool calc_lat (struct io_stat *is,unsigned long *min,unsigned long *max,double *mean,double *dev); -extern unsigned int calc_clat_percentiles (unsigned int *io_u_plat,unsigned long nr,fio_fp64_t *plist,unsigned int **output,unsigned int *maxv,unsigned int *minv); +extern bool calc_lat (struct io_stat *is,unsigned long long *min,unsigned long long *max,double *mean,double *dev); +extern unsigned int calc_clat_percentiles (unsigned int *io_u_plat,unsigned long nr,fio_fp64_t *plist,unsigned long long **output,unsigned long long *maxv,unsigned long long *minv); +extern void stat_calc_lat_n (struct thread_stat *ts,double *io_u_lat);extern void stat_calc_lat_m (struct thread_stat *ts,double *io_u_lat);extern void stat_calc_lat_u (struct thread_stat *ts,double *io_u_lat);extern void stat_calc_dist (unsigned int *map,unsigned long total,double *io_u_dist);
@@ -295,9 +298,9 @@ extern void reset_io_stats(struct thread_data *);extern void update_rusage_stat (struct thread_data *);extern void clear_rusage_stat (struct thread_data *); -extern void add_lat_sample (struct thread_data *,enum fio_ddir ,unsigned long , +extern void add_lat_sample (struct thread_data *,enum fio_ddir ,unsigned long long ,unsigned int ,uint64_t ); -extern void add_clat_sample (struct thread_data *,enum fio_ddir ,unsigned long , +extern void add_clat_sample (struct thread_data *,enum fio_ddir ,unsigned long long ,unsigned int ,uint64_t );extern void add_slat_sample (struct thread_data *,enum fio_ddir ,unsigned long ,unsigned int ,uint64_t );
@@ -305,16 +308,17 @@ extern void add_agg_sample(union io_sample_data, enum fio_ddir, unsigned int);extern void add_iops_sample (struct thread_data *,struct io_u *,unsigned int );extern void add_bw_sample (struct thread_data *,struct io_u *, -unsigned int ,unsigned long ); +unsigned int ,unsigned long long );extern int calc_log_samples (void );extern struct io_log *agg_io_log[DDIR_RWDIR_CNT ];extern int write_bw_log; -static inline bool usec_to_msec (unsigned long *min,unsigned long *max, -double *mean,double *dev) +static inline bool nsec_to_usec (unsigned long long *min, +unsigned long long *max,double *mean, +double *dev) { -if (*min >1000 && *max >1000 && *mean >1000.0 && *dev >1000.0 ) { +if (*min >2000 && *max >99999 && *dev >1000.0 ) { *min /=1000 ; *max /=1000 ; *mean /=1000.0 ;
@@ -324,6 +328,22 @@ static inline bool usec_to_msec(unsigned long *min, unsigned long *max,return false; } + +static inline bool nsec_to_msec (unsigned long long *min, +unsigned long long *max,double *mean, +double *dev) +{ +if (*min >2000000 && *max >99999999ULL && *dev >1000000.0 ) { + *min /=1000000 ; + *max /=1000000 ; + *mean /=1000000.0 ; + *dev /=1000000.0 ; +return true; + } + +return false; +} +/* * Worst level condensing would be 1:5, so allow enough room for that */
steadystate.c +1 -1
@@ -196,7 +196,7 @@ void steadystate_check(void)int i, j, ddir, prev_groupid, group_ramp_time_over =0 ;unsigned long rate_time;struct thread_data *td, *td2; -struct timeval now; +struct timespec now;uint64_t group_bw =0 , group_iops =0 ;uint64_t td_iops, td_bytes;bool ret;
steadystate.h +1 -1
@@ -35,7 +35,7 @@ struct steadystate_data {uint64_t sum_xy;uint64_t oldest_y; -struct timeval prev_time; +struct timespec prev_time;uint64_t prev_iops;uint64_t prev_bytes; };
t/arch.c +1 -1
@@ -1,5 +1,5 @@#include "../arch/arch.h" unsigned long arch_flags =0 ; -int tsc_reliable; +bool tsc_reliable;int arch_random;
t/debug.c +1 -1
@@ -1,7 +1,7 @@#include <stdio.h> FILE *f_err; -struct timeval *fio_tv =NULL ; +struct timespec *fio_ts =NULL ;unsigned long fio_debug =0 ;void __dprint (int type,const char *str, ...)
t/dedupe.c +1 -1
@@ -334,7 +334,7 @@ static void *thread_fn(void *data)static void show_progress (struct worker_thread *threads,unsigned long total) {unsigned long last_nitems =0 ; -struct timeval last_tv; +struct timespec last_tv;fio_gettime (&last_tv,NULL );
t/lfsr-test.c +1 -1
@@ -27,7 +27,7 @@ void usage()int main (int argc,char *argv[]) {int r; -struct timeval start, end; +struct timespec start, end;struct fio_lfsr *fl;int verify =0 ;unsigned int spin =0 ;
t/time-test.c new file +544 -0
544 lines not on this page · raw message
time.c +16 -20
@@ -3,23 +3,23 @@#include "fio.h" -static struct timeval genesis; +static struct timespec genesis;static unsigned long ns_granularity; -void timeval_add_msec (struct timeval *tv,unsigned int msec) +void timespec_add_msec (struct timespec *ts,unsigned int msec) { -unsigned long adj_usec =1000 * msec; +unsigned long adj_nsec =1000000 * msec; - tv->tv_usec += adj_usec; -if (adj_usec >=1000000 ) { -unsigned long adj_sec = adj_usec /1000000 ; + ts->tv_nsec += adj_nsec; +if (adj_nsec >=1000000000 ) { +unsigned long adj_sec = adj_nsec /1000000000UL ; - tv->tv_usec -= adj_sec *1000000 ; - tv->tv_sec += adj_sec; + ts->tv_nsec -= adj_sec *1000000000UL ; + ts->tv_sec += adj_sec; } -if (tv->tv_usec >=1000000 ){ - tv->tv_usec -=1000000 ; - tv->tv_sec++; +if (ts->tv_nsec >=1000000000UL ){ + ts->tv_nsec -=1000000000UL ; + ts->tv_sec++; } }
@@ -28,7 +28,7 @@ void timeval_add_msec(struct timeval *tv, unsigned int msec)*/ uint64_t usec_spin (unsigned int usec) { -struct timeval start; +struct timespec start;uint64_t t;fio_gettime (&start,NULL );
@@ -41,7 +41,7 @@ uint64_t usec_spin(unsigned int usec)uint64_t usec_sleep (struct thread_data *td,unsigned long usec) {struct timespec req; -struct timeval tv; +struct timespec tv;uint64_t t =0 ; do {
@@ -111,13 +111,10 @@ static void parent_update_ramp(struct thread_data *td)bool ramp_time_over (struct thread_data *td) { -struct timeval tv; -if (!td->o.ramp_time || td->ramp_time_over)return true; -fio_gettime (&tv,NULL );
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.