From: Gregoire Pichon Date: Wed, 7 Sep 2011 14:55:04 +0000 (+0200) Subject: LU-663 kernel: Some arch do not have NUMA features anymore X-Git-Tag: 2.1.53~44 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=49b74e8ab7c0bf76a4ff5b0b2cce15314b1ca8f8;hp=f12b088ace79fa518bdfc8bdb9b462b8165d715e;ds=sidebyside LU-663 kernel: Some arch do not have NUMA features anymore 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 Change-Id: If81269f403f888d4cde89c6fda5a8d7e10ea70b0 Reviewed-on: http://review.whamcloud.com/1345 Reviewed-by: Bobi Jam Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Liang Zhen --- diff --git a/libcfs/include/libcfs/linux/linux-prim.h b/libcfs/include/libcfs/linux/linux-prim.h index dfe8af2..770c12c 100644 --- a/libcfs/include/libcfs/linux/linux-prim.h +++ b/libcfs/include/libcfs/linux/linux-prim.h @@ -96,7 +96,12 @@ #define CFS_NR_CPUS 1 #endif +#ifdef HAVE_SET_CPUS_ALLOWED #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 */ diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f9f9790..40c6a0f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1901,6 +1901,15 @@ AC_DEFUN([LC_EXPORT_ADD_TO_PAGE_CACHE_LRU], # 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]) @@ -2037,6 +2046,19 @@ EXTRA_KCFLAGS="-I$LINUX/fs" 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 ], + [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 @@ -2229,6 +2251,9 @@ AC_DEFUN([LC_PROG_LINUX], 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 @@ -2238,6 +2263,7 @@ AC_DEFUN([LC_PROG_LINUX], 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 diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 01f5e4f..ecaa8eb 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -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 -#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)) @@ -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 +#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 */ diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 2c5d417..b4b036f 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -2291,7 +2291,7 @@ static int ptlrpc_hr_main(void *arg) "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