Re: [PATCH v3 for-next 1/2] RDMA/core: Provide rdma_user_mmap_disassociate() to disassociate mmap pages

From: Jason Gunthorpe
Date: Wed Sep 04 2024 - 12:05:12 EST


On Tue, Sep 03, 2024 at 10:09:22AM +0300, Leon Romanovsky wrote:

> > The original thought was that ib_uverbs_mmap() reads ufile->disassociated while
> > uverbs_user_mmap_disassociate() writes it, and there might be a racing. We tried
> > to use atomic_t to avoid racing without adding locks.
>
> atomic_t is never a replacement for locks. It is a way to provide
> coherent view of the data between CPUs and makes sure that write/read is
> not interrupted.

Yes, add a lock, like I said

Jason