Whamcloud - gitweb
LU-1756 kernel: cleanup lustre_compat25.h
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-cpu.c
index 896fd7d..4cb06d3 100644 (file)
@@ -22,7 +22,7 @@
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -46,9 +46,7 @@
  *  1 : disable multiple partitions
  * >1 : specify number of partitions
  */
-/* NB: we set it to 1 for now, multiple partitions will be enabled after
- * all smp node affinity code landed */
-static int     cpu_npartitions = 1;
+static int     cpu_npartitions;
 CFS_MODULE_PARM(cpu_npartitions, "i", int, 0444, "# of CPU partitions");
 
 /**
@@ -81,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)
@@ -114,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);
@@ -145,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);
@@ -806,9 +804,9 @@ cfs_cpt_table_create(int ncpt)
        if (ncpt <= 0)
                ncpt = rc;
 
-       if (ncpt > rc) {
+       if (ncpt > num_online_cpus() || ncpt > 4 * rc) {
                CWARN("CPU partition number %d is larger than suggested "
-                     "value(%d), your system may have performance"
+                     "value (%d), your system may have performance"
                      "issue or run out of memory while under pressure\n",
                      ncpt, rc);
        }