linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: anna.schumaker@netapp.com
Cc: linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH v2 11/21] xprtrdma: Simplify rpcrdma_mr_pop
Date: Mon, 19 Aug 2019 18:44:04 -0400	[thread overview]
Message-ID: <156625462416.8161.10214523289584503091.stgit@seurat29.1015granger.net> (raw)
In-Reply-To: <156625401091.8161.14744201497689200191.stgit@seurat29.1015granger.net>

Clean up: rpcrdma_mr_pop call sites check if the list is empty
first. Let's replace the list_empty with less costly logic.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 net/sunrpc/xprtrdma/frwr_ops.c  |   12 ++++--------
 net/sunrpc/xprtrdma/rpc_rdma.c  |    7 +------
 net/sunrpc/xprtrdma/verbs.c     |    6 ++----
 net/sunrpc/xprtrdma/xprt_rdma.h |    7 ++++---
 4 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
index 3a10bfff2125..d7e763fafa04 100644
--- a/net/sunrpc/xprtrdma/frwr_ops.c
+++ b/net/sunrpc/xprtrdma/frwr_ops.c
@@ -126,12 +126,10 @@ frwr_mr_recycle_worker(struct work_struct *work)
  */
 void frwr_reset(struct rpcrdma_req *req)
 {
-	while (!list_empty(&req->rl_registered)) {
-		struct rpcrdma_mr *mr;
+	struct rpcrdma_mr *mr;
 
-		mr = rpcrdma_mr_pop(&req->rl_registered);
+	while ((mr = rpcrdma_mr_pop(&req->rl_registered)))
 		rpcrdma_mr_unmap_and_put(mr);
-	}
 }
 
 /**
@@ -532,8 +530,7 @@ void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
 	 */
 	frwr = NULL;
 	prev = &first;
-	while (!list_empty(&req->rl_registered)) {
-		mr = rpcrdma_mr_pop(&req->rl_registered);
+	while ((mr = rpcrdma_mr_pop(&req->rl_registered))) {
 
 		trace_xprtrdma_mr_localinv(mr);
 		r_xprt->rx_stats.local_inv_needed++;
@@ -632,8 +629,7 @@ void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
 	 */
 	frwr = NULL;
 	prev = &first;
-	while (!list_empty(&req->rl_registered)) {
-		mr = rpcrdma_mr_pop(&req->rl_registered);
+	while ((mr = rpcrdma_mr_pop(&req->rl_registered))) {
 
 		trace_xprtrdma_mr_localinv(mr);
 		r_xprt->rx_stats.local_inv_needed++;
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index 4345e6912392..0ac096a6348a 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -841,12 +841,7 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
 	 * chunks. Very likely the connection has been replaced,
 	 * so these registrations are invalid and unusable.
 	 */
-	while (unlikely(!list_empty(&req->rl_registered))) {
-		struct rpcrdma_mr *mr;
-
-		mr = rpcrdma_mr_pop(&req->rl_registered);
-		rpcrdma_mr_recycle(mr);
-	}
+	frwr_reset(req);
 
 	/* This implementation supports the following combinations
 	 * of chunk lists in one RPC-over-RDMA Call message:
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index e004873cc4f0..ee6fcf10425b 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1213,13 +1213,11 @@ struct rpcrdma_mr *
 rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt)
 {
 	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
-	struct rpcrdma_mr *mr = NULL;
+	struct rpcrdma_mr *mr;
 
 	spin_lock(&buf->rb_mrlock);
-	if (!list_empty(&buf->rb_mrs))
-		mr = rpcrdma_mr_pop(&buf->rb_mrs);
+	mr = rpcrdma_mr_pop(&buf->rb_mrs);
 	spin_unlock(&buf->rb_mrlock);
-
 	if (!mr)
 		goto out_nomrs;
 	return mr;
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index 5aaa53b8ae12..9663b8ddd733 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -338,7 +338,7 @@ rpcr_to_rdmar(const struct rpc_rqst *rqst)
 static inline void
 rpcrdma_mr_push(struct rpcrdma_mr *mr, struct list_head *list)
 {
-	list_add_tail(&mr->mr_list, list);
+	list_add(&mr->mr_list, list);
 }
 
 static inline struct rpcrdma_mr *
@@ -346,8 +346,9 @@ rpcrdma_mr_pop(struct list_head *list)
 {
 	struct rpcrdma_mr *mr;
 
-	mr = list_first_entry(list, struct rpcrdma_mr, mr_list);
-	list_del_init(&mr->mr_list);
+	mr = list_first_entry_or_null(list, struct rpcrdma_mr, mr_list);
+	if (mr)
+		list_del_init(&mr->mr_list);
 	return mr;
 }
 


  parent reply	other threads:[~2019-08-19 22:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-19 22:35 [PATCH v2 00/21] NFS/RDMA client-side for-5.4 Chuck Lever
2019-08-19 22:36 ` [PATCH v2 01/21] SUNRPC: Remove rpc_wake_up_queued_task_on_wq() Chuck Lever
2019-08-19 22:37 ` [PATCH v2 02/21] SUNRPC: Inline xdr_commit_encode Chuck Lever
2019-08-19 22:37 ` [PATCH v2 03/21] xprtrdma: Refresh the documenting comment in frwr_ops.c Chuck Lever
2019-08-19 22:38 ` [PATCH v2 04/21] xprtrdma: Update obsolete comment Chuck Lever
2019-08-19 22:39 ` [PATCH v2 05/21] xprtrdma: Fix calculation of ri_max_segs again Chuck Lever
2019-08-19 22:40 ` [PATCH v2 06/21] xprtrdma: Boost maximum transport header size Chuck Lever
2019-08-19 22:40 ` [PATCH v2 07/21] xprtrdma: Boost client's max slot table size to match Linux server Chuck Lever
2019-08-19 22:41 ` [PATCH v2 08/21] xprtrdma: Rename CQE field in Receive trace points Chuck Lever
2019-08-19 22:42 ` [PATCH v2 09/21] xprtrdma: Rename rpcrdma_buffer::rb_all Chuck Lever
2019-08-19 22:43 ` [PATCH v2 10/21] xprtrdma: Toggle XPRT_CONGESTED in xprtrdma's slot methods Chuck Lever
2019-08-19 22:44 ` Chuck Lever [this message]
2019-08-19 22:44 ` [PATCH v2 12/21] xprtrdma: Combine rpcrdma_mr_put and rpcrdma_mr_unmap_and_put Chuck Lever
2019-08-19 22:45 ` [PATCH v2 13/21] xprtrdma: Move rpcrdma_mr_get out of frwr_map Chuck Lever
2019-08-19 22:46 ` [PATCH v2 14/21] xprtrdma: Ensure creating an MR does not trigger FS writeback Chuck Lever
2019-08-19 22:47 ` [PATCH v2 15/21] xprtrdma: Cache free MRs in each rpcrdma_req Chuck Lever
2019-08-19 22:47 ` [PATCH v2 16/21] xprtrdma: Remove rpcrdma_buffer::rb_mrlock Chuck Lever
2019-08-19 22:48 ` [PATCH v2 17/21] xprtrdma: Use an llist to manage free rpcrdma_reps Chuck Lever
2019-08-19 22:49 ` [PATCH v2 18/21] xprtrdma: Clean up xprt_rdma_set_connect_timeout() Chuck Lever
2019-08-19 22:50 ` [PATCH v2 19/21] xprtrdma: Fix bc_max_slots return value Chuck Lever
2019-08-19 22:51 ` [PATCH v2 20/21] xprtrdma: Inline XDR chunk encoder functions Chuck Lever
2019-08-19 22:51 ` [PATCH v2 21/21] xprtrdma: Optimize rpcrdma_post_recvs() Chuck Lever
2019-08-22 20:18 ` [PATCH v2 00/21] NFS/RDMA client-side for-5.4 Schumaker, Anna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156625462416.8161.10214523289584503091.stgit@seurat29.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=anna.schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).