fio: fix s390 timing for older machines/binutils
authorChristian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Thu, 10 Apr 2014 13:09:47 +0000 (15:09 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 10 Apr 2014 14:04:07 +0000 (08:04 -0600)
Older gcc/binutils or one with very low default march will refuse to use stckf.
On top of that machines older than a z196 don not even have the store clock
fast facility.

To fix all of those issues, check for the facilities in configure step and make
the usage of stckf and a matching march dependent to it.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
arch/arch-s390.h
configure

index 56cb23024bf70f8954cc7bfe29e5b439345f54d7..169282b9d4d308de3e3ca23aa6ba5be7c46613e1 100644 (file)
 #define read_barrier() asm volatile("bcr 15,0" : : : "memory")
 #define write_barrier()        asm volatile("bcr 15,0" : : : "memory")
 
-/*
- * Fio needs monotonic (never lower), but not strict monotonic (never the same)
- * so store clock fast is enough
- */
 static inline unsigned long long get_cpu_clock(void)
 {
        unsigned long long clk;
 
+#ifdef CONFIG_S390_Z196_FACILITIES
+       /*
+        * Fio needs monotonic (never lower), but not strict monotonic (never
+        * the same) so store clock fast is enough.
+        */
        __asm__ __volatile__("stckf %0" : "=Q" (clk) : : "cc");
+#else
+       __asm__ __volatile__("stck %0" : "=Q" (clk) : : "cc");
+#endif
        return clk>>12;
 }
 
index 05f985b6634e5dc516d0ef98dfbf5b45294becae..4757d6705e7ef95bac00eb4fbb2865a431703b20 100755 (executable)
--- a/configure
+++ b/configure
@@ -1181,6 +1181,36 @@ if compile_prog "" "" "setvbuf"; then
 fi
 echo "setvbuf                       $setvbuf"
 
+##########################################
+# Check if we support stckf on s390
+s390_z196_facilities="no"
+cat > $TMPC << EOF
+#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
+int main(int argc, char **argv)
+{
+    /* We want just 1 double word to be returned.  */
+    register unsigned long reg0 asm("0") = 0;
+    unsigned long stfle_bits;
+    asm volatile(".machine push"        "\n\t"
+                 ".machine \"z9-109\""  "\n\t"
+                 "stfle %0"             "\n\t"
+                 ".machine pop"         "\n"
+                 : "=QS" (stfle_bits), "+d" (reg0)
+                 : : "cc");
+
+    if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
+      return 0;
+    else
+      return -1;
+}
+EOF
+if compile_prog "" "" "s390_z196_facilities"; then
+  $TMPE
+  if [[ $? -eq 0 ]]; then
+       s390_z196_facilities="yes"
+  fi
+fi
+echo "s390_z196_facilities          $s390_z196_facilities"
 #############################################################################
 
 if test "$wordsize" = "64" ; then
@@ -1311,6 +1341,10 @@ fi
 if test "$setvbuf" = "yes" ; then
   output_sym "CONFIG_SETVBUF"
 fi
+if test "$s390_z196_facilities" = "yes" ; then
+  output_sym "CONFIG_S390_Z196_FACILITIES"
+  CFLAGS="$CFLAGS -march=z9-109"
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "CFLAGS+=$CFLAGS" >> $config_host_mak