Whamcloud - gitweb
LU-663 kernel: Some arch do not have NUMA features anymore
authorGregoire Pichon <gregoire.pichon@bull.net>
Wed, 7 Sep 2011 14:55:04 +0000 (16:55 +0200)
committerOleg Drokin <green@whamcloud.com>
Sat, 10 Dec 2011 16:57:37 +0000 (11:57 -0500)
Some architectures, especially x86_64, do not have cpu_to_node()
defined as a macro, and node_to_cpumask() exported by the kernel
anymore.

The cpu_to_node() routine is defined either as a macro, as an inline
routine using another exported symbol, or as an exported symbol.
Anyway, the kernel defines this service since at least version
2.6.12.

The node_to_cpumask() routine has been replaced by cpumask_of_node()
for x86 architectures since kernel version 2.6.30.

The set_cpus_allowed() routine is not defined if
CONFIG_CPUMASK_OFFSTACK=y since kernel version 2.6.32.

Signed-off-by: Gregoire Pichon <gregoire.pichon@bull.net>
Change-Id: If81269f403f888d4cde89c6fda5a8d7e10ea70b0
Reviewed-on: http://review.whamcloud.com/1345
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Liang Zhen <liang@whamcloud.com>
libcfs/include/libcfs/linux/linux-prim.h
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/ptlrpc/service.c

index dfe8af2..770c12c 100644 (file)
 #define CFS_NR_CPUS     1
 #endif
 
 #define CFS_NR_CPUS     1
 #endif
 
+#ifdef HAVE_SET_CPUS_ALLOWED
 #define cfs_set_cpus_allowed(t, mask)  set_cpus_allowed(t, mask)
 #define cfs_set_cpus_allowed(t, mask)  set_cpus_allowed(t, mask)
+#else
+#define cfs_set_cpus_allowed(t, mask)  set_cpus_allowed_ptr(t, &(mask))
+#endif
+
 /*
  * cache
  */
 /*
  * cache
  */
index f9f9790..40c6a0f 100644 (file)
@@ -1901,6 +1901,15 @@ AC_DEFUN([LC_EXPORT_ADD_TO_PAGE_CACHE_LRU],
 
 # 2.6.31
 
 
 # 2.6.31
 
+# 2.6.30 x86 node_to_cpumask has been removed. must use cpumask_of_node
+AC_DEFUN([LC_EXPORT_CPUMASK_OF_NODE],
+         [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask_map],
+                                 [arch/$LINUX_ARCH/mm/numa.c],
+                                 [AC_DEFINE(HAVE_CPUMASK_OF_NODE, 1,
+                                            [node_to_cpumask_map is exported by
+                                             the kernel])]) # x86_64
+         ])
+
 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
@@ -2037,6 +2046,19 @@ EXTRA_KCFLAGS="-I$LINUX/fs"
 EXTRA_KCFLAGS=$tmp_flags
 ])
 
 EXTRA_KCFLAGS=$tmp_flags
 ])
 
+# 2.6.32 set_cpus_allowed is no more defined if CONFIG_CPUMASK_OFFSTACK=yes
+AC_DEFUN([LC_SET_CPUS_ALLOWED],
+         [AC_MSG_CHECKING([if kernel defines set_cpus_allowed])
+          LB_LINUX_TRY_COMPILE(
+                [#include <linux/sched.h>],
+                [struct task_struct *p = NULL;
+                 cpumask_t mask = { { 0 } };
+                 (void) set_cpus_allowed(p, mask);],
+                [AC_MSG_RESULT([yes])
+                 AC_DEFINE(HAVE_SET_CPUS_ALLOWED, 1,
+                           [set_cpus_allowed is exported by the kernel])],
+                [AC_MSG_RESULT([no])] )])
+
 #
 # LC_D_OBTAIN_ALIAS
 # starting from 2.6.28 kernel replaces d_alloc_anon() with
 #
 # LC_D_OBTAIN_ALIAS
 # starting from 2.6.28 kernel replaces d_alloc_anon() with
@@ -2229,6 +2251,9 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_SB_HAS_QUOTA_ACTIVE
          LC_EXPORT_ADD_TO_PAGE_CACHE_LRU
 
          LC_SB_HAS_QUOTA_ACTIVE
          LC_EXPORT_ADD_TO_PAGE_CACHE_LRU
 
+         # 2.6.30
+         LC_EXPORT_CPUMASK_OF_NODE
+
          # 2.6.31
          LC_BLK_QUEUE_LOG_BLK_SIZE
 
          # 2.6.31
          LC_BLK_QUEUE_LOG_BLK_SIZE
 
@@ -2238,6 +2263,7 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_SB_BDI
          LC_BLK_QUEUE_MAX_SECTORS
          LC_BLK_QUEUE_MAX_SEGMENTS
          LC_SB_BDI
          LC_BLK_QUEUE_MAX_SECTORS
          LC_BLK_QUEUE_MAX_SEGMENTS
+         LC_SET_CPUS_ALLOWED
 
          # 2.6.38
          LC_BLKDEV_GET_BY_DEV
 
          # 2.6.38
          LC_BLKDEV_GET_BY_DEV
index 01f5e4f..ecaa8eb 100644 (file)
@@ -692,10 +692,6 @@ static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
 #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
 #endif
 
 #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
 #endif
 
-#ifndef cpu_to_node
-#define cpu_to_node(cpu)         0
-#endif
-
 #ifdef HAVE_BIO_ENDIO_2ARG
 #define cfs_bio_io_error(a,b)   bio_io_error((a))
 #define cfs_bio_endio(a,b,c)    bio_endio((a),(c))
 #ifdef HAVE_BIO_ENDIO_2ARG
 #define cfs_bio_io_error(a,b)   bio_io_error((a))
 #define cfs_bio_endio(a,b,c)    bio_endio((a),(c))
@@ -860,5 +856,10 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
 #define ll_pagevec_lru_add_file(pv)     pagevec_lru_add_file(pv)
 #endif
 
 #define ll_pagevec_lru_add_file(pv)     pagevec_lru_add_file(pv)
 #endif
 
+#if !defined(HAVE_NODE_TO_CPUMASK) && defined(HAVE_CPUMASK_OF_NODE)
+#define node_to_cpumask(i)         (*(cpumask_of_node(i)))
+#define HAVE_NODE_TO_CPUMASK
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
index 2c5d417..b4b036f 100644 (file)
@@ -2291,7 +2291,7 @@ static int ptlrpc_hr_main(void *arg)
                  "ptlrpc_hr_%d", hr_args->thread_index);
 
         cfs_daemonize_ctxt(threadname);
                  "ptlrpc_hr_%d", hr_args->thread_index);
 
         cfs_daemonize_ctxt(threadname);
-#if defined(CONFIG_SMP) && defined(HAVE_NODE_TO_CPUMASK)
+#if defined(CONFIG_NUMA) && defined(HAVE_NODE_TO_CPUMASK)
         cfs_set_cpus_allowed(cfs_current(),
                              node_to_cpumask(cpu_to_node(hr_args->cpu_index)));
 #endif
         cfs_set_cpus_allowed(cfs_current(),
                              node_to_cpumask(cpu_to_node(hr_args->cpu_index)));
 #endif