Set affinity before doing buffer and io_u allocs
authorJens Axboe <jaxboe@fusionio.com>
Fri, 8 Jul 2011 17:25:04 +0000 (19:25 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 8 Jul 2011 17:25:04 +0000 (19:25 +0200)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
fio.c

diff --git a/fio.c b/fio.c
index 48c728eb2cb9370f2242ca0a5df0c36cc40e972b..81854818d6bd81ae3cd503a8eb4e4661d99bfc93 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1092,6 +1092,22 @@ static void *thread_main(void *data)
                goto err;
        }
 
+       /*
+        * If we have a gettimeofday() thread, make sure we exclude that
+        * thread from this job
+        */
+       if (td->o.gtod_cpu)
+               fio_cpu_clear(&td->o.cpumask, td->o.gtod_cpu);
+
+       /*
+        * Set affinity first, in case it has an impact on the memory
+        * allocations.
+        */
+       if (td->o.cpumask_set && fio_setaffinity(td->pid, td->o.cpumask) == -1) {
+               td_verror(td, errno, "cpu_set_affinity");
+               goto err;
+       }
+
        /*
         * May alter parameters that init_io_u() will use, so we need to
         * do this first.
@@ -1105,23 +1121,6 @@ static void *thread_main(void *data)
        if (td->o.verify_async && verify_async_init(td))
                goto err;
 
-       if (td->o.cpumask_set && fio_setaffinity(td->pid, td->o.cpumask) == -1) {
-               td_verror(td, errno, "cpu_set_affinity");
-               goto err;
-       }
-
-       /*
-        * If we have a gettimeofday() thread, make sure we exclude that
-        * thread from this job
-        */
-       if (td->o.gtod_cpu) {
-               fio_cpu_clear(&td->o.cpumask, td->o.gtod_cpu);
-               if (fio_setaffinity(td->pid, td->o.cpumask) == -1) {
-                       td_verror(td, errno, "cpu_set_affinity");
-                       goto err;
-               }
-       }
-
        if (td->ioprio_set) {
                if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) {
                        td_verror(td, errno, "ioprio_set");