From: Jens Axboe Date: Mon, 22 May 2017 16:23:25 +0000 (-0600) Subject: Merge branch 'bugfix' of https://github.com/YukiKita/fio X-Git-Tag: fio-2.21~44 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=af13d1e88158d3e37940648be139d7a46fe00431;hp=002e57665ed7eebe920de6f1729ef2e403b7c6cc Merge branch 'bugfix' of https://github.com/YukiKita/fio --- diff --git a/FIO-VERSION-GEN b/FIO-VERSION-GEN index 4cc903fd..a9ddb31d 100755 --- a/FIO-VERSION-GEN +++ b/FIO-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=FIO-VERSION-FILE -DEF_VER=fio-2.19 +DEF_VER=fio-2.20 LF=' ' diff --git a/HOWTO b/HOWTO index d9e881ab..a899b902 100644 --- a/HOWTO +++ b/HOWTO @@ -1290,7 +1290,7 @@ Block size means default for reads, 8k for writes and trims. **bs=,8k,** - means default for reads, 8k for writes, and default for writes. + means default for reads, 8k for writes, and default for trims. .. option:: blocksize_range=irange[,irange][,irange], bsrange=irange[,irange][,irange] diff --git a/Makefile b/Makefile index 1f0f5d04..c3e551df 100644 --- a/Makefile +++ b/Makefile @@ -140,7 +140,7 @@ ifeq ($(CONFIG_TARGET_OS), Linux) LDFLAGS += -rdynamic endif ifeq ($(CONFIG_TARGET_OS), Android) - SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c \ + SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \ oslib/linux-dev-lookup.c LIBS += -ldl LDFLAGS += -rdynamic diff --git a/configure b/configure index 21bcaf46..03275787 100755 --- a/configure +++ b/configure @@ -1930,16 +1930,7 @@ fi cat > $TMPC << EOF #include #include -#undef offsetof -#ifdef __compiler_offsetof -#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) -#else -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#include struct foo { int a, b; diff --git a/fio.1 b/fio.1 index 0167c23e..301a7081 100644 --- a/fio.1 +++ b/fio.1 @@ -533,7 +533,7 @@ bs=256k means 256k for reads, writes and trims bs=8k,32k means 8k for reads, 32k for writes and trims bs=8k,32k, means 8k for reads, 32k for writes, and default for trims bs=,8k means default for reads, 8k for writes and trims -bs=,8k, means default for reads, 8k for writes, and default for writes +bs=,8k, means default for reads, 8k for writes, and default for trims .fi .TP .BI blocksize_range \fR=\fPirange[,irange][,irange] "\fR,\fB bsrange" \fR=\fPirange[,irange][,irange] diff --git a/fio.h b/fio.h index e11a0390..ed631bc7 100644 --- a/fio.h +++ b/fio.h @@ -149,7 +149,7 @@ struct thread_data { unsigned int thread_number; unsigned int subjob_number; unsigned int groupid; - struct thread_stat ts; + struct thread_stat ts __attribute__ ((aligned)); int client_type; diff --git a/flist.h b/flist.h index b4fe6e65..2ca3d777 100644 --- a/flist.h +++ b/flist.h @@ -2,13 +2,7 @@ #define _LINUX_FLIST_H #include - -#undef offsetof -#ifdef __compiler_offsetof -#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) -#else -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif +#include #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ diff --git a/libfio.c b/libfio.c index 83107084..da22456e 100644 --- a/libfio.c +++ b/libfio.c @@ -353,14 +353,17 @@ int initialize_fio(char *envp[]) * can run into problems on archs that fault on unaligned fp * access (ARM). */ + compiletime_assert((offsetof(struct thread_data, ts) % sizeof(void *)) == 0, "ts"); compiletime_assert((offsetof(struct thread_stat, percentile_list) % 8) == 0, "stat percentile_list"); compiletime_assert((offsetof(struct thread_stat, total_run_time) % 8) == 0, "total_run_time"); compiletime_assert((offsetof(struct thread_stat, total_err_count) % 8) == 0, "total_err_count"); compiletime_assert((offsetof(struct thread_stat, latency_percentile) % 8) == 0, "stat latency_percentile"); + compiletime_assert((offsetof(struct thread_data, ts.clat_stat) % 8) == 0, "ts.clat_stat"); compiletime_assert((offsetof(struct thread_options_pack, zipf_theta) % 8) == 0, "zipf_theta"); compiletime_assert((offsetof(struct thread_options_pack, pareto_h) % 8) == 0, "pareto_h"); compiletime_assert((offsetof(struct thread_options_pack, percentile_list) % 8) == 0, "percentile_list"); compiletime_assert((offsetof(struct thread_options_pack, latency_percentile) % 8) == 0, "latency_percentile"); + compiletime_assert((offsetof(struct jobs_eta, m_rate) % 8) == 0, "m_rate"); err = endian_check(); if (err) { diff --git a/os/os-android.h b/os/os-android.h index 6c3e0985..c56d6827 100644 --- a/os/os-android.h +++ b/os/os-android.h @@ -32,6 +32,7 @@ #define FIO_HAVE_HUGETLB #define FIO_HAVE_BLKTRACE #define FIO_HAVE_CL_SIZE +#define FIO_HAVE_CGROUPS #define FIO_HAVE_FS_STAT #define FIO_HAVE_TRIM #define FIO_HAVE_GETTID @@ -59,19 +60,17 @@ #ifndef CONFIG_NO_SHM /* - * The Android NDK doesn't currently export , so define the - * necessary stuff here. + * Bionic doesn't support SysV shared memeory, so implement it using ashmem */ - -#include -#define SHM_HUGETLB 04000 - #include #include +#include +#define shmid_ds shmid64_ds +#define SHM_HUGETLB 04000 #define ASHMEM_DEVICE "/dev/ashmem" -static inline int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) +static inline int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) { int ret=0; if (__cmd == IPC_RMID) @@ -84,7 +83,7 @@ static inline int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) return ret; } -static inline int shmget (key_t __key, size_t __size, int __shmflg) +static inline int shmget(key_t __key, size_t __size, int __shmflg) { int fd,ret; char keybuf[11]; @@ -98,7 +97,8 @@ static inline int shmget (key_t __key, size_t __size, int __shmflg) if (ret < 0) goto error; - ret = ioctl(fd, ASHMEM_SET_SIZE, __size); + /* Stores size in first 8 bytes, allocate extra space */ + ret = ioctl(fd, ASHMEM_SET_SIZE, __size + sizeof(uint64_t)); if (ret < 0) goto error; @@ -109,21 +109,22 @@ error: return ret; } -static inline void *shmat (int __shmid, const void *__shmaddr, int __shmflg) +static inline void *shmat(int __shmid, const void *__shmaddr, int __shmflg) { - size_t *ptr, size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); - ptr = mmap(NULL, size + sizeof(size_t), PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0); - *ptr = size; //save size at beginning of buffer, for use with munmap - return &ptr[1]; + size_t size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); + /* Needs to be 8-byte aligned to prevent SIGBUS on 32-bit ARM */ + uint64_t *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0); + /* Save size at beginning of buffer, for use with munmap */ + *ptr = size; + return ptr + 1; } static inline int shmdt (const void *__shmaddr) { - size_t *ptr, size; - ptr = (size_t *)__shmaddr; - ptr--; - size = *ptr; //find mmap size which we stored at the beginning of the buffer - return munmap((void *)ptr, size + sizeof(size_t)); + /* Find mmap size which we stored at the beginning of the buffer */ + uint64_t *ptr = (uint64_t *)__shmaddr - 1; + size_t size = *ptr; + return munmap(ptr, size); } #endif diff --git a/os/os-linux.h b/os/os-linux.h index 911f7e7c..ba53590d 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -314,9 +314,13 @@ static inline int fio_set_sched_idle(void) static inline void make_pos_h_l(unsigned long *pos_h, unsigned long *pos_l, off_t offset) { +#if BITS_PER_LONG == 64 + *pos_l = offset; + *pos_h = 0; +#else *pos_l = offset & 0xffffffff; *pos_h = ((uint64_t) offset) >> 32; - +#endif } static inline ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, unsigned int flags) diff --git a/os/windows/install.wxs b/os/windows/install.wxs index ffaed8e1..05d2a83b 100755 --- a/os/windows/install.wxs +++ b/os/windows/install.wxs @@ -10,7 +10,7 @@ + UpgradeCode="2338A332-5511-43CF-B9BD-5C60496CCFCC" Version="2.20"> bw_log) { + if (log) { unsigned int bs = 0; if (td->o.min_bs[ddir] == td->o.max_bs[ddir]) @@ -2541,12 +2541,14 @@ int calc_log_samples(void) next = min(td->o.iops_avg_time, td->o.bw_avg_time); continue; } - if (td->bw_log && !per_unit_log(td->bw_log)) { + if (!td->bw_log || + (td->bw_log && !per_unit_log(td->bw_log))) { tmp = add_bw_samples(td, &now); if (tmp < next) next = tmp; } - if (td->iops_log && !per_unit_log(td->iops_log)) { + if (!td->iops_log || + (td->iops_log && !per_unit_log(td->iops_log))) { tmp = add_iops_samples(td, &now); if (tmp < next) next = tmp; diff --git a/stat.h b/stat.h index aa4ad806..d8a08034 100644 --- a/stat.h +++ b/stat.h @@ -242,17 +242,17 @@ struct jobs_eta { uint32_t nr_pending; uint32_t nr_setting_up; - uint32_t files_open; - uint64_t m_rate[DDIR_RWDIR_CNT], t_rate[DDIR_RWDIR_CNT]; - uint32_t m_iops[DDIR_RWDIR_CNT], t_iops[DDIR_RWDIR_CNT]; uint64_t rate[DDIR_RWDIR_CNT]; + uint32_t m_iops[DDIR_RWDIR_CNT], t_iops[DDIR_RWDIR_CNT]; uint32_t iops[DDIR_RWDIR_CNT]; uint64_t elapsed_sec; uint64_t eta_sec; uint32_t is_pow2; uint32_t unit_base; + uint32_t files_open; + /* * Network 'copy' of run_str[] */