From: Jens Axboe Date: Wed, 30 Jan 2013 12:58:58 +0000 (+0100) Subject: configure: add SCHED_IDLE check X-Git-Tag: fio-2.0.14~60 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=7e09a9f10bb301635b6f9206b3144878a2710b0a configure: add SCHED_IDLE check We can't consider it always available on Linux. It fails on Debian 6.x, for instance. Signed-off-by: Jens Axboe --- diff --git a/configure b/configure index 583e3ab2..995b5df2 100755 --- 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 +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 diff --git a/idletime.c b/idletime.c index 6100134f..fb6f9ddc 100644 --- a/idletime.c +++ b/idletime.c @@ -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(); diff --git a/os/os-linux.h b/os/os-linux.h index acc5a202..c45f0717 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -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 diff --git a/os/os-windows.h b/os/os-windows.h index 2d57891f..98f90305 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -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"