Whamcloud - gitweb
LU-11004 ptlrpc: Serialize procfs access to scp_hist_reqs using mutex 07/32307/2
authorAndriy Skulysh <c17819@cray.com>
Thu, 12 Apr 2018 13:12:05 +0000 (16:12 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 3 Jul 2018 18:05:14 +0000 (18:05 +0000)
scp_hist_reqs list can be quite long thus a lot of
userland processes can waste CPU power in spinlock cycles.

Change-Id: Ic0fa7338569f9a19213a1dc31f5479c96a76d23a
Cray-bug-id: LUS-5833
Signed-off-by: Andriy Skulysh <c17819@cray.com>
Reviewed-by: Andrew Perepechko <c17827@cray.com>
Reviewed-by: Alexander Boyko <c17825@cray.com>
Reviewed-on: https://review.whamcloud.com/32307
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_net.h
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/service.c

index 3afe692..e8d290b 100644 (file)
@@ -1773,6 +1773,8 @@ struct ptlrpc_service_part {
         * threads starting & stopping are also protected by this lock.
         */
        spinlock_t                      scp_lock  __cfs_cacheline_aligned;
+       /** userland serialization */
+       struct mutex                    scp_mutex;
        /** total # req buffer descs allocated */
        int                             scp_nrqbds_total;
        /** # posted request buffers for receiving */
index 400ce64..89d256d 100644 (file)
@@ -910,10 +910,12 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
                if (i > cpt) /* make up the lowest position for this CPT */
                        *pos = PTLRPC_REQ_CPT2POS(svc, i);
 
+               mutex_lock(&svcpt->scp_mutex);
                spin_lock(&svcpt->scp_lock);
                rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi,
                                PTLRPC_REQ_POS2SEQ(svc, *pos));
                spin_unlock(&svcpt->scp_lock);
+               mutex_unlock(&svcpt->scp_mutex);
                if (rc == 0) {
                        *pos = PTLRPC_REQ_SEQ2POS(svc, srhi->srhi_seq);
                        srhi->srhi_idx = i;
@@ -955,9 +957,11 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
                        seq = srhi->srhi_seq + (1 << svc->srv_cpt_bits);
                }
 
+               mutex_lock(&svcpt->scp_mutex);
                spin_lock(&svcpt->scp_lock);
                rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, seq);
                spin_unlock(&svcpt->scp_lock);
+               mutex_unlock(&svcpt->scp_mutex);
                if (rc == 0) {
                        *pos = PTLRPC_REQ_SEQ2POS(svc, srhi->srhi_seq);
                        srhi->srhi_idx = i;
@@ -1011,6 +1015,7 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
 
        svcpt = svc->srv_parts[srhi->srhi_idx];
 
+       mutex_lock(&svcpt->scp_mutex);
        spin_lock(&svcpt->scp_lock);
 
        rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, srhi->srhi_seq);
@@ -1051,6 +1056,8 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
        }
 
        spin_unlock(&svcpt->scp_lock);
+       mutex_unlock(&svcpt->scp_mutex);
+
        return rc;
 }
 
index 9625af5..78fa186 100644 (file)
@@ -605,6 +605,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
 
        /* rqbd and incoming request queue */
        spin_lock_init(&svcpt->scp_lock);
+       mutex_init(&svcpt->scp_mutex);
        INIT_LIST_HEAD(&svcpt->scp_rqbd_idle);
        INIT_LIST_HEAD(&svcpt->scp_rqbd_posted);
        INIT_LIST_HEAD(&svcpt->scp_req_incoming);