All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Kalderon <mkalderon@marvell.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Gal Pressman <galpress@amazon.com>
Cc: Ariel Elior <aelior@marvell.com>,
	"dledford@redhat.com" <dledford@redhat.com>,
	"bmt@zurich.ibm.com" <bmt@zurich.ibm.com>,
	"sleybo@amazon.com" <sleybo@amazon.com>,
	"leon@kernel.org" <leon@kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Subject: RE: [EXT] Re: [PATCH v11 rdma-next 6/7] RDMA/qedr: Add doorbell overflow recovery support
Date: Wed, 25 Sep 2019 19:16:23 +0000	[thread overview]
Message-ID: <MN2PR18MB3182FEF24664E620E357B83AA1870@MN2PR18MB3182.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20190920133817.GB7095@ziepe.ca>

> From: Jason Gunthorpe <jgg@ziepe.ca>
> Sent: Friday, September 20, 2019 4:38 PM
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Fri, Sep 20, 2019 at 04:30:52PM +0300, Gal Pressman wrote:
> > On 19/09/2019 21:02, Jason Gunthorpe wrote:
> > > On Thu, Sep 05, 2019 at 01:01:16PM +0300, Michal Kalderon wrote:
> > >
> > >> @@ -347,6 +360,9 @@ void qedr_mmap_free(struct
> rdma_user_mmap_entry
> > >> *rdma_entry)  {
> > >>  	struct qedr_user_mmap_entry *entry =
> > >> get_qedr_mmap_entry(rdma_entry);
> > >>
> > >> +	if (entry->mmap_flag == QEDR_USER_MMAP_PHYS_PAGE)
> > >> +		free_page((unsigned long)phys_to_virt(entry->address));
> > >> +
> > >
> > > While it isn't wrong it do it this way, we don't need this
> > > mmap_free() stuff for normal CPU pages. Those are refcounted and
> > > qedr can simply call free_page() during the teardown of the uobject
> > > that is using the this page. This is what other drivers already do.
> >
> > This is pretty much what EFA does as well.  When we allocate pages for
> > the user (CQ for example), we DMA map them and later on mmap them to
> > the user. We expect those pages to remain until the entry is freed,
> > how can we call free_page, who is holding a refcount on those except
> > for the driver?
> 
> free_page is kind of a lie, it is more like put_page (see __free_pages). I think
> the difference is that it assumes the page came from alloc_page and skips
> some generic stuff when freeing it.
> 
> When the driver does vm_insert_page the vma holds another refcount and
> the refcount does not go to zero until that page drops out of the vma (ie at
> the same time mmap_free above is called).
> 
> Then __put_page will do the free_unref_page(), etc.
> 
> So for CPU pages it is fine to not use mmap_free so long as vm_insert_page
> is used
Jason, by adding the kref to the rdma_user_mmap_entry  we sort of disable the 
option of being sure the entry is removed from the mmap xarray when it is removed
by the driver (this will only decrease the refcnt).
If we call free_page during the uobject teardown, we can't be sure
the entry is removed from the mmap_xa, this could lead to us having an entry in the mmap_xa
that points to an invalid page. 

Perhaps we could define the entry as being ref-counted or not based on the type of address, but
the original design was to keep this information opaque to the rdma_user_mmap_entry. 
We can also assume that for CPU pages the flow that increases the refcnt won't be called
(mmap_io) but this feels like bad practice. 

How should I handle this?
Thanks,

> 
> Jason

  parent reply	other threads:[~2019-09-25 19:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 10:01 [PATCH v11 rdma-next 0/7] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Michal Kalderon
2019-09-05 10:01 ` [PATCH v11 rdma-next 1/7] RDMA/core: Move core content from ib_uverbs to ib_core Michal Kalderon
2019-09-05 10:01 ` [PATCH v11 rdma-next 2/7] RDMA/core: Create mmap database and cookie helper functions Michal Kalderon
2019-09-19 17:14   ` Jason Gunthorpe
2019-09-19 17:48   ` Jason Gunthorpe
2019-09-19 18:07   ` Jason Gunthorpe
2019-09-23  9:36     ` [EXT] " Michal Kalderon
2019-09-23 13:30       ` Jason Gunthorpe
2019-09-24  8:31         ` Michal Kalderon
2019-09-24 12:37           ` Jason Gunthorpe
2019-09-05 10:01 ` [PATCH v11 rdma-next 3/7] RDMA/efa: Use the common mmap_xa helpers Michal Kalderon
2019-09-19 17:37   ` Jason Gunthorpe
2019-09-23  9:15     ` Michal Kalderon
2019-09-23 13:28       ` Jason Gunthorpe
2019-09-05 10:01 ` [PATCH v11 rdma-next 4/7] RDMA/siw: " Michal Kalderon
2019-09-05 10:01 ` [PATCH v11 rdma-next 5/7] RDMA/qedr: Use the common mmap API Michal Kalderon
2019-09-19 17:55   ` Jason Gunthorpe
2019-09-20 13:39     ` Gal Pressman
2019-09-23  9:21       ` Michal Kalderon
2019-09-23 13:29         ` Jason Gunthorpe
2019-09-24  8:25           ` [EXT] " Michal Kalderon
2019-09-24  8:49         ` Pressman, Gal
2019-09-24  9:31           ` Michal Kalderon
2019-10-20  7:19             ` Gal Pressman
2019-10-21 17:33               ` Jason Gunthorpe
2019-10-23  6:40                 ` Gal Pressman
2019-10-23 14:41                   ` Jason Gunthorpe
2019-10-24  8:06                     ` Gal Pressman
2019-09-05 10:01 ` [PATCH v11 rdma-next 6/7] RDMA/qedr: Add doorbell overflow recovery support Michal Kalderon
2019-09-19 18:02   ` Jason Gunthorpe
2019-09-20 13:30     ` Gal Pressman
2019-09-20 13:38       ` Jason Gunthorpe
2019-09-20 14:00         ` Gal Pressman
2019-09-23  9:37           ` Michal Kalderon
2019-09-25 19:16         ` Michal Kalderon [this message]
2019-09-25 19:21           ` [EXT] " Jason Gunthorpe
2019-09-25 19:37             ` Michal Kalderon
2019-09-26 19:10               ` Jason Gunthorpe
2019-09-23  9:30     ` Michal Kalderon
2019-09-23 13:26       ` Jason Gunthorpe
2019-09-05 10:01 ` [PATCH v11 rdma-next 7/7] RDMA/qedr: Add iWARP doorbell " Michal Kalderon

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=MN2PR18MB3182FEF24664E620E357B83AA1870@MN2PR18MB3182.namprd18.prod.outlook.com \
    --to=mkalderon@marvell.com \
    --cc=aelior@marvell.com \
    --cc=bmt@zurich.ibm.com \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sleybo@amazon.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.