All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Michal Kalderon <michal.kalderon@marvell.com>
Cc: ariel.elior@marvell.com, dledford@redhat.com,
	galpress@amazon.com, yishaih@mellanox.com, bmt@zurich.ibm.com,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH v12 rdma-next 3/8] RDMA: Connect between the mmap entry and the umap_priv structure
Date: Tue, 5 Nov 2019 15:47:43 -0400	[thread overview]
Message-ID: <20191105194743.GA19748@ziepe.ca> (raw)
In-Reply-To: <20191030094417.16866-4-michal.kalderon@marvell.com>

On Wed, Oct 30, 2019 at 11:44:12AM +0200, Michal Kalderon wrote:

> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index b1f5334ff907..dbe9bd3d389a 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -819,7 +819,7 @@ static void rdma_umap_open(struct vm_area_struct *vma)
>  	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
>  		goto out_unlock;
> -	rdma_umap_priv_init(priv, vma);
> +	rdma_umap_priv_init(priv, vma, opriv->entry);
>  
>  	up_read(&ufile->hw_destroy_rwsem);
>  	return;
> @@ -844,6 +844,11 @@ static void rdma_umap_close(struct vm_area_struct *vma)
>  	if (!priv)
>  		return;
>  
> +	if (priv->entry) {
> +		rdma_user_mmap_entry_put(ufile->ucontext, priv->entry);
> +		priv->entry = NULL;
> +	}
> +

This should be done inside the lock otherwise it can race with
uverbs_user_mmap_disassociate(), the assignment of NULL is not needed
as we free it immediately after.


> @@ -946,6 +951,13 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
>  
>  			if (vma->vm_mm != mm)
>  				continue;
> +
> +			if (priv->entry) {
> +				rdma_user_mmap_entry_put(ufile->ucontext,
> +							 priv->entry);
> +				priv->entry = NULL;
> +			}
> +
>  			list_del_init(&priv->list);
>  
>  			zap_vma_ptes(vma, vma->vm_start,

The zap needs to be before the entry_put so that the pages are
actually removed before the driver goes to free them

Jason

  reply	other threads:[~2019-11-05 19:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30  9:44 [PATCH v12 rdma-next 0/8] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 1/8] RDMA/core: Move core content from ib_uverbs to ib_core Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 2/8] RDMA/core: Create mmap database and cookie helper functions Michal Kalderon
2019-10-31 12:35   ` Yishai Hadas
2019-11-01 10:19     ` [EXT] " Michal Kalderon
2019-11-05 19:44   ` Jason Gunthorpe
2019-10-30  9:44 ` [PATCH v12 rdma-next 3/8] RDMA: Connect between the mmap entry and the umap_priv structure Michal Kalderon
2019-11-05 19:47   ` Jason Gunthorpe [this message]
2019-10-30  9:44 ` [PATCH v12 rdma-next 4/8] RDMA/efa: Use the common mmap_xa helpers Michal Kalderon
2019-11-05 19:54   ` Jason Gunthorpe
2019-11-06  8:20     ` Gal Pressman
2019-10-30  9:44 ` [PATCH v12 rdma-next 5/8] RDMA/siw: " Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 6/8] RDMA/qedr: Use the common mmap API Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 7/8] RDMA/qedr: Add doorbell overflow recovery support Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 8/8] RDMA/qedr: Add iWARP doorbell " Michal Kalderon
2019-10-30 15:33 ` [PATCH v12 rdma-next 5/8] RDMA/siw: Use the common mmap_xa helpers Bernard Metzler
2019-11-05 20:41 ` [PATCH v12 rdma-next 0/8] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Jason Gunthorpe
2019-11-06 13:04   ` Michal Kalderon
2019-11-06 15:10     ` Jason Gunthorpe
2019-11-06 17:09     ` Jason Gunthorpe

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=20191105194743.GA19748@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=ariel.elior@marvell.com \
    --cc=bmt@zurich.ibm.com \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michal.kalderon@marvell.com \
    --cc=yishaih@mellanox.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 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.