Fix cpumask setting/getting on older kernels
authorJens Axboe <jens.axboe@oracle.com>
Tue, 22 May 2007 07:13:02 +0000 (09:13 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 22 May 2007 07:13:02 +0000 (09:13 +0200)
Don't call into the affinity functions, unless the user has
specified a mask.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c
fio.h
init.c
options.c

diff --git a/fio.c b/fio.c
index 0c297f7..6483e64 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -792,7 +792,7 @@ static void *thread_main(void *data)
        if (init_io_u(td))
                goto err;
 
-       if (fio_setaffinity(td) == -1) {
+       if (td->o.cpumask_set && fio_setaffinity(td) == -1) {
                td_verror(td, errno, "cpu_set_affinity");
                goto err;
        }
diff --git a/fio.h b/fio.h
index 2717f5d..9a43c6f 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -406,6 +406,7 @@ struct thread_options {
        unsigned int new_group;
        unsigned int numjobs;
        os_cpu_mask_t cpumask;
+       unsigned int cpumask_set;
        unsigned int iolog;
        unsigned int rwmixcycle;
        unsigned int rwmix[2];
diff --git a/init.c b/init.c
index 0df30a2..355de88 100644 (file)
--- a/init.c
+++ b/init.c
@@ -655,10 +655,7 @@ static int fill_def_thread(void)
 {
        memset(&def_thread, 0, sizeof(def_thread));
 
-       if (fio_getaffinity(getpid(), &def_thread.o.cpumask) == -1) {
-               perror("sched_getaffinity");
-               return 1;
-       }
+       fio_getaffinity(getpid(), &def_thread.o.cpumask);
 
        /*
         * fill default options
index 54ceaee..e67742d 100644 (file)
--- a/options.c
+++ b/options.c
@@ -117,6 +117,7 @@ static int str_cpumask_cb(void *data, unsigned int *val)
        struct thread_data *td = data;
 
        fill_cpu_mask(td->o.cpumask, *val);
+       td->o.cpumask_set = 1;
        return 0;
 }