Whamcloud - gitweb
LU-8703 libcfs: change CPT estimate algorithm
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-cpu.c
index d351eaa..59e9986 100644 (file)
@@ -777,33 +777,14 @@ out:
 
 static int cfs_cpt_num_estimate(void)
 {
-       int nnode = num_online_nodes();
+       int nthr = cpumask_weight(topology_sibling_cpumask(smp_processor_id()));
        int ncpu  = num_online_cpus();
-       int ncpt;
+       int ncpt = 1;
 
-       if (ncpu <= CPT_WEIGHT_MIN) {
-               ncpt = 1;
-               goto out;
-       }
-
-       /* generate reasonable number of CPU partitions based on total number
-        * of CPUs, Preferred N should be power2 and match this condition:
-        * 2 * (N - 1)^2 < NCPUS <= 2 * N^2 */
-       for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1)
-               ;
-
-       if (ncpt <= nnode) { /* fat numa system */
-               while (nnode > ncpt)
-                       nnode >>= 1;
+       if (ncpu > CPT_WEIGHT_MIN)
+               for (ncpt = 2; ncpu > 2 * nthr * ncpt; ncpt++);
+                       /* nothing */
 
-       } else { /* ncpt > nnode */
-               while ((nnode << 1) <= ncpt)
-                       nnode <<= 1;
-       }
-
-       ncpt = nnode;
-
-out:
 #if (BITS_PER_LONG == 32)
        /* config many CPU partitions on 32-bit system could consume
         * too much memory */