All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/15] Make return value type of fio_getaffinity() consistent
@ 2016-07-27 13:37 Tomohiro Kusumi
  2016-07-27 13:37 ` [PATCH 02/15] Fix typos in log_err() message Tomohiro Kusumi
                   ` (14 more replies)
  0 siblings, 15 replies; 19+ messages in thread
From: Tomohiro Kusumi @ 2016-07-27 13:37 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

Return type of fio_getaffinity() isn't consistent among supported OS.
Windows and DragonFlyBSD return void while FreeBSD version is int.
The default version for those that don't support is do{}while(0).

Linux version is a macro for sched_getaffinity(2) which returns 0
on success and -1 otherwise, so others should basically follow that.

Note that I haven't compiled this on Windows, but it shouldn't fail.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
---
 os/os-dragonfly.h | 10 ++++++----
 os/os-windows.h   |  5 ++++-
 os/os.h           |  6 +++++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h
index 187330b..d4a9579 100644
--- a/os/os-dragonfly.h
+++ b/os/os-dragonfly.h
@@ -70,8 +70,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
@@ -145,12 +144,15 @@ 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 */
diff --git a/os/os-windows.h b/os/os-windows.h
index d049531..616ad43 100644
--- a/os/os-windows.h
+++ b/os/os-windows.h
@@ -193,7 +193,7 @@ static inline int fio_setaffinity(int pid, os_cpu_mask_t cpumask)
 	return (bSuccess)? 0 : -1;
 }
 
-static inline void fio_getaffinity(int pid, os_cpu_mask_t *mask)
+static inline int fio_getaffinity(int pid, os_cpu_mask_t *mask)
 {
 	os_cpu_mask_t systemMask;
 
@@ -204,7 +204,10 @@ static inline void fio_getaffinity(int pid, os_cpu_mask_t *mask)
 		CloseHandle(h);
 	} else {
 		log_err("fio_getaffinity failed: failed to get handle for pid %d\n", pid);
+		return -1;
 	}
+
+	return 0;
 }
 
 static inline void fio_cpu_clear(os_cpu_mask_t *mask, int cpu)
diff --git a/os/os.h b/os/os.h
index 9877383..4f267c2 100644
--- a/os/os.h
+++ b/os/os.h
@@ -84,7 +84,6 @@ typedef struct aiocb os_aiocb_t;
 #endif
 
 #ifndef FIO_HAVE_CPU_AFFINITY
-#define fio_getaffinity(pid, mask)	do { } while (0)
 #define fio_cpu_clear(mask, cpu)	do { } while (0)
 typedef unsigned long os_cpu_mask_t;
 
@@ -93,6 +92,11 @@ static inline int fio_setaffinity(int pid, os_cpu_mask_t cpumask)
 	return 0;
 }
 
+static inline int fio_getaffinity(int pid, os_cpu_mask_t *cpumask)
+{
+	return -1;
+}
+
 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
 {
 	return -1;
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-07-27 14:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-27 13:37 [PATCH 01/15] Make return value type of fio_getaffinity() consistent Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 02/15] Fix typos in log_err() message Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 03/15] Use default CPU_COUNT() function in DragonFlyBSD Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 04/15] Add FIO_HAVE_BLKDEV_INVALIDATE_CACHE to selectively support pagecache invalidation Tomohiro Kusumi
2016-07-27 14:25   ` Jens Axboe
2016-07-27 14:44     ` Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 05/15] Use sizeof(char*) instead of sizeof(void*) Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 06/15] Mention default values for readwrite=/ioengine=/mem= in documentation Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 07/15] Mention cpuio never finishes without real I/O " Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 08/15] Ignore exit_io_done= option if no I/O threads are configured Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 09/15] Use correct I/O engine name "cpuio" instead of "cpu" Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 10/15] Add missing --cmdhelp type string for FIO_OPT_UNSUPPORTED Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 11/15] Don't malloc/memcpy ioengine_ops on td initialization Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 12/15] Fix stat(2) related bugs introduced by changes made for Windows Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 13/15] Rename exists_and_not_file() to exists_and_not_regfile() Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 14/15] Add missing archs in fio_arch_strings[] Tomohiro Kusumi
2016-07-27 13:37 ` [PATCH 15/15] Change arch_i386 to arch_x86 Tomohiro Kusumi
2016-07-27 14:30 ` [PATCH 01/15] Make return value type of fio_getaffinity() consistent Jens Axboe
2016-07-27 14:44   ` Tomohiro Kusumi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.