All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v1 03/16] xprtrdma: Add vector of ops for each memory registration strategy
Date: Sun, 15 Mar 2015 05:04:40 +0200	[thread overview]
Message-ID: <5504F6C8.9030902@dev.mellanox.co.il> (raw)
In-Reply-To: <20150313212659.22783.28341.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>

On 3/13/2015 11:26 PM, Chuck Lever wrote:
> Instead of employing switch() statements, let's use the typical
> Linux kernel idiom for handling behavioral variation: virtual
> functions.
>
> Define a vector of operations for each supported memory registration
> mode, and add a source file for each mode.
>
> Signed-off-by: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> ---
>   net/sunrpc/xprtrdma/Makefile       |    3 ++-
>   net/sunrpc/xprtrdma/fmr_ops.c      |   22 ++++++++++++++++++++++
>   net/sunrpc/xprtrdma/frwr_ops.c     |   22 ++++++++++++++++++++++
>   net/sunrpc/xprtrdma/physical_ops.c |   24 ++++++++++++++++++++++++
>   net/sunrpc/xprtrdma/verbs.c        |   11 +++++++----
>   net/sunrpc/xprtrdma/xprt_rdma.h    |   12 ++++++++++++
>   6 files changed, 89 insertions(+), 5 deletions(-)
>   create mode 100644 net/sunrpc/xprtrdma/fmr_ops.c
>   create mode 100644 net/sunrpc/xprtrdma/frwr_ops.c
>   create mode 100644 net/sunrpc/xprtrdma/physical_ops.c
>
> diff --git a/net/sunrpc/xprtrdma/Makefile b/net/sunrpc/xprtrdma/Makefile
> index da5136f..579f72b 100644
> --- a/net/sunrpc/xprtrdma/Makefile
> +++ b/net/sunrpc/xprtrdma/Makefile
> @@ -1,6 +1,7 @@
>   obj-$(CONFIG_SUNRPC_XPRT_RDMA_CLIENT) += xprtrdma.o
>
> -xprtrdma-y := transport.o rpc_rdma.o verbs.o
> +xprtrdma-y := transport.o rpc_rdma.o verbs.o \
> +	fmr_ops.o frwr_ops.o physical_ops.o
>
>   obj-$(CONFIG_SUNRPC_XPRT_RDMA_SERVER) += svcrdma.o
>
> diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
> new file mode 100644
> index 0000000..ffb7d93
> --- /dev/null
> +++ b/net/sunrpc/xprtrdma/fmr_ops.c
> @@ -0,0 +1,22 @@
> +/*
> + * Copyright (c) 2015 Oracle.  All rights reserved.
> + * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
> + */
> +
> +/* Lightweight memory registration using Fast Memory Regions (FMR).
> + * Referred to sometimes as MTHCAFMR mode.
> + *
> + * FMR uses synchronous memory registration and deregistration.
> + * FMR registration is known to be fast, but FMR deregistration
> + * can take tens of usecs to complete.
> + */
> +
> +#include "xprt_rdma.h"
> +
> +#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
> +# define RPCDBG_FACILITY	RPCDBG_TRANS
> +#endif
> +
> +const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = {
> +	.ro_displayname			= "fmr",
> +};
> diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
> new file mode 100644
> index 0000000..79173f9
> --- /dev/null
> +++ b/net/sunrpc/xprtrdma/frwr_ops.c
> @@ -0,0 +1,22 @@
> +/*
> + * Copyright (c) 2015 Oracle.  All rights reserved.
> + * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
> + */
> +
> +/* Lightweight memory registration using Fast Registration Work
> + * Requests (FRWR). Also referred to sometimes as FRMR mode.
> + *
> + * FRWR features ordered asynchronous registration and deregistration
> + * of arbitrarily sized memory regions. This is the fastest and safest
> + * but most complex memory registration mode.
> + */
> +
> +#include "xprt_rdma.h"
> +
> +#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
> +# define RPCDBG_FACILITY	RPCDBG_TRANS
> +#endif
> +
> +const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = {
> +	.ro_displayname			= "frwr",
> +};
> diff --git a/net/sunrpc/xprtrdma/physical_ops.c b/net/sunrpc/xprtrdma/physical_ops.c
> new file mode 100644
> index 0000000..b0922ac
> --- /dev/null
> +++ b/net/sunrpc/xprtrdma/physical_ops.c
> @@ -0,0 +1,24 @@
> +/*
> + * Copyright (c) 2015 Oracle.  All rights reserved.
> + * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
> + */
> +
> +/* No-op chunk preparation. All client memory is pre-registered.
> + * Sometimes referred to as ALLPHYSICAL mode.
> + *
> + * Physical registration is simple because all client memory is
> + * pre-registered and never deregistered. This mode is good for
> + * adapter bring up, but is considered not safe: the server is
> + * trusted not to abuse its access to client memory not involved
> + * in RDMA I/O.
> + */
> +
> +#include "xprt_rdma.h"
> +
> +#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
> +# define RPCDBG_FACILITY	RPCDBG_TRANS
> +#endif
> +
> +const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = {
> +	.ro_displayname			= "physical",
> +};
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 1aa55b7..e4d9d9c 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -492,10 +492,10 @@ connected:
>   		int ird = attr->max_dest_rd_atomic;
>   		int tird = ep->rep_remote_cma.responder_resources;
>
> -		pr_info("rpcrdma: connection to %pIS:%u on %s, memreg %d slots %d ird %d%s\n",
> +		pr_info("rpcrdma: connection to %pIS:%u on %s, memreg '%s', %d credits, %d responders%s\n",
>   			sap, rpc_get_port(sap),
>   			ia->ri_id->device->name,
> -			ia->ri_memreg_strategy,
> +			ia->ri_ops->ro_displayname,
>   			xprt->rx_buf.rb_max_requests,
>   			ird, ird < 4 && ird < tird / 2 ? " (low!)" : "");
>   	} else if (connstate < 0) {
> @@ -649,13 +649,16 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>   	 */
>   	switch (memreg) {
>   	case RPCRDMA_FRMR:
> +		ia->ri_ops = &rpcrdma_frwr_memreg_ops;
>   		break;
>   	case RPCRDMA_ALLPHYSICAL:
> +		ia->ri_ops = &rpcrdma_physical_memreg_ops;
>   		mem_priv = IB_ACCESS_LOCAL_WRITE |
>   				IB_ACCESS_REMOTE_WRITE |
>   				IB_ACCESS_REMOTE_READ;
>   		goto register_setup;
>   	case RPCRDMA_MTHCAFMR:
> +		ia->ri_ops = &rpcrdma_fmr_memreg_ops;
>   		if (ia->ri_have_dma_lkey)
>   			break;
>   		mem_priv = IB_ACCESS_LOCAL_WRITE;
> @@ -675,8 +678,8 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>   		rc = -ENOMEM;
>   		goto out3;
>   	}
> -	dprintk("RPC:       %s: memory registration strategy is %d\n",
> -		__func__, memreg);
> +	dprintk("RPC:       %s: memory registration strategy is '%s'\n",
> +		__func__, ia->ri_ops->ro_displayname);
>
>   	/* Else will do memory reg/dereg for each chunk */
>   	ia->ri_memreg_strategy = memreg;
> diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
> index c8afd83..ef3cf4a 100644
> --- a/net/sunrpc/xprtrdma/xprt_rdma.h
> +++ b/net/sunrpc/xprtrdma/xprt_rdma.h
> @@ -60,6 +60,7 @@
>    * Interface Adapter -- one per transport instance
>    */
>   struct rpcrdma_ia {
> +	const struct rpcrdma_memreg_ops	*ri_ops;
>   	rwlock_t		ri_qplock;
>   	struct rdma_cm_id 	*ri_id;
>   	struct ib_pd		*ri_pd;
> @@ -331,6 +332,17 @@ struct rpcrdma_stats {
>   };
>
>   /*
> + * Per-registration mode operations
> + */
> +struct rpcrdma_memreg_ops {
> +	const char	*ro_displayname;
> +};
> +
> +extern const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops;
> +extern const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops;
> +extern const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops;
> +
> +/*
>    * RPCRDMA transport -- encapsulates the structures above for
>    * integration with RPC.
>    *
>

Don't know if I'd use three different files, but other than that I like
the change.

Reviewed-by: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
--
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-15  3:04 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 [this message]
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
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:21 ` [PATCH v1 03/16] xprtrdma: Add vector of ops for each memory registration strategy 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=5504F6C8.9030902@dev.mellanox.co.il \
    --to=sagig-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
    --cc=chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@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.