configure: add SCHED_IDLE check
authorJens Axboe <axboe@kernel.dk>
Wed, 30 Jan 2013 12:58:58 +0000 (13:58 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 Jan 2013 12:58:58 +0000 (13:58 +0100)
We can't consider it always available on Linux. It fails on
Debian 6.x, for instance.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure
idletime.c
os/os-linux.h
os/os-windows.h

index 583e3ab286b0cc9088d221ff3fc49630699e5bd5..995b5df231e9129b9dceace6b867c7fb717c63be 100755 (executable)
--- a/configure
+++ b/configure
@@ -200,6 +200,7 @@ CYGWIN*)
   output_sym "CONFIG_FDATASYNC"
   output_sym "CONFIG_GETTIMEOFDAY"
   output_sym "CONFIG_CLOCK_GETTIME"
+  output_sym "CONFIG_SCHED_IDLE"
   echo "CC=$CC" >> $config_host_mak
   echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
   exit 0
@@ -844,6 +845,22 @@ if compile_prog "" "" "RUSAGE_THREAD"; then
 fi
 echo "RUSAGE_THREAD                 $rusage_thread"
 
+##########################################
+# Check whether we have SCHED_IDLE
+sched_idle="no"
+cat > $TMPC << EOF
+#include <sched.h>
+int main(int argc, char **argv)
+{
+  struct sched_param p;
+  return sched_setscheduler(0, SCHED_IDLE, &p);
+}
+EOF
+if compile_prog "" "" "SCHED_IDLE"; then
+  sched_idle="yes"
+fi
+echo "SCHED_IDLE                    $sched_idle"
+
 #############################################################################
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
@@ -947,6 +964,9 @@ fi
 if test "$rusage_thread" = "yes" ; then
   output_sym "CONFIG_RUSAGE_THREAD"
 fi
+if test "$sched_idle" = "yes" ; then
+  output_sym "CONFIG_SCHED_IDLE"
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
index 6100134f69820992b9ba708cdedce325198e078b..fb6f9ddcb13350815ead74fc895901151be534c0 100644 (file)
@@ -74,7 +74,7 @@ static void *idle_prof_thread_fn(void *data)
        ipt->cali_time = calibrate_unit(ipt->data);
 
        /* delay to set IDLE class till now for better calibration accuracy */
-#if defined(FIO_HAVE_SCHED_IDLE)
+#if defined(CONFIG_SCHED_IDLE)
        if ((retval = fio_set_sched_idle()))
                log_err("fio: fio_set_sched_idle failed\n");
 #else
@@ -385,7 +385,7 @@ int fio_idle_prof_parse_opt(const char *args)
                return -1;
        }       
 
-#if defined(FIO_HAVE_CPU_AFFINITY) && defined(FIO_HAVE_SCHED_IDLE)
+#if defined(FIO_HAVE_CPU_AFFINITY) && defined(CONFIG_SCHED_IDLE)
        if (strcmp("calibrate", args) == 0) {
                ipc.opt = IDLE_PROF_OPT_CALI;
                fio_idle_prof_init();
index acc5a202aa80fc611bb11ed0bfa7421eaeaece6b..c45f071760affff6e435b18b3ce6cf4e33d51187 100644 (file)
@@ -35,7 +35,6 @@
 #define FIO_HAVE_TRIM
 #define FIO_HAVE_BINJECT
 #define FIO_HAVE_GETTID
-#define FIO_HAVE_SCHED_IDLE
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 
 #ifdef MAP_HUGETLB
@@ -247,10 +246,12 @@ static inline int os_trim(int fd, unsigned long long start,
        return errno;
 }
 
+#ifdef CONFIG_SCHED_IDLE
 static inline int fio_set_sched_idle(void)
 {
        struct sched_param p = { .sched_priority = 0, };
        return sched_setscheduler(gettid(), SCHED_IDLE, &p);
 }
+#endif
 
 #endif
index 2d57891f411bdab6debcbe587ffd0813d1a7df5d..98f9030530ef23db3536d67ae38f4f6abcedeebd 100644 (file)
@@ -21,7 +21,6 @@
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_GETTID
-#define FIO_HAVE_SCHED_IDLE
 #define FIO_USE_GENERIC_RAND
 
 #define FIO_PREFERRED_ENGINE           "windowsaio"