From 6d459ee7e90393af490a64709aec206d8a585ebd Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 12 Dec 2008 20:02:58 +0100 Subject: [PATCH] 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 --- options.c | 12 ++++++------ os/os-linux.h | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/options.c b/options.c index fd8ec935..8e11227c 100644 --- 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; - 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 @@ static int str_cpumask_cb(void *data, unsigned int *val) 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; - CPU_ZERO(&td->o.cpumask); + fio_cpuset_init(td); 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 (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 @@ static int str_cpus_allowed_cb(void *data, const char *input) } 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 6812acd2..ea2db9b8 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -67,6 +67,10 @@ typedef struct drand48_data os_random_state_t; #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) { -- 2.25.1