The following changes since commit e259879ea353f5695a8be662b2748c4f4d0918d9: gettime: add some sanity checks to platform clock (2013-02-24 21:29:35 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (3): Fixup wrong types for dprint() gettime: use 32-bit atomic sequences debug: only do getpid() if we have to debug.c | 3 +-- filesetup.c | 9 +++++---- gettime.c | 29 ++++++++++++++++++----------- io_u.c | 19 ++++++++++++------- memory.c | 12 +++++++----- server.c | 5 +++-- 6 files changed, 46 insertions(+), 31 deletions(-) --- Diff of recent changes: diff --git a/debug.c b/debug.c index 5e98063..ecee8e3 100644 --- a/debug.c +++ b/debug.c @@ -11,9 +11,8 @@ void __dprint(int type, const char *str, ...) assert(type < FD_DEBUG_MAX); - pid = getpid(); if (fio_debug_jobp && *fio_debug_jobp != -1U - && pid != *fio_debug_jobp) + && (pid = getpid() != *fio_debug_jobp)) return; log_local("%-8s ", debug_levels[type].name); diff --git a/filesetup.c b/filesetup.c index ac1804b..220ceb9 100644 --- a/filesetup.c +++ b/filesetup.c @@ -79,7 +79,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f) break; case FIO_FALLOCATE_POSIX: dprint(FD_FILE, "posix_fallocate file %s size %llu\n", - f->file_name, f->real_file_size); + f->file_name, + (unsigned long long) f->real_file_size); r = posix_fallocate(f->fd, 0, f->real_file_size); if (r > 0) { @@ -91,8 +92,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f) case FIO_FALLOCATE_KEEP_SIZE: dprint(FD_FILE, "fallocate(FALLOC_FL_KEEP_SIZE) " - "file %s size %llu\n", - f->file_name, f->real_file_size); + "file %s size %llu\n", f->file_name, + (unsigned long long) f->real_file_size); r = fallocate(f->fd, FALLOC_FL_KEEP_SIZE, 0, f->real_file_size); @@ -118,7 +119,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f) */ if (!td->o.fill_device) { dprint(FD_FILE, "truncate file %s, size %llu\n", f->file_name, - f->real_file_size); + (unsigned long long) f->real_file_size); if (ftruncate(f->fd, f->real_file_size) == -1) { td_verror(td, errno, "ftruncate"); goto err; diff --git a/gettime.c b/gettime.c index d56045c..660ba4c 100644 --- a/gettime.c +++ b/gettime.c @@ -302,11 +302,12 @@ static int calibrate_cpu_clock(void) mean /= 10.0; for (i = 0; i < NR_TIME_ITERS; i++) - dprint(FD_TIME, "cycles[%d]=%lu\n", i, cycles[i] / 10); + dprint(FD_TIME, "cycles[%d]=%llu\n", i, + (unsigned long long) cycles[i] / 10); avg /= samples; avg = (avg + 5) / 10; - dprint(FD_TIME, "avg: %lu\n", avg); + dprint(FD_TIME, "avg: %llu\n", (unsigned long long) avg); dprint(FD_TIME, "mean=%f, S=%f\n", mean, S); cycles_per_usec = avg; @@ -440,9 +441,9 @@ uint64_t time_since_now(struct timeval *s) #define CLOCK_ENTRIES 100000 struct clock_entry { - uint64_t seq; + uint32_t seq; + uint32_t cpu; uint64_t tsc; - uint64_t cpu; }; struct clock_thread { @@ -450,11 +451,11 @@ struct clock_thread { int cpu; pthread_mutex_t lock; pthread_mutex_t started; - uint64_t *seq; + uint32_t *seq; struct clock_entry *entries; }; -static inline uint64_t atomic64_inc_return(uint64_t *seq) +static inline uint32_t atomic32_inc_return(uint32_t *seq) { return 1 + __sync_fetch_and_add(seq, 1); } @@ -464,6 +465,7 @@ static void *clock_thread_fn(void *data) struct clock_thread *t = data; struct clock_entry *c; os_cpu_mask_t cpu_mask; + uint32_t last_seq; int i; memset(&cpu_mask, 0, sizeof(cpu_mask)); @@ -477,13 +479,17 @@ static void *clock_thread_fn(void *data) pthread_mutex_lock(&t->lock); pthread_mutex_unlock(&t->started); + last_seq = 0; c = &t->entries[0]; for (i = 0; i < CLOCK_ENTRIES; i++, c++) { - uint64_t seq, tsc; + uint32_t seq; + uint64_t tsc; c->cpu = t->cpu; do { - seq = atomic64_inc_return(t->seq); + seq = atomic32_inc_return(t->seq); + if (seq < last_seq) + break; tsc = get_cpu_clock(); } while (seq != *t->seq); @@ -491,12 +497,13 @@ static void *clock_thread_fn(void *data) c->tsc = tsc; } - log_info("cs: cpu%3d: %lu clocks seen\n", t->cpu, t->entries[CLOCK_ENTRIES - 1].tsc - t->entries[0].tsc); + log_info("cs: cpu%3d: %lu clocks seen\n", t->cpu, t->entries[i - 1].tsc - t->entries[0].tsc); + /* * The most common platform clock breakage is returning zero * indefinitely. Check for that and return failure. */ - if (!t->entries[CLOCK_ENTRIES - 1].tsc && !t->entries[0].tsc) + if (!t->entries[i - 1].tsc && !t->entries[0].tsc) return (void *) 1; return NULL; @@ -520,7 +527,7 @@ int fio_monotonic_clocktest(void) struct clock_entry *entries; unsigned long tentries, failed; struct clock_entry *prev, *this; - uint64_t seq = 0; + uint32_t seq = 0; int i; log_info("cs: reliable_tsc: %s\n", tsc_reliable ? "yes" : "no"); diff --git a/io_u.c b/io_u.c index 1013c7f..e474b48 100644 --- a/io_u.c +++ b/io_u.c @@ -101,7 +101,7 @@ static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f, r = __rand(&td->__random_state); } - dprint(FD_RANDOM, "off rand %llu\n", r); + dprint(FD_RANDOM, "off rand %llu\n", (unsigned long long) r); *b = (lastb - 1) * (r / ((uint64_t) rmax + 1.0)); } else { @@ -125,7 +125,8 @@ static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f, if (random_map_free(f, *b)) goto ret; - dprint(FD_RANDOM, "get_next_rand_offset: offset %llu busy\n", *b); + dprint(FD_RANDOM, "get_next_rand_offset: offset %llu busy\n", + (unsigned long long) *b); *b = axmap_next_free(f->io_axmap, *b); if (*b == (uint64_t) -1ULL) @@ -242,7 +243,8 @@ static int get_next_rand_block(struct thread_data *td, struct fio_file *f, } dprint(FD_IO, "%s: rand offset failed, last=%llu, size=%llu\n", - f->file_name, f->last_pos, f->real_file_size); + f->file_name, (unsigned long long) f->last_pos, + (unsigned long long) f->real_file_size); return 1; } @@ -344,14 +346,16 @@ static int __get_next_offset(struct thread_data *td, struct io_u *io_u) if (io_u->offset >= f->io_size) { dprint(FD_IO, "get_next_offset: offset %llu >= io_size %llu\n", - io_u->offset, f->io_size); + (unsigned long long) io_u->offset, + (unsigned long long) f->io_size); return 1; } io_u->offset += f->file_offset; if (io_u->offset >= f->real_file_size) { dprint(FD_IO, "get_next_offset: offset %llu >= size %llu\n", - io_u->offset, f->real_file_size); + (unsigned long long) io_u->offset, + (unsigned long long) f->real_file_size); return 1; } @@ -716,8 +720,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) if (io_u->offset + io_u->buflen > io_u->file->real_file_size) { dprint(FD_IO, "io_u %p, offset too large\n", io_u); - dprint(FD_IO, " off=%llu/%lu > %llu\n", io_u->offset, - io_u->buflen, io_u->file->real_file_size); + dprint(FD_IO, " off=%llu/%lu > %llu\n", + (unsigned long long) io_u->offset, io_u->buflen, + (unsigned long long) io_u->file->real_file_size); return 1; } diff --git a/memory.c b/memory.c index 3759c8c..ee5f895 100644 --- a/memory.c +++ b/memory.c @@ -155,8 +155,8 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem) td->orig_buffer = mmap(NULL, total_mem, PROT_READ | PROT_WRITE, flags, td->mmapfd, 0); - dprint(FD_MEM, "mmap %u/%d %p\n", total_mem, td->mmapfd, - td->orig_buffer); + dprint(FD_MEM, "mmap %llu/%d %p\n", (unsigned long long) total_mem, + td->mmapfd, td->orig_buffer); if (td->orig_buffer == MAP_FAILED) { td_verror(td, errno, "mmap"); td->orig_buffer = NULL; @@ -173,7 +173,8 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem) static void free_mem_mmap(struct thread_data *td, size_t total_mem) { - dprint(FD_MEM, "munmap %u %p\n", total_mem, td->orig_buffer); + dprint(FD_MEM, "munmap %llu %p\n", (unsigned long long) total_mem, + td->orig_buffer); munmap(td->orig_buffer, td->orig_buffer_size); if (td->mmapfile) { close(td->mmapfd); @@ -185,7 +186,8 @@ static void free_mem_mmap(struct thread_data *td, size_t total_mem) static int alloc_mem_malloc(struct thread_data *td, size_t total_mem) { td->orig_buffer = malloc(total_mem); - dprint(FD_MEM, "malloc %u %p\n", total_mem, td->orig_buffer); + dprint(FD_MEM, "malloc %llu %p\n", (unsigned long long) total_mem, + td->orig_buffer); return td->orig_buffer == NULL; } @@ -216,7 +218,7 @@ int allocate_io_mem(struct thread_data *td) total_mem += td->o.mem_align - page_size; } - dprint(FD_MEM, "Alloc %lu for buffers\n", (size_t) total_mem); + dprint(FD_MEM, "Alloc %llu for buffers\n", (unsigned long long) total_mem); if (td->o.mem_type == MEM_MALLOC) ret = alloc_mem_malloc(td, total_mem); diff --git a/server.c b/server.c index ad78572..d4676dd 100644 --- a/server.c +++ b/server.c @@ -463,8 +463,9 @@ static int handle_command(struct fio_net_cmd *cmd) { int ret; - dprint(FD_NET, "server: got op [%s], pdu=%u, tag=%lx\n", - fio_server_op(cmd->opcode), cmd->pdu_len, cmd->tag); + dprint(FD_NET, "server: got op [%s], pdu=%u, tag=%llx\n", + fio_server_op(cmd->opcode), cmd->pdu_len, + (unsigned long long) cmd->tag); switch (cmd->opcode) { case FIO_NET_CMD_QUIT: -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html