From: Peng Tao Date: Tue, 30 Oct 2012 09:15:02 +0000 (+0800) Subject: LU-1756 kernel: cleanup lustre_compat25.h X-Git-Tag: 2.3.59~50 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=64e7bea80a303488e0e851970f27bd5b884100f2 LU-1756 kernel: cleanup lustre_compat25.h Use cpumask_of_node() rather than node_to_cpumask(). cpumask_of_node() is availabe in latest kernel, while node_to_cpumask() isn't. Also fix how cpumask_of_node() is detected. Some OFED backports cpumask_of_node() and put it in private include/linux/cpumask.h. Signed-off-by: Peng Tao Change-Id: I770fcb549c354c2c925c821d2a8920d867274d7a Reviewed-on: http://review.whamcloud.com/4588 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Yang Sheng --- diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 389e4de..04f61a6 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -214,6 +214,21 @@ LB_LINUX_TRY_COMPILE([ AC_MSG_RESULT(no) ]) + AC_MSG_CHECKING([whether OFED backports have cpumask_of_node]) + # Some OFED has cpumask_of_node backports defined in + # its private include/linux/cpumask.h. However, it is + # defined conflictingly with kernel's cpumask_of_node. + if test -f $OFED_BACKPORT_PATH/linux/cpumask.h; then + grep -q cpumask_of_node $OFED_BACKPORT_PATH/linux/cpumask.h 2>/dev/null + rc=$? + if test $rc -eq 0; then + AC_DEFINE(HAVE_OFED_CPUMASK_OF_NODE, 1, [have cpumask_of_node]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + fi + AC_MSG_CHECKING([whether have cpumask_of_node]) LB_LINUX_TRY_COMPILE([ #include @@ -226,6 +241,18 @@ LB_LINUX_TRY_COMPILE([ AC_MSG_RESULT(no) ]) + AC_MSG_CHECKING([whether have cpumask_copy]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + cpumask_copy(NULL, NULL); + ],[ + AC_DEFINE(HAVE_CPUMASK_COPY, 1, [have cpumask_copy]) + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING([whether have node_to_cpumask]) LB_LINUX_TRY_COMPILE([ #include diff --git a/libcfs/libcfs/linux/linux-cpu.c b/libcfs/libcfs/linux/linux-cpu.c index 720aedc..4cb06d3 100644 --- a/libcfs/libcfs/linux/linux-cpu.c +++ b/libcfs/libcfs/linux/linux-cpu.c @@ -79,7 +79,7 @@ static struct cfs_cpt_data cpt_data; void cfs_cpu_core_siblings(int cpu, cpumask_t *mask) { -#if defined(HAVE_TOPOLOGY_CORE_CPUMASK) +#if defined(HAVE_TOPOLOGY_CORE_CPUMASK) && defined(HAVE_CPUMASK_COPY) /* return cpumask of cores in the same socket */ cpumask_copy(mask, topology_core_cpumask(cpu)); #elif defined(HAVE_TOPOLOGY_CORE_SIBLINGS) @@ -112,7 +112,7 @@ EXPORT_SYMBOL(cfs_cpu_core_nsiblings); void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) { -#if defined(HAVE_TOPOLOGY_THREAD_CPUMASK) +#if defined(HAVE_TOPOLOGY_THREAD_CPUMASK) && defined(HAVE_CPUMASK_COPY) cpumask_copy(mask, topology_thread_cpumask(cpu)); #elif defined(HAVE_TOPOLOGY_THREAD_SIBLINGS) *mask = topology_thread_siblings(cpu); @@ -143,7 +143,7 @@ EXPORT_SYMBOL(cfs_cpu_ht_nsiblings); void cfs_node_to_cpumask(int node, cpumask_t *mask) { -#if defined(HAVE_CPUMASK_OF_NODE) +#if defined(HAVE_CPUMASK_OF_NODE) && defined(HAVE_CPUMASK_COPY) cpumask_copy(mask, cpumask_of_node(node)); #elif defined(HAVE_NODE_TO_CPUMASK) *mask = node_to_cpumask(node); diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 593b3ac..cc26fdb 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -645,9 +645,12 @@ 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 +#if !defined(HAVE_CPUMASK_OF_NODE) && defined(HAVE_NODE_TO_CPUMASK) +# ifdef HAVE_OFED_CPUMASK_OF_NODE +# undef cpumask_of_node +# define HAVE_CPUMASK_OF_NODE +# endif +#define cpumask_of_node(i) (&node_to_cpumask(i)) #endif #ifndef QUOTA_OK diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c index c93a8df..8a842cb 100644 --- a/lustre/ptlrpc/ptlrpcd.c +++ b/lustre/ptlrpc/ptlrpcd.c @@ -410,20 +410,21 @@ static int ptlrpcd(void *arg) int rc, exit = 0; ENTRY; - cfs_daemonize_ctxt(pc->pc_name); -#if defined(CONFIG_SMP) && defined(HAVE_NODE_TO_CPUMASK) + cfs_daemonize_ctxt(pc->pc_name); +#if defined(CONFIG_SMP) && \ +(defined(HAVE_CPUMASK_OF_NODE) || defined(HAVE_NODE_TO_CPUMASK)) if (test_bit(LIOD_BIND, &pc->pc_flags)) { - int index = pc->pc_index; + int index = pc->pc_index; if (index >= 0 && index < cfs_num_possible_cpus()) { - while (!cpu_online(index)) { - if (++index >= cfs_num_possible_cpus()) - index = 0; - } - cfs_set_cpus_allowed(cfs_current(), - node_to_cpumask(cpu_to_node(index))); - } - } + while (!cpu_online(index)) { + if (++index >= cfs_num_possible_cpus()) + index = 0; + } + cfs_set_cpus_allowed(cfs_current(), + *cpumask_of_node(cpu_to_node(index))); + } + } #endif /* * XXX So far only "client" ptlrpcd uses an environment. In @@ -526,14 +527,13 @@ static int ptlrpcd(void *arg) # endif static int ptlrpcd_bind(int index, int max) { - struct ptlrpcd_ctl *pc; - int rc = 0; -#if defined(CONFIG_NUMA) && defined(HAVE_NODE_TO_CPUMASK) - struct ptlrpcd_ctl *ppc; - int node, i, pidx; - cpumask_t mask; + struct ptlrpcd_ctl *pc; + int rc = 0; +#if defined(CONFIG_NUMA) && \ +(defined(HAVE_CPUMASK_OF_NODE) || defined(HAVE_NODE_TO_CPUMASK)) + cpumask_t mask; #endif - ENTRY; + ENTRY; LASSERT(index <= max - 1); pc = &ptlrpcds->pd_threads[index]; @@ -549,14 +549,17 @@ static int ptlrpcd_bind(int index, int max) LASSERT(max % 2 == 0); pc->pc_npartners = 1; break; - case PDB_POLICY_NEIGHBOR: -#if defined(CONFIG_NUMA) && defined(HAVE_NODE_TO_CPUMASK) - node = cpu_to_node(index); - mask = node_to_cpumask(node); - for (i = max; i < cfs_num_online_cpus(); i++) - cpu_clear(i, mask); - pc->pc_npartners = cpus_weight(mask) - 1; + case PDB_POLICY_NEIGHBOR: +#if defined(CONFIG_NUMA) && \ +(defined(HAVE_CPUMASK_OF_NODE) || defined(HAVE_NODE_TO_CPUMASK)) + { + int i; + mask = *cpumask_of_node(cpu_to_node(index)); + for (i = max; i < cfs_num_online_cpus(); i++) + cpu_clear(i, mask); + pc->pc_npartners = cpus_weight(mask) - 1; set_bit(LIOD_BIND, &pc->pc_flags); + } #else LASSERT(max >= 3); pc->pc_npartners = 2; @@ -584,23 +587,28 @@ static int ptlrpcd_bind(int index, int max) pc_partners[0] = pc; } break; - case PDB_POLICY_NEIGHBOR: -#if defined(CONFIG_NUMA) && defined(HAVE_NODE_TO_CPUMASK) - /* partners are cores in the same NUMA node. - * setup partnership only with ptlrpcd threads - * that are already initialized - */ - for (pidx = 0, i = 0; i < index; i++) { - if (cpu_isset(i, mask)) { - ppc = &ptlrpcds->pd_threads[i]; - pc->pc_partners[pidx++] = ppc; - ppc->pc_partners[ppc-> - pc_npartners++] = pc; - } - } + case PDB_POLICY_NEIGHBOR: +#if defined(CONFIG_NUMA) && \ +(defined(HAVE_CPUMASK_OF_NODE) || defined(HAVE_NODE_TO_CPUMASK)) + { + struct ptlrpcd_ctl *ppc; + int i, pidx; + /* partners are cores in the same NUMA node. + * setup partnership only with ptlrpcd threads + * that are already initialized + */ + for (pidx = 0, i = 0; i < index; i++) { + if (cpu_isset(i, mask)) { + ppc = &ptlrpcds->pd_threads[i]; + pc->pc_partners[pidx++] = ppc; + ppc->pc_partners[ppc-> + pc_npartners++] = pc; + } + } /* adjust number of partners to the number * of partnership really setup */ pc->pc_npartners = pidx; + } #else if (index & 0x1) set_bit(LIOD_BIND, &pc->pc_flags);