diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 8cbed312b78233fb5ae1b07da6db1b116fcaafe2..9ab8f6362996b0ba281acaa176805c0148a9af47 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -2543,7 +2543,7 @@ static int mdt_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                 mds_max_threads = mds_min_threads = mds_num_threads;
         } else {
                 /* Base min threads on memory and cpus */
-                mds_min_threads = smp_num_cpus * num_physpages >> 
+                mds_min_threads = num_possible_cpus() * num_physpages >> 
                         (27 - CFS_PAGE_SHIFT);
                 if (mds_min_threads < MDS_THREADS_MIN)
                         mds_min_threads = MDS_THREADS_MIN;
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index cf051b4358035b16da749af24a0920d615cbe555..ddbe3897e772a3b3765b8484211679e08cd3e5d6 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -1777,7 +1777,7 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
                 oss_max_threads = oss_min_threads = oss_num_threads;
         } else {
                 /* Base min threads on memory and cpus */
-                oss_min_threads = smp_num_cpus * num_physpages >> 
+                oss_min_threads = num_possible_cpus() * num_physpages >> 
                         (27 - CFS_PAGE_SHIFT);
                 if (oss_min_threads < OSS_THREADS_MIN)
                         oss_min_threads = OSS_THREADS_MIN;
diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c
index feb542b8a8ad80cf8d4f3e7e935d95e982be9459..2f3b02f1a319be95bb458d4d38706665e466cddd 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -979,7 +979,7 @@ static int ptlrpc_main(void *arg)
         if (svc->srv_cpu_affinity) {
                 int cpu, num_cpu;
 
-                for (cpu = 0, num_cpu = 0; cpu < NR_CPUS; cpu++) {
+                for (cpu = 0, num_cpu = 0; cpu < num_possible_cpus(); cpu++) {
                         if (!cpu_online(cpu))
                                 continue;
                         if (num_cpu == thread->t_id % num_online_cpus())