Merge branch 'pthread_getaffinity_1' of https://github.com/kusumi/fio
authorJens Axboe <axboe@kernel.dk>
Sun, 25 Apr 2021 16:23:34 +0000 (10:23 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 25 Apr 2021 16:23:34 +0000 (10:23 -0600)
* 'pthread_getaffinity_1' of https://github.com/kusumi/fio:
  gettime: Fix compilation on non-Linux with pthread_getaffinity_np()

gettime.c
os/os-aix.h
os/os-android.h
os/os-dragonfly.h
os/os-freebsd.h
os/os-hpux.h
os/os-linux.h
os/os-mac.h
os/os-netbsd.h
os/os-openbsd.h
os/os-solaris.h

index e3f483a700130a5fc6d490809b5c78bdd1934cd3..099e9d9f6c879ffadb5d70a757d9910a6696be4e 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -679,7 +679,7 @@ int fio_monotonic_clocktest(int debug)
        unsigned int i;
        os_cpu_mask_t mask;
 
-#ifdef CONFIG_PTHREAD_GETAFFINITY
+#ifdef FIO_HAVE_GET_THREAD_AFFINITY
        fio_get_thread_affinity(mask);
 #else
        memset(&mask, 0, sizeof(mask));
index 1aab96e08d40ad9656eaa41ba1626a348bfa0d52..db99eef4cef6214408277e70d0ba1685961307aa 100644 (file)
 
 #define FIO_USE_GENERIC_SWAP
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 static inline int blockdev_invalidate_cache(struct fio_file *f)
 {
        return ENOTSUP;
index 3c050776249c426a75834e3cb244f3a844cc09aa..3f1aa9d30abec412ffb9c72cfd08aae8ebe9c487 100644 (file)
 #define MAP_HUGETLB 0x40000 /* arch specific */
 #endif
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 #ifndef CONFIG_NO_SHM
 /*
  * Bionic doesn't support SysV shared memeory, so implement it using ashmem
index 44bfcd5d064001722567d8c2011665b612a13d4b..6e46589450eaaf6b318724d61a157813e92f144d 100644 (file)
@@ -92,6 +92,12 @@ typedef cpumask_t os_cpu_mask_t;
 /* No CPU_COUNT(), but use the default function defined in os/os.h */
 #define fio_cpu_count(mask)             CPU_COUNT((mask))
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
 {
        CPUMASK_ASSZERO(*mask);
index b3addf981f98d1d0ac872bde57ae0363f6e8af4c..1b24fa022a3b61ccb17b35e158c227d370fb3c7e 100644 (file)
@@ -37,6 +37,12 @@ typedef cpuset_t os_cpu_mask_t;
 #define fio_cpu_isset(mask, cpu)       (CPU_ISSET((cpu), (mask)) != 0)
 #define fio_cpu_count(mask)            CPU_COUNT((mask))
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
 {
         CPU_ZERO(mask);
index c1dafe42ee55c0bf2317304daa828e138691e312..a80cb2bc474ecee0733ffac7c07662006762318d 100644 (file)
 #define FIO_USE_GENERIC_SWAP
 
 #define FIO_OS_HAVE_AIOCB_TYPEDEF
+
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 typedef struct aiocb64 os_aiocb_t;
 
 static inline int blockdev_invalidate_cache(struct fio_file *f)
index ea8d79221c06454168d39857a994ea2e88e83ba5..f7137abe1b872a9821cfa4ea73dd799627597f5c 100644 (file)
@@ -74,8 +74,11 @@ typedef cpu_set_t os_cpu_mask_t;
        sched_getaffinity((pid), (ptr))
 #endif
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
 #define fio_get_thread_affinity(mask)  \
        pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
 
 #define fio_cpu_clear(mask, cpu)       (void) CPU_CLR((cpu), (mask))
 #define fio_cpu_set(mask, cpu)         (void) CPU_SET((cpu), (mask))
index 683aab3220a54f4125ebe97327be75b2a2b64d86..ec2cc1e555f43c2bc5afce2cc35396ebd7adfc1d 100644 (file)
 #define fio_swap32(x)  OSSwapInt32(x)
 #define fio_swap64(x)  OSSwapInt64(x)
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 #ifndef CONFIG_CLOCKID_T
 typedef unsigned int clockid_t;
 #endif
index abc1d3cb70120b25244ff80e8833e1023f6f602a..624c7fa5096daf40d646886ec38a6058f26061c5 100644 (file)
 #define fio_swap32(x)  bswap32(x)
 #define fio_swap64(x)  bswap64(x)
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
 {
        struct disklabel dl;
index 994bf078c9863a1fb0d28bcb940bd224fd1d4a1c..f1bad67165e982c4da1ecc743887ec8e4bbe056c 100644 (file)
 #define fio_swap32(x)  swap32(x)
 #define fio_swap64(x)  swap64(x)
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
 {
        struct disklabel dl;
index f1966f449d9f4acb6fa7b20c3b376ae6f384fb8c..ea1f081c89e5d24bdc2c6854e29916ccdacc4b1a 100644 (file)
@@ -46,6 +46,12 @@ struct solaris_rand_seed {
 #define os_ctime_r(x, y, z)     ctime_r((x), (y), (z))
 #define FIO_OS_HAS_CTIME_R
 
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask)  \
+       pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
 typedef psetid_t os_cpu_mask_t;
 
 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)