diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 8309aa6f7255420148019bf93c1f1bcc79cf4b9f..969b66a923b25db29f399a5ba48efa295d4bd196 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -2547,7 +2547,7 @@ static int mdt_setup(struct obd_device *obd, obd_count len, void *buf)
                 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 14dce9a82326e6b7dbc5d12505e54fb38ac93410..4b5d7e6a51c93995dd13b6ad20a09a8943971ce1 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -1750,7 +1750,7 @@ static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
                 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 6b05e5bc1b317623282b5339cd0828a7a713f335..40bddf16ae094380ce7ba73de23e859e9638f274 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -1271,7 +1271,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())