Move Linux/ppc64 specific cpu_online() to os/os-linux.h
authorTomohiro Kusumi <tkusumi@tuxera.com>
Tue, 23 May 2017 18:44:49 +0000 (21:44 +0300)
committerJens Axboe <axboe@fb.com>
Wed, 24 May 2017 02:02:42 +0000 (20:02 -0600)
cpu_online() implementation for ppc64 added to os/os.h by c5dd5d97
(powerpc: fix cpus_online() to get correct max CPU number for powerpc64)
seems Linux specific, thus it should be moved to os/os-linux.h.

For example, non standard sysconf values _SC_NPROCESSORS_ONLN and
_SC_NPROCESSORS_CONF do the same thing with libc in FreeBSD, whereas
they aren't always the same with glibc. This implies c5dd5d97 is about
Linux, and wouldn't be a general solution that needs to be in os/os.h.

sysconf(3) in FreeBSD
https://github.com/freebsd/freebsd/blob/master/lib/libc/gen/sysconf.c#L588

Another possibility is AIX in addition to Linux, but below website
has an example of both _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF
having the same value under SMT.

Topic: prtconf and sysconf produce different numbers of processors
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014250083
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
os/os-linux.h
os/os.h

index 0e6246ef1d6e5e70166ea55433e5c2f25fc14c83..008ce2d0af1c15e78d0bcf19574f5d0ba0a0df02 100644 (file)
@@ -260,6 +260,14 @@ static inline int arch_cache_line_size(void)
                return atoi(size);
 }
 
+#ifdef __powerpc64__
+#define FIO_HAVE_CPU_ONLINE_SYSCONF
+static inline unsigned int cpus_online(void)
+{
+        return sysconf(_SC_NPROCESSORS_CONF);
+}
+#endif
+
 static inline unsigned long long get_fs_free_size(const char *path)
 {
        unsigned long long ret;
diff --git a/os/os.h b/os/os.h
index 3c96b4d11d56a25b62b3c86cb79137120caa45ab..1d400c8f0e303fc3420a5abc40e4a4c0c9955796 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -324,14 +324,6 @@ static inline unsigned long long get_fs_free_size(const char *path)
 }
 #endif
 
-#ifdef __powerpc64__
-#define FIO_HAVE_CPU_ONLINE_SYSCONF
-static inline unsigned int cpus_online(void)
-{
-        return sysconf(_SC_NPROCESSORS_CONF);
-}
-#endif
-
 #ifndef FIO_HAVE_CPU_ONLINE_SYSCONF
 static inline unsigned int cpus_online(void)
 {