public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Doug Ledford <dledford@redhat.com>,
	linux-rdma@vger.kernel.org
Cc: Amir Vadai <amirv@mellanox.com>,
	Andy Grover <andy.grover@oracle.com>,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	Chien Yen <chien.yen@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	Dominique Martinet <dominique.martinet@cea.fr>,
	Eli Cohen <eli@mellanox.com>,
	Eric Van Hensbergen <ericvh@gmail.com>,
	Ido Shamay <idos@mellanox.com>,
	Latchesar Ionkov <lucho@ionkov.net>,
	Or Gerlitz <ogerlitz@mellanox.com>, Roi Dayan <roid@mellanox.com>,
	Ron Minnich <rminnich@sandia.gov>,
	Sagi Grimberg <sagig@mellanox.com>,
	Simon Derr <simon.derr@bull.net>,
	Tom Tucker <tom@opengridcomputing.com>,
	Zach Brown <zach.brown@oracle.com>,
	rds-devel@oss.oracle.com, target-devel@vger.kernel.org,
	v9fs-developer@lists.sourceforge.net
Subject: Re: [PATCH 01/10] IB/core: Guarantee that a local_dma_lkey is available
Date: Thu, 23 Jul 2015 13:47:02 +0300	[thread overview]
Message-ID: <55B0C626.4070707@dev.mellanox.co.il> (raw)
In-Reply-To: <1437608083-22898-2-git-send-email-jgunthorpe@obsidianresearch.com>

On 7/23/2015 2:34 AM, Jason Gunthorpe wrote:
> Every single ULP requires a local_dma_lkey to do anything with
> a QP, so let us ensure one exists for every PD created.
>
> If the driver can supply a global local_dma_lkey then use that, otherwise
> ask the driver to create a local use all physical memory MR associated
> with the new PD.
>
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> Reviewed-by: Sagi Grimberg <sagig@dev.mellanox.co.il>
> Acked-by: Christoph Hellwig <hch@infradead.org>
> ---
>   drivers/infiniband/core/verbs.c | 40 +++++++++++++++++++++++++++++++++++-----
>   include/rdma/ib_verbs.h         |  2 ++
>   2 files changed, 37 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index bac3fb406a74..1ddf06314f36 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -213,24 +213,54 @@ EXPORT_SYMBOL(rdma_port_get_link_layer);
>
>   /* Protection domains */
>
> +/* Return a pd for in-kernel use that has a local_dma_lkey which provides
> +   local access to all physical memory. */

Why not kdoc style? we need to move the ib_verbs.h kdocs here anyway.
Might be a good chance to do that for ib_alloc_pd().

>   struct ib_pd *ib_alloc_pd(struct ib_device *device)
>   {
>   	struct ib_pd *pd;
> +	struct ib_device_attr devattr;
> +	int rc;
> +
> +	rc = ib_query_device(device, &devattr);
> +	if (rc)
> +		return ERR_PTR(rc);
>
>   	pd = device->alloc_pd(device, NULL, NULL);
> +	if (IS_ERR(pd))
> +		return pd;
> +
> +	pd->device = device;
> +	pd->uobject = NULL;
> +	pd->local_mr = NULL;
> +	atomic_set(&pd->usecnt, 0);
> +
> +	if (devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)
> +		pd->local_dma_lkey = device->local_dma_lkey;
> +	else {
> +		struct ib_mr *mr;
> +
> +		mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE);
> +		if (IS_ERR(mr)) {
> +			ib_dealloc_pd(pd);
> +			return (struct ib_pd *)mr;
> +		}
>
> -	if (!IS_ERR(pd)) {
> -		pd->device  = device;
> -		pd->uobject = NULL;
> -		atomic_set(&pd->usecnt, 0);
> +		pd->local_mr = mr;
> +		pd->local_dma_lkey = pd->local_mr->lkey;
>   	}
> -
>   	return pd;
>   }
> +
>   EXPORT_SYMBOL(ib_alloc_pd);

You have an extra newline here.

>
>   int ib_dealloc_pd(struct ib_pd *pd)
>   {
> +	if (pd->local_mr) {
> +		if (ib_dereg_mr(pd->local_mr))
> +			return -EBUSY;
> +		pd->local_mr = NULL;
> +	}
> +
>   	if (atomic_read(&pd->usecnt))
>   		return -EBUSY;
>
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 986fddb08579..cfda95d7b067 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1255,6 +1255,8 @@ struct ib_pd {
>   	struct ib_device       *device;
>   	struct ib_uobject      *uobject;
>   	atomic_t          	usecnt; /* count all resources */
> +	struct ib_mr	       *local_mr;
> +	u32			local_dma_lkey;

Maybe its better to place the local_dma_lkey in the first cacheline as
it is normally accessed in the hot path?

  reply	other threads:[~2015-07-23 10:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 23:34 [PATCH 00/10] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey Jason Gunthorpe
2015-07-22 23:34 ` [PATCH 01/10] IB/core: Guarantee that a local_dma_lkey is available Jason Gunthorpe
2015-07-23 10:47   ` Sagi Grimberg [this message]
2015-07-23 18:36     ` Jason Gunthorpe
     [not found] ` <1437608083-22898-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-22 23:34   ` [PATCH 02/10] IB/mad: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-22 23:34   ` [PATCH 03/10] IB/ipoib: " Jason Gunthorpe
2015-07-22 23:34   ` [PATCH 07/10] iser-target: " Jason Gunthorpe
2015-07-23 10:49     ` Sagi Grimberg
2015-07-22 23:34   ` [PATCH 08/10] IB/srp: Use pd->local_dma_lkey Jason Gunthorpe
     [not found]     ` <1437608083-22898-9-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-23 10:50       ` Sagi Grimberg
2015-07-22 23:34 ` [PATCH 04/10] IB/mlx4: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-22 23:34 ` [PATCH 05/10] IB/mlx5: " Jason Gunthorpe
2015-07-22 23:34 ` [PATCH 06/10] IB/iser: Use pd->local_dma_lkey Jason Gunthorpe
2015-07-23 10:49   ` Sagi Grimberg
2015-07-22 23:34 ` [PATCH 09/10] ib_srpt: Remove ib_get_dma_mr calls Jason Gunthorpe
2015-07-23 10:51   ` Sagi Grimberg
2015-07-22 23:34 ` [PATCH 10/10] net/9p: " Jason Gunthorpe
2015-07-23  7:46   ` Dominique Martinet
2015-07-23 10:56 ` [PATCH 00/10] IB: Replace safe uses for ib_get_dma_mr with pd->local_dma_lkey Sagi Grimberg
2015-07-23 13:47 ` Bart Van Assche
2015-07-23 18:30   ` Jason Gunthorpe
     [not found]     ` <20150723183044.GA1868-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-23 18:42       ` Bart Van Assche
     [not found]         ` <55B13583.5010208-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-07-23 18:47           ` Jason Gunthorpe
2015-07-26  8:45             ` Sagi Grimberg
2015-07-29 16:39             ` Doug Ledford
2015-07-25  6:27   ` Christoph Hellwig
2015-07-28 15:01 ` J.L. Burr
2015-07-28 18:23   ` Jason Gunthorpe
2015-07-28 20:58     ` J.L. Burr
2015-07-28 22:10       ` Jason Gunthorpe
2015-07-28 23:56         ` J.L. Burr

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=55B0C626.4070707@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    --cc=amirv@mellanox.com \
    --cc=andy.grover@oracle.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=chien.yen@oracle.com \
    --cc=dledford@redhat.com \
    --cc=dominique.martinet@cea.fr \
    --cc=eli@mellanox.com \
    --cc=ericvh@gmail.com \
    --cc=hch@infradead.org \
    --cc=idos@mellanox.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=ogerlitz@mellanox.com \
    --cc=rds-devel@oss.oracle.com \
    --cc=rminnich@sandia.gov \
    --cc=roid@mellanox.com \
    --cc=sagig@mellanox.com \
    --cc=simon.derr@bull.net \
    --cc=target-devel@vger.kernel.org \
    --cc=tom@opengridcomputing.com \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=zach.brown@oracle.com \
    /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