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 0c297f7e4cc450a6984764baed64fcdff14a9726..6483e64c9462eeae4075fa6f449dae7970bb1eeb 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 2717f5ddb80c447b94d8aa9fccbbc44314f1bed4..9a43c6f65edc05c64a5f3e3d6879b7599c068de7 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 0df30a2e06ef796fe84a2169a55884839b5dd622..355de88ffa4db9cdc65e6c3d53103fd4618064c4 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 54ceaeed706cbaa110eff416375cbe5f5beb7393..e67742ddec211043e1bdceadeae9b0ed5f375282 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;
 }