Whamcloud - gitweb
LU-8710 ptlrpc: use current CPU instead of harcoded 0 05/23305/3
authorDmitry Eremin <dmitry.eremin@intel.com>
Fri, 21 Oct 2016 12:38:46 +0000 (15:38 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Jan 2017 05:22:23 +0000 (05:22 +0000)
fix crash if CPU 0 disabled.

Change-Id: I8ac5a10f544a1c8fc454bc64a6bb1d3607240be9
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: https://review.whamcloud.com/23305
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/ptlrpc/service.c

index e42c307..4b57b9e 100644 (file)
@@ -559,7 +559,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
                 * have too many threads no matter how many cores/HTs
                 * there are.
                 */
                 * 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);
                }
                        /* depress thread factor for hyper-thread */
                        factor = factor - (factor >> 1) + (factor >> 3);
                }
@@ -2585,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;
        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);
        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) {
        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);
        }
                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);
        }
@@ -2910,7 +2912,7 @@ int ptlrpc_hr_init(void)
 
        init_waitqueue_head(&ptlrpc_hr.hr_waitq);
 
 
        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;
 
        cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
                hrp->hrp_cpt = i;