The following changes since commit 8037423f08649a7c3378dadf95327d6553105264: debug: only do getpid() if we have to (2013-02-25 14:02:42 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (7): debug: make __dprint() have printf() like argument type checking gettime: print 64-bit variable with ULL powerpc: use ATB clock, if it's available powerpc: harden the clock ATB probe a bit configure: use `foo` instead of $(foo) Merge branch 'master' of ssh://brick.kernel.dk/data/git/fio FIO-VERSION-GEN: use `foo` instead of $(foo) FIO-VERSION-GEN | 10 ++++---- arch/arch-ppc.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- arch/arch.h | 2 + configure | 2 +- debug.h | 2 +- gettime.c | 3 +- 6 files changed, 65 insertions(+), 11 deletions(-) --- Diff of recent changes: diff --git a/FIO-VERSION-GEN b/FIO-VERSION-GEN index 85e6f4a..6811d29 100755 --- a/FIO-VERSION-GEN +++ b/FIO-VERSION-GEN @@ -10,14 +10,14 @@ LF=' # then try git-describe, then default. if test -f version then - VN=$(cat version) || VN="$DEF_VER" + VN=`cat version` || VN="$DEF_VER" elif test -d .git -o -f .git && - VN=$(git describe --match "fio-[0-9]*" --abbrev=4 HEAD 2>/dev/null) && + VN=`git describe --match "fio-[0-9]*" --abbrev=4 HEAD 2>/dev/null` && case "$VN" in *$LF*) (exit 1) ;; v[0-9]*) git update-index -q --refresh - test -z "$(git diff-index --name-only HEAD --)" || + test -z "`git diff-index --name-only HEAD --`" || VN="$VN-dirty" ;; esac then @@ -26,11 +26,11 @@ else VN="$DEF_VER" fi -VN=$(expr "$VN" : v*'\(.*\)') +VN=`expr "$VN" : v*'\(.*\)'` if test -r $GVF then - VC=$(sed -e 's/^FIO_VERSION = //' <$GVF) + VC=`sed -e 's/^FIO_VERSION = //' <$GVF` else VC=unset fi diff --git a/arch/arch-ppc.h b/arch/arch-ppc.h index e73093d..0cc0cbd 100644 --- a/arch/arch-ppc.h +++ b/arch/arch-ppc.h @@ -1,6 +1,11 @@ #ifndef ARCH_PPC_H #define ARCH_PPH_H +#include <unistd.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/wait.h> + #define FIO_ARCH (arch_ppc) #ifndef __NR_ioprio_set @@ -43,26 +48,72 @@ static inline int arch_ffz(unsigned long bitmask) return __ilog2(bitmask & -bitmask); } +static inline unsigned int mfspr(unsigned int reg) +{ + unsigned int val; + + asm volatile("mfspr %0,%1": "=r" (val) : "K" (reg)); + return val; +} + +#define SPRN_TBRL 0x10C /* Time Base Register Lower */ +#define SPRN_TBRU 0x10D /* Time Base Register Upper */ +#define SPRN_ATBL 0x20E /* Alternate Time Base Lower */ +#define SPRN_ATBU 0x20F /* Alternate Time Base Upper */ + static inline unsigned long long get_cpu_clock(void) { unsigned int tbl, tbu0, tbu1; unsigned long long ret; do { - __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0)); - __asm__ __volatile__ ("mftb %0" : "=r"(tbl) ); - __asm__ __volatile__ ("mftbu %0" : "=r"(tbu1)); + if (arch_flags & ARCH_FLAG_1) { + tbu0 = mfspr(SPRN_ATBU); + tbl = mfspr(SPRN_ATBL); + tbu1 = mfspr(SPRN_ATBU); + } else { + __asm__ __volatile__("mftbu %0" : "=r"(tbu0)); + __asm__ __volatile__("mftb %0" : "=r"(tbl) ); + __asm__ __volatile__("mftbu %0" : "=r"(tbu1)); + } } while (tbu0 != tbu1); ret = (((unsigned long long)tbu0) << 32) | tbl; return ret; } +static void atb_child(void) +{ + arch_flags |= ARCH_FLAG_1; + get_cpu_clock(); + _exit(0); +} + +static void atb_clocktest(void) +{ + pid_t pid; + + pid = fork(); + if (!pid) + atb_child(); + else if (pid != -1) { + int status; + + pid = wait(&status); + if (pid == -1 || !WIFEXITED(status)) + arch_flags &= ~ARCH_FLAG_1; + else + arch_flags |= ARCH_FLAG_1; + } +} + #define ARCH_HAVE_INIT extern int tsc_reliable; + static inline int arch_init(char *envp[]) { tsc_reliable = 1; + atb_clocktest(); return 0; } diff --git a/arch/arch.h b/arch/arch.h index 4165c9f..31d96d4 100644 --- a/arch/arch.h +++ b/arch/arch.h @@ -27,6 +27,8 @@ enum { ARCH_FLAG_4 = 1 << 3, }; +extern unsigned long arch_flags; + #if defined(__i386__) #include "arch-x86.h" #elif defined(__x86_64__) diff --git a/configure b/configure index caaf30e..8125fc3 100755 --- a/configure +++ b/configure @@ -349,7 +349,7 @@ int main(void) } EOF if compile_prog "" "" "wordsize"; then - wordsize=$($TMPE) + wordsize=`$TMPE` fi echo "Wordsize $wordsize" diff --git a/debug.h b/debug.h index af71d62..6dd2ad8 100644 --- a/debug.h +++ b/debug.h @@ -34,7 +34,7 @@ extern struct debug_level debug_levels[]; extern unsigned long fio_debug; -void __dprint(int type, const char *str, ...); +void __dprint(int type, const char *str, ...) __attribute__((format (printf, 2, 3))); #define dprint(type, str, args...) \ do { \ diff --git a/gettime.c b/gettime.c index 660ba4c..4c998e5 100644 --- a/gettime.c +++ b/gettime.c @@ -497,7 +497,8 @@ static void *clock_thread_fn(void *data) c->tsc = tsc; } - log_info("cs: cpu%3d: %lu clocks seen\n", t->cpu, t->entries[i - 1].tsc - t->entries[0].tsc); + log_info("cs: cpu%3d: %llu clocks seen\n", t->cpu, + (unsigned long long) t->entries[i - 1].tsc - t->entries[0].tsc); /* * The most common platform clock breakage is returning zero -- 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