powerpc: fix cpus_online() to get correct max CPU number for powerpc64
authorDan Qing Zhang <dqzhang@linux.vnet.ibm.com>
Mon, 25 Jan 2016 13:04:18 +0000 (13:04 +0000)
committerJens Axboe <axboe@fb.com>
Mon, 25 Jan 2016 15:29:50 +0000 (08:29 -0700)
This patch tries to fix cpus_online() for powerpc64 when running fio
by using parameter "cpus_allowed", in order to obtain correct max CPU
number on powerpc64 architecture.

When changing SMT settings on powerpc architecture, the way of cpu
numbering is changing as well. For example, when SMT=off, CPUs are
numbered like 0,8,16,..., while when SMT=2, CPUs are numbered like
0,1,8,9,.... Therefore, sysconf(_SC_NPROCESSORS_ONLN) is not applied
to get exact max CPU number on powerpc. And the max_cpu value can be
correctly ontained by using sysconf(_SC_NPROCESSORS_CONF).

Signed-off-by: Dan Qing Zhang <dqzhang@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
os/os.h

diff --git a/os/os.h b/os/os.h
index fd47f22a367c5af1e688d59af333dffb796c5e14..02ab40d38a6ca86c3b70552f797a1c6b9b28def7 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -343,6 +343,14 @@ 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)
 {