Prepare for support for CPU binding on other platforms
The interface was Linux/glibc centric, since that is what got there first.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/options.c b/options.c
index fd8ec93..8e11227 100644
--- a/options.c
+++ b/options.c
@@ -248,7 +248,7 @@
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++) {
@@ -259,7 +259,7 @@
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 @@
long max_cpu;
int ret = 0;
- CPU_ZERO(&td->o.cpumask);
+ fio_cpuset_init(td);
p = str = strdup(input);
@@ -303,9 +303,9 @@
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"
- " %d CPUs\n", (int) CPU_SETSIZE);
+ " %d CPUs\n", (int) FIO_MAX_CPUS);
ret = 1;
break;
}
@@ -317,7 +317,7 @@
}
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)
diff --git a/os/os-linux.h b/os/os-linux.h
index 6812acd..ea2db9b 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -67,6 +67,10 @@
#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)
{