Whamcloud - gitweb
LU-8710 ptlrpc: use current CPU instead of harcoded 0
[fs/lustre-release.git] / lustre / ptlrpc / service.c
index 2de4753..4b57b9e 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2010, 2015, Intel Corporation.
+ * Copyright (c) 2010, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -559,7 +559,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
                 * have too many threads no matter how many cores/HTs
                 * there are.
                 */
-               if (cfs_cpu_ht_nsiblings(0) > 1) { /* weight is # of HTs */
+               if (cfs_cpu_ht_nsiblings(smp_processor_id()) > 1) {
+                       /* weight is # of HTs */
                        /* depress thread factor for hyper-thread */
                        factor = factor - (factor >> 1) + (factor >> 3);
                }
@@ -646,7 +647,9 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
        if (array->paa_reqs_count == NULL)
                goto failed;
 
-       cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt);
+       setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer,
+                   (unsigned long)svcpt);
+
        /* At SOW, service time should be quick; 10s seems generous. If client
         * timeout is less than this, we'll be sending an early reply. */
        at_init(&svcpt->scp_at_estimate, 10, 0);
@@ -1158,7 +1161,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
        __s32 next;
 
        if (array->paa_count == 0) {
-               cfs_timer_disarm(&svcpt->scp_at_timer);
+               del_timer(&svcpt->scp_at_timer);
                return;
        }
 
@@ -1168,7 +1171,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
        if (next <= 0) {
                ptlrpc_at_timer((unsigned long)svcpt);
        } else {
-               cfs_timer_arm(&svcpt->scp_at_timer, cfs_time_shift(next));
+               mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
                CDEBUG(D_INFO, "armed %s at %+ds\n",
                       svcpt->scp_service->srv_name, next);
        }
@@ -2583,16 +2586,17 @@ static int ptlrpc_hr_main(void *arg)
        struct ptlrpc_hr_thread         *hrt = (struct ptlrpc_hr_thread *)arg;
        struct ptlrpc_hr_partition      *hrp = hrt->hrt_partition;
        struct list_head                replies;
-       char                            threadname[20];
        int                             rc;
 
        INIT_LIST_HEAD(&replies);
-       snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d",
-                hrp->hrp_cpt, hrt->hrt_id);
        unshare_fs_struct();
 
        rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
        if (rc != 0) {
+               char threadname[20];
+
+               snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d",
+                        hrp->hrp_cpt, hrt->hrt_id);
                CWARN("Failed to bind %s on CPT %d of CPT table %p: rc = %d\n",
                      threadname, hrp->hrp_cpt, ptlrpc_hr.hr_cpt_table, rc);
        }
@@ -2908,7 +2912,7 @@ int ptlrpc_hr_init(void)
 
        init_waitqueue_head(&ptlrpc_hr.hr_waitq);
 
-       weight = cfs_cpu_ht_nsiblings(0);
+       weight = cfs_cpu_ht_nsiblings(smp_processor_id());
 
        cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
                hrp->hrp_cpt = i;
@@ -2917,9 +2921,11 @@ int ptlrpc_hr_init(void)
                atomic_set(&hrp->hrp_nstopped, 0);
 
                hrp->hrp_nthrs = cfs_cpt_weight(ptlrpc_hr.hr_cpt_table, i);
+
                hrp->hrp_nthrs /= weight;
+               if (hrp->hrp_nthrs == 0)
+                       hrp->hrp_nthrs = 1;
 
-               LASSERT(hrp->hrp_nthrs > 0);
                OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i,
                              hrp->hrp_nthrs * sizeof(*hrt));
                if (hrp->hrp_thrs == NULL)
@@ -2993,7 +2999,7 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc)
        /* early disarm AT timer... */
        ptlrpc_service_for_each_part(svcpt, i, svc) {
                if (svcpt->scp_service != NULL)
-                       cfs_timer_disarm(&svcpt->scp_at_timer);
+                       del_timer(&svcpt->scp_at_timer);
        }
 }
 
@@ -3134,7 +3140,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc)
                        break;
 
                /* In case somebody rearmed this in the meantime */
-               cfs_timer_disarm(&svcpt->scp_at_timer);
+               del_timer(&svcpt->scp_at_timer);
                array = &svcpt->scp_at_array;
 
                if (array->paa_reqs_array != NULL) {