X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=os%2Fos-dragonfly.h;h=5e94855cac5faef440a72492093944c0ffc0c3fa;hb=92ddd6b6d6c14b366c251daf3bad32c3cf199a1c;hp=57958ca689dc36ea199f935ebaeeea6a6821ab2e;hpb=a306497afd5ae9dfa52d0423073ed73333ded475;p=fio.git diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h index 57958ca6..5e94855c 100644 --- a/os/os-dragonfly.h +++ b/os/os-dragonfly.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "../file.h" @@ -22,6 +23,9 @@ #define FIO_HAVE_CHARDEV_SIZE #define FIO_HAVE_GETTID #define FIO_HAVE_CPU_AFFINITY +#define FIO_HAVE_IOPRIO +/* Only have attach-to-open-removed when kern.ipc.shm_allow_removed is 1 */ +#undef FIO_HAVE_SHM_ATTACH_REMOVED #define OS_MAP_ANON MAP_ANON @@ -68,8 +72,7 @@ typedef cpumask_t os_cpu_mask_t; /* * Define USCHED_GET_CPUMASK as the macro didn't exist until release 4.5. - * usched_set(2) returns EINVAL if the kernel doesn't support it, though - * fio_getaffinity() returns void. + * usched_set(2) returns EINVAL if the kernel doesn't support it. * * Also note usched_set(2) works only for the current thread regardless of * the command type. It doesn't work against another thread regardless of @@ -80,6 +83,9 @@ typedef cpumask_t os_cpu_mask_t; #define USCHED_GET_CPUMASK 5 #endif +/* No CPU_COUNT(), but use the default function defined in os/os.h */ +#define fio_cpu_count(mask) CPU_COUNT((mask)) + static inline int fio_cpuset_init(os_cpu_mask_t *mask) { CPUMASK_ASSZERO(*mask); @@ -109,17 +115,6 @@ static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu) return 0; } -static inline int fio_cpu_count(os_cpu_mask_t *mask) -{ - int i, n = 0; - - for (i = 0; i < FIO_MAX_CPUS; i++) - if (CPUMASK_TESTBIT(*mask, i)) - n++; - - return n; -} - static inline int fio_setaffinity(int pid, os_cpu_mask_t mask) { int i, firstcall = 1; @@ -143,14 +138,33 @@ static inline int fio_setaffinity(int pid, os_cpu_mask_t mask) return 0; } -static inline void fio_getaffinity(int pid, os_cpu_mask_t *mask) +static inline int fio_getaffinity(int pid, os_cpu_mask_t *mask) { /* 0 for the current thread, see BUGS in usched_set(2) */ pid = 0; - usched_set(pid, USCHED_GET_CPUMASK, mask, sizeof(*mask)); + if (usched_set(pid, USCHED_GET_CPUMASK, mask, sizeof(*mask))) + return -1; + + return 0; } +/* fio code is Linux based, so rename macros to Linux style */ +#define IOPRIO_WHO_PROCESS PRIO_PROCESS +#define IOPRIO_WHO_PGRP PRIO_PGRP +#define IOPRIO_WHO_USER PRIO_USER + +#define IOPRIO_MIN_PRIO 1 /* lowest priority */ +#define IOPRIO_MAX_PRIO 10 /* highest priority */ + +/* + * Prototypes declared in sys/sys/resource.h are preventing from defining + * ioprio_set() with 4 arguments, so define fio's ioprio_set() as a macro. + * Note that there is no idea of class within ioprio_set(2) unlike Linux. + */ +#define ioprio_set(which, who, ioprio_class, ioprio) \ + ioprio_set(which, who, ioprio) + static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) { struct partinfo pi;