Prepare for support for CPU binding on other platforms
authorJens Axboe <jens.axboe@oracle.com>
Fri, 12 Dec 2008 19:02:58 +0000 (20:02 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 12 Dec 2008 19:02:58 +0000 (20:02 +0100)
The interface was Linux/glibc centric, since that is what got there first.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
options.c
os/os-linux.h

index fd8ec93516148f829ecd8a98bad7b1285fb8b116..8e11227c6e0ff2917fbb0307fcbabb601286ec53 100644 (file)
--- a/options.c
+++ b/options.c
@@ -248,7 +248,7 @@ static int str_cpumask_cb(void *data, unsigned int *val)
        unsigned int i;
        long max_cpu;
 
        unsigned int i;
        long max_cpu;
 
-       CPU_ZERO(&td->o.cpumask);
+       fio_cpuset_init(td);
        max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
 
        for (i = 0; i < sizeof(int) * 8; i++) {
        max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
 
        for (i = 0; i < sizeof(int) * 8; i++) {
@@ -259,7 +259,7 @@ static int str_cpumask_cb(void *data, unsigned int *val)
                                return 1;
                        }
                        dprint(FD_PARSE, "set cpu allowed %d\n", i);
                                return 1;
                        }
                        dprint(FD_PARSE, "set cpu allowed %d\n", i);
-                       CPU_SET(i, &td->o.cpumask);
+                       fio_cpu_set(&td->o.cpumask, i);
                }
        }
 
                }
        }
 
@@ -274,7 +274,7 @@ static int str_cpus_allowed_cb(void *data, const char *input)
        long max_cpu;
        int ret = 0;
 
        long max_cpu;
        int ret = 0;
 
-       CPU_ZERO(&td->o.cpumask);
+       fio_cpuset_init(td);
 
        p = str = strdup(input);
 
 
        p = str = strdup(input);
 
@@ -303,9 +303,9 @@ static int str_cpus_allowed_cb(void *data, const char *input)
                if (icpu2 == -1)
                        icpu2 = icpu;
                while (icpu <= icpu2) {
                if (icpu2 == -1)
                        icpu2 = icpu;
                while (icpu <= icpu2) {
-                       if (icpu >= CPU_SETSIZE) {
+                       if (icpu >= FIO_MAX_CPUS) {
                                log_err("fio: your OS only supports up to"
                                log_err("fio: your OS only supports up to"
-                                       " %d CPUs\n", (int) CPU_SETSIZE);
+                                       " %d CPUs\n", (int) FIO_MAX_CPUS);
                                ret = 1;
                                break;
                        }
                                ret = 1;
                                break;
                        }
@@ -317,7 +317,7 @@ static int str_cpus_allowed_cb(void *data, const char *input)
                        }
        
                        dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
                        }
        
                        dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
-                       CPU_SET(atoi(cpu), &td->o.cpumask);
+                       fio_cpu_set(&td->o.cpumask, icpu);
                        icpu++;
                }
                if (ret)
                        icpu++;
                }
                if (ret)
index 6812acd25cb56a14a0095818627113a77ec673fd..ea2db9b8023c75eba4cb949d451aafe1bd4d2dab 100644 (file)
@@ -67,6 +67,10 @@ typedef struct drand48_data os_random_state_t;
 #endif
 
 #define fio_cpu_clear(mask, cpu)       CPU_CLR((cpu), (mask))
 #endif
 
 #define fio_cpu_clear(mask, cpu)       CPU_CLR((cpu), (mask))
+#define fio_cpu_set(mask, cpu)         CPU_SET((cpu), (mask))
+#define fio_cpuset_init(td)            CPU_ZERO(&(td)->o.cpumask)
+
+#define FIO_MAX_CPUS                   CPU_SETSIZE
 
 static inline int ioprio_set(int which, int who, int ioprio)
 {
 
 static inline int ioprio_set(int which, int who, int ioprio)
 {