From 04fb94c99160ae1c6dea02624fefd47eb48da810 Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Mon, 14 Aug 2017 10:15:45 +0530 Subject: rpc: Eliminate conn->lock contention by using more granular locks rpc_clnt_submit() acquires conn->lock before call to rpc_transport_submit_request() and subsequent queuing of frame into saved_frames list. However, as part of handling RPC_TRANSPORT_MSG_RECEIVED and RPC_TRANSPORT_MSG_SENT notifications in rpc_clnt_notify(), conn->lock is again used to atomically update conn->last_received and conn->last_sent event timestamps. So when conn->lock is acquired as part of submitting a request, a parallel POLLIN notification gets blocked at rpc layer until the request submission completes and the lock is released. To get around this, this patch call clock_gettime (instead to call gettimeofday) to update event timestamps in conn->last_received and conn->last_sent and to call clock_gettime don't need to call mutex_lock because it (clock_gettime) is thread safe call. Note: Run fio on vm after apply the patch, iops is improved after apply the patch. Change-Id: I347b5031d61c426b276bc5e07136a7172645d763 BUG: 1467614 Signed-off-by: Krutika Dhananjay --- rpc/rpc-lib/src/rpc-clnt-ping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rpc/rpc-lib/src/rpc-clnt-ping.c') diff --git a/rpc/rpc-lib/src/rpc-clnt-ping.c b/rpc/rpc-lib/src/rpc-clnt-ping.c index 2f11341b0d5..40077e7aefd 100644 --- a/rpc/rpc-lib/src/rpc-clnt-ping.c +++ b/rpc/rpc-lib/src/rpc-clnt-ping.c @@ -112,7 +112,7 @@ rpc_clnt_ping_timer_expired (void *rpc_ptr) rpc_clnt_connection_t *conn = NULL; int disconnect = 0; int transport_activity = 0; - struct timeval current = {0, }; + struct timespec current = {0, }; int unref = 0; rpc = (struct rpc_clnt*) rpc_ptr; @@ -129,7 +129,7 @@ rpc_clnt_ping_timer_expired (void *rpc_ptr) { unref = rpc_clnt_remove_ping_timer_locked (rpc); - gettimeofday (¤t, NULL); + clock_gettime (CLOCK_REALTIME, ¤t); if (((current.tv_sec - conn->last_received.tv_sec) < conn->ping_timeout) || ((current.tv_sec - conn->last_sent.tv_sec) < -- cgit