From d1419c4f019c6dead07f19326a6db20b93e4542b Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Tue, 23 May 2017 21:44:49 +0300 Subject: [PATCH] Move Linux/ppc64 specific cpu_online() to os/os-linux.h 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 Signed-off-by: Jens Axboe --- os/os-linux.h | 8 ++++++++ os/os.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/os/os-linux.h b/os/os-linux.h index 0e6246ef..008ce2d0 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -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 3c96b4d1..1d400c8f 100644 --- 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) { -- 2.25.1