All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v1 12/16] xprtrdma: Acquire FMRs in rpcrdma_fmr_register_external()
Date: Mon, 16 Mar 2015 10:03:34 -0700	[thread overview]
Message-ID: <B60B5333-7A78-4A11-8070-C1AC7C9E3F7A@oracle.com> (raw)
In-Reply-To: <5506CC6C.8090106-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>


On Mar 16, 2015, at 5:28 AM, Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org> wrote:

> On 3/13/2015 11:28 PM, Chuck Lever wrote:
>> Acquiring 64 FMRs in rpcrdma_buffer_get() while holding the buffer
>> pool lock is expensive, and unnecessary because FMR mode can
>> transfer up to a 1MB payload using just a single ib_fmr.
>> 
>> Instead, acquire ib_fmrs one-at-a-time as chunks are registered, and
>> return them to rb_mws immediately during deregistration.
>> 
>> Signed-off-by: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
>> ---
>>  net/sunrpc/xprtrdma/fmr_ops.c   |   41 ++++++++++++++++++++++++++++++++++++---
>>  net/sunrpc/xprtrdma/verbs.c     |   41 ++++++++++++++-------------------------
>>  net/sunrpc/xprtrdma/xprt_rdma.h |    1 +
>>  3 files changed, 54 insertions(+), 29 deletions(-)
>> 
>> diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
>> index 96e6cd3..9c6c2e8 100644
>> --- a/net/sunrpc/xprtrdma/fmr_ops.c
>> +++ b/net/sunrpc/xprtrdma/fmr_ops.c
>> @@ -28,10 +28,11 @@ __fmr_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg)
>>  {
>>  	struct rpcrdma_ia *ia = &r_xprt->rx_ia;
>>  	struct rpcrdma_mr_seg *seg1 = seg;
>> +	struct rpcrdma_mw *mw = seg1->rl_mw;
>>  	int rc, nsegs = seg->mr_nsegs;
>>  	LIST_HEAD(l);
>> 
>> -	list_add(&seg1->rl_mw->r.fmr->list, &l);
>> +	list_add(&mw->r.fmr->list, &l);
>>  	rc = ib_unmap_fmr(&l);
>>  	read_lock(&ia->ri_qplock);
>>  	while (seg1->mr_nsegs--)
>> @@ -39,11 +40,14 @@ __fmr_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg)
>>  	read_unlock(&ia->ri_qplock);
>>  	if (rc)
>>  		goto out_err;
>> +out:
>> +	seg1->rl_mw = NULL;
>> +	rpcrdma_put_mw(r_xprt, mw);
>>  	return nsegs;
>> 
>>  out_err:
>>  	dprintk("RPC:       %s: ib_unmap_fmr status %i\n", __func__, rc);
>> -	return nsegs;
>> +	goto out;
>>  }
>> 
>>  static int
>> @@ -117,6 +121,27 @@ out_fmr_err:
>>  	return rc;
>>  }
>> 
>> +static struct rpcrdma_mw *
>> +__fmr_get_mw(struct rpcrdma_xprt *r_xprt)
> 
> This introduces an asymmetric approach where you have fmr/frwr get_mw
> routines but have a single rpcrdma_put_mw. I noticed that the
> frwr_get_mw (next patch) is almost completely different - but I wander
> if that should really be that different?

FMR doesn’t need to deal with asynchronous LOCAL_INV getting flushed
when the transport disconnects.

I will explain this further in response to 13/16.

> Just raising the question.
> 
>> +{
>> +	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
>> +	struct rpcrdma_mw *mw = NULL;
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&buf->rb_lock, flags);
>> +
>> +	if (!list_empty(&buf->rb_mws)) {
>> +		mw = list_entry(buf->rb_mws.next,
>> +				struct rpcrdma_mw, mw_list);
>> +		list_del_init(&mw->mw_list);
>> +	} else {
>> +		pr_err("RPC:       %s: no MWs available\n", __func__);
>> +	}
>> +
>> +	spin_unlock_irqrestore(&buf->rb_lock, flags);
>> +	return mw;
>> +}
>> +
>>  /* Use the ib_map_phys_fmr() verb to register a memory region
>>   * for remote access via RDMA READ or RDMA WRITE.
>>   */
>> @@ -126,10 +151,18 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
>>  {
>>  	struct rpcrdma_ia *ia = &r_xprt->rx_ia;
>>  	struct rpcrdma_mr_seg *seg1 = seg;
>> -	struct rpcrdma_mw *mw = seg1->rl_mw;
>> +	struct rpcrdma_mw *mw;
>>  	u64 physaddrs[RPCRDMA_MAX_DATA_SEGS];
>>  	int len, pageoff, i, rc;
>> 
>> +	mw = __fmr_get_mw(r_xprt);
>> +	if (!mw)
>> +		return -ENOMEM;
>> +	if (seg1->rl_mw) {
>> +		rpcrdma_put_mw(r_xprt, seg1->rl_mw);
>> +		seg1->rl_mw = NULL;
>> +	}
>> +
> 
> How can this happen? getting to op_map with existing rl_mw? and
> wouldn't it be better to use rl_mw instead of getting a new mw and
> putting seg1->rl_mw?
> 
>>  	pageoff = offset_in_page(seg1->mr_offset);
>>  	seg1->mr_offset -= pageoff;	/* start of page */
>>  	seg1->mr_len += pageoff;
>> @@ -152,6 +185,7 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
>>  	if (rc)
>>  		goto out_maperr;
>> 
>> +	seg1->rl_mw = mw;
>>  	seg1->mr_rkey = mw->r.fmr->rkey;
>>  	seg1->mr_base = seg1->mr_dma + pageoff;
>>  	seg1->mr_nsegs = i;
>> @@ -164,6 +198,7 @@ out_maperr:
>>  		pageoff, i, rc);
>>  	while (i--)
>>  		rpcrdma_unmap_one(ia, --seg);
>> +	rpcrdma_put_mw(r_xprt, mw);
>>  	return rc;
>>  }
>> 
>> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
>> index f108a57..f2316d8 100644
>> --- a/net/sunrpc/xprtrdma/verbs.c
>> +++ b/net/sunrpc/xprtrdma/verbs.c
>> @@ -1171,6 +1171,21 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
>>  	kfree(buf->rb_pool);
>>  }
>> 
>> +void
>> +rpcrdma_put_mw(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mw *mw)
>> +{
>> +	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
>> +	unsigned long flags;
>> +
>> +	if (!list_empty(&mw->mw_list))
>> +		pr_warn("RPC:       %s: mw %p still on a list!\n",
>> +			__func__, mw);
>> +
>> +	spin_lock_irqsave(&buf->rb_lock, flags);
>> +	list_add_tail(&mw->mw_list, &buf->rb_mws);
>> +	spin_unlock_irqrestore(&buf->rb_lock, flags);
>> +}
>> +
>>  /* "*mw" can be NULL when rpcrdma_buffer_get_mrs() fails, leaving
>>   * some req segments uninitialized.
>>   */
>> @@ -1292,28 +1307,6 @@ rpcrdma_buffer_get_frmrs(struct rpcrdma_req *req, struct rpcrdma_buffer *buf,
>>  	return NULL;
>>  }
>> 
>> -static struct rpcrdma_req *
>> -rpcrdma_buffer_get_fmrs(struct rpcrdma_req *req, struct rpcrdma_buffer *buf)
>> -{
>> -	struct rpcrdma_mw *r;
>> -	int i;
>> -
>> -	i = RPCRDMA_MAX_SEGS - 1;
>> -	while (!list_empty(&buf->rb_mws)) {
>> -		r = list_entry(buf->rb_mws.next,
>> -			       struct rpcrdma_mw, mw_list);
>> -		list_del(&r->mw_list);
>> -		req->rl_segments[i].rl_mw = r;
>> -		if (unlikely(i-- == 0))
>> -			return req;	/* Success */
>> -	}
>> -
>> -	/* Not enough entries on rb_mws for this req */
>> -	rpcrdma_buffer_put_sendbuf(req, buf);
>> -	rpcrdma_buffer_put_mrs(req, buf);
>> -	return NULL;
>> -}
>> -
>>  /*
>>   * Get a set of request/reply buffers.
>>   *
>> @@ -1355,9 +1348,6 @@ rpcrdma_buffer_get(struct rpcrdma_buffer *buffers)
>>  	case RPCRDMA_FRMR:
>>  		req = rpcrdma_buffer_get_frmrs(req, buffers, &stale);
>>  		break;
>> -	case RPCRDMA_MTHCAFMR:
>> -		req = rpcrdma_buffer_get_fmrs(req, buffers);
>> -		break;
>>  	default:
>>  		break;
>>  	}
>> @@ -1382,7 +1372,6 @@ rpcrdma_buffer_put(struct rpcrdma_req *req)
>>  	rpcrdma_buffer_put_sendbuf(req, buffers);
>>  	switch (ia->ri_memreg_strategy) {
>>  	case RPCRDMA_FRMR:
>> -	case RPCRDMA_MTHCAFMR:
>>  		rpcrdma_buffer_put_mrs(req, buffers);
>>  		break;
>>  	default:
>> diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
>> index 40a0ee8..d5aa5b4 100644
>> --- a/net/sunrpc/xprtrdma/xprt_rdma.h
>> +++ b/net/sunrpc/xprtrdma/xprt_rdma.h
>> @@ -426,6 +426,7 @@ void rpcrdma_free_regbuf(struct rpcrdma_ia *,
>>  unsigned int rpcrdma_max_segments(struct rpcrdma_xprt *);
>>  void rpcrdma_map_one(struct rpcrdma_ia *, struct rpcrdma_mr_seg *, bool);
>>  void rpcrdma_unmap_one(struct rpcrdma_ia *, struct rpcrdma_mr_seg *);
>> +void rpcrdma_put_mw(struct rpcrdma_xprt *, struct rpcrdma_mw *);
>> 
>>  /*
>>   * RPC/RDMA connection management calls - xprtrdma/rpc_rdma.c
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> 
> 

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-03-16 17:03 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 21:26 [PATCH v1 00/16] NFS/RDMA patches proposed for 4.1 Chuck Lever
     [not found] ` <20150313212517.22783.18364.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-13 21:26   ` [PATCH v1 01/16] xprtrdma: Display IPv6 addresses and port numbers correctly Chuck Lever
     [not found]     ` <20150313212641.22783.93522.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-15  2:50       ` Sagi Grimberg
     [not found]         ` <5504F37A.20803-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 16:34           ` Chuck Lever
2015-03-24  8:27       ` Devesh Sharma
     [not found]         ` <EE7902D3F51F404C82415C4803930ACD5DC3A952-DWYeeINJQrxExQ8dmkPuX0M9+F4ksjoh@public.gmane.org>
2015-03-24 14:43           ` Chuck Lever
2015-03-13 21:26   ` [PATCH v1 02/16] xprtrdma: Perform a full marshal on retransmit Chuck Lever
     [not found]     ` <20150313212650.22783.28071.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-15  3:01       ` Sagi Grimberg
2015-03-13 21:26   ` [PATCH v1 03/16] xprtrdma: Add vector of ops for each memory registration strategy Chuck Lever
     [not found]     ` <20150313212659.22783.28341.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-15  3:04       ` Sagi Grimberg
2015-03-13 21:27   ` [PATCH v1 04/16] xprtrdma: Add a "max_payload" op for each memreg mode Chuck Lever
     [not found]     ` <20150313212708.22783.70403.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:18       ` Sagi Grimberg
2015-03-13 21:27   ` [PATCH v1 05/16] xprtrdma: Add a "register_external" " Chuck Lever
     [not found]     ` <20150313212718.22783.10096.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:28       ` Sagi Grimberg
     [not found]         ` <5506B036.1040905-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 16:48           ` Chuck Lever
     [not found]             ` <982A021D-1B85-4AAF-89A3-302A21CF2B36-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-03-16 18:15               ` Sagi Grimberg
     [not found]                 ` <55071DBB.4050500-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 20:13                   ` Steve Wise
     [not found]                     ` <55073966.30006-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2015-03-16 22:11                       ` Chuck Lever
     [not found]                         ` <7595A8CB-B38B-4F01-A132-CE3BE143A897-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-03-21 11:53                           ` Sagi Grimberg
2015-03-13 21:27   ` [PATCH v1 06/16] xprtrdma: Add a "deregister_external" " Chuck Lever
     [not found]     ` <20150313212728.22783.11821.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:34       ` Sagi Grimberg
     [not found]         ` <5506B19F.80105-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 16:57           ` Chuck Lever
2015-03-24 11:12       ` Devesh Sharma
     [not found]         ` <EE7902D3F51F404C82415C4803930ACD5DC3A9C4-DWYeeINJQrxExQ8dmkPuX0M9+F4ksjoh@public.gmane.org>
2015-03-24 14:54           ` Chuck Lever
2015-03-13 21:27   ` [PATCH v1 07/16] xprtrdma: Add "init MRs" memreg op Chuck Lever
     [not found]     ` <20150313212738.22783.34521.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:36       ` Sagi Grimberg
2015-03-13 21:27   ` [PATCH v1 08/16] xprtrdma: Add "reset " Chuck Lever
     [not found]     ` <20150313212747.22783.98300.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:38       ` Sagi Grimberg
2015-03-24 11:27       ` Devesh Sharma
     [not found]         ` <EE7902D3F51F404C82415C4803930ACD5DC3A9E3-DWYeeINJQrxExQ8dmkPuX0M9+F4ksjoh@public.gmane.org>
2015-03-24 15:10           ` Chuck Lever
2015-03-13 21:27   ` [PATCH v1 09/16] xprtrdma: Add "destroy " Chuck Lever
     [not found]     ` <20150313212758.22783.67493.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:46       ` Sagi Grimberg
     [not found]         ` <5506B48F.6050902-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 16:59           ` Chuck Lever
2015-03-13 21:28   ` [PATCH v1 10/16] xprtrdma: Add "open" " Chuck Lever
     [not found]     ` <20150313212807.22783.61881.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-24 11:34       ` Devesh Sharma
     [not found]         ` <EE7902D3F51F404C82415C4803930ACD5DC3A9FF-DWYeeINJQrxExQ8dmkPuX0M9+F4ksjoh@public.gmane.org>
2015-03-24 15:29           ` Chuck Lever
2015-03-13 21:28   ` [PATCH v1 11/16] xprtrdma: Handle non-SEND completions via a callout Chuck Lever
     [not found]     ` <20150313212816.22783.49677.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 10:53       ` Sagi Grimberg
2015-03-13 21:28   ` [PATCH v1 12/16] xprtrdma: Acquire FMRs in rpcrdma_fmr_register_external() Chuck Lever
     [not found]     ` <20150313212825.22783.51384.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 12:28       ` Sagi Grimberg
     [not found]         ` <5506CC6C.8090106-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 17:03           ` Chuck Lever [this message]
2015-03-13 21:28   ` [PATCH v1 13/16] xprtrdma: Acquire MRs in rpcrdma_register_external() Chuck Lever
     [not found]     ` <20150313212835.22783.12326.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 12:44       ` Sagi Grimberg
     [not found]         ` <5506D02B.5050602-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-03-16 18:14           ` Chuck Lever
2015-03-13 21:28   ` [PATCH v1 14/16] xprtrdma: Remove rpcrdma_ia::ri_memreg_strategy Chuck Lever
     [not found]     ` <20150313212844.22783.1438.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 12:45       ` Sagi Grimberg
2015-03-13 21:28   ` [PATCH v1 15/16] xprtrdma: Make rpcrdma_{un}map_one() into inline functions Chuck Lever
     [not found]     ` <20150313212853.22783.62285.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2015-03-16 12:45       ` Sagi Grimberg
2015-03-13 21:29   ` [PATCH v1 16/16] xprtrdma: Split rb_lock Chuck Lever
  -- strict thread matches above, loose matches on Subject: below --
2015-03-13 21:21 [PATCH v1 00/16] NFS/RDMA patches proposed for 4.1 Chuck Lever
2015-03-13 21:23 ` [PATCH v1 12/16] xprtrdma: Acquire FMRs in rpcrdma_fmr_register_external() Chuck Lever

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=B60B5333-7A78-4A11-8070-C1AC7C9E3F7A@oracle.com \
    --to=chuck.lever-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.