Re: [PATCH v2 for-next 1/3] RDMA/core: Provide rdma_user_mmap_disassociate() to disassociate mmap pages
From: Jason Gunthorpe
Date: Mon Aug 26 2024 - 09:16:52 EST
On Mon, Aug 26, 2024 at 09:12:33PM +0800, Junxian Huang wrote:
> diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
> index 821d93c8f712..05b589aad5ef 100644
> --- a/drivers/infiniband/core/uverbs.h
> +++ b/drivers/infiniband/core/uverbs.h
> @@ -160,6 +160,9 @@ struct ib_uverbs_file {
> struct page *disassociate_page;
>
> struct xarray idr;
> +
> + struct mutex disassociation_lock;
> + bool disassociated;
> };
>
> struct ib_uverbs_event {
> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index 6b4d5a660a2f..6503f9a23211 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -722,12 +722,12 @@ static void rdma_umap_open(struct vm_area_struct *vma)
> return;
>
> /* We are racing with disassociation */
> - if (!down_read_trylock(&ufile->hw_destroy_rwsem))
> + if (!mutex_trylock(&ufile->disassociation_lock))
> goto out_zap;
Nonon, don't touch this stuff! It is fine as is
The extra lock should be in the mmap zap functions only
Jason