From: Bruce Cran Date: Thu, 21 Feb 2013 12:39:24 +0000 (+0000) Subject: Add FreeBSD cpu affinity support. X-Git-Tag: fio-2.0.14~2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=638204956e6ef8f79033163667bdda94aaf9e949 Add FreeBSD cpu affinity support. Since FreeBSD has different thread and process IDs, assume that fio_setaffinity will always be called with a tid and fio_getaffinity with a pid. Signed-off-by: Jens Axboe --- diff --git a/os/os-freebsd.h b/os/os-freebsd.h index c55a7c31..57ce409c 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "../file.h" @@ -16,6 +18,7 @@ #define FIO_USE_GENERIC_INIT_RANDOM_STATE #define FIO_HAVE_CHARDEV_SIZE #define FIO_HAVE_GETTID +#define FIO_HAVE_CPU_AFFINITY #define OS_MAP_ANON MAP_ANON @@ -25,6 +28,34 @@ typedef off_t off64_t; +typedef cpuset_t os_cpu_mask_t; + +#define fio_cpu_clear(mask, cpu) (void) CPU_CLR((cpu), (mask)) +#define fio_cpu_set(mask, cpu) (void) CPU_SET((cpu), (mask)) + +static inline int fio_cpuset_init(os_cpu_mask_t *mask) +{ + CPU_ZERO(mask); + return 0; +} + +static inline int fio_cpuset_exit(os_cpu_mask_t *mask) +{ + return 0; +} + +static inline int fio_setaffinity(int pid, os_cpu_mask_t cpumask) +{ + return cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, pid, sizeof(cpumask), &cpumask); +} + +static inline int fio_getaffinity(int pid, os_cpu_mask_t *cpumask) +{ + return cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid, sizeof(cpumask), cpumask); +} + +#define FIO_MAX_CPUS CPU_SETSIZE + static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) { off_t size;