From: Andriy Skulysh Date: Thu, 12 Apr 2018 13:12:05 +0000 (+0300) Subject: LU-11004 ptlrpc: Serialize procfs access to scp_hist_reqs using mutex X-Git-Tag: 2.11.53~30 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=413a738a37d7a8cacc41f5843bfe2aef286be62b LU-11004 ptlrpc: Serialize procfs access to scp_hist_reqs using mutex 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 Reviewed-by: Andrew Perepechko Reviewed-by: Alexander Boyko Reviewed-on: https://review.whamcloud.com/32307 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alexandr Boyko Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 3afe692..e8d290b 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -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 */ diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 400ce64..89d256d 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -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; } diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 9625af5..78fa186 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -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);