From: Logan Gunthorpe <logang@deltatee.com>
To: Dan Williams <dan.j.williams@intel.com>, akpm@linux-foundation.org
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Christoph Hellwig <hch@lst.de>,
linux-mm@kvack.org, linux-pci@vger.kernel.org,
linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] pci/p2pdma: Track pgmap references per resource, not globally
Date: Fri, 29 Mar 2019 11:50:23 -0600 [thread overview]
Message-ID: <cfda881b-d99c-7c53-64cb-745ff4b257b0@deltatee.com> (raw)
In-Reply-To: <155387327020.2443841.6446837127378298192.stgit@dwillia2-desk3.amr.corp.intel.com>
Thanks Dan, this is great. I think the changes in this series are
cleaner and more understandable than the patch set I had sent earlier.
However, I found a couple minor issues with this patch:
On 2019-03-29 9:27 a.m., Dan Williams wrote:
> static void pci_p2pdma_release(void *data)
> {
> struct pci_dev *pdev = data;
> @@ -103,12 +110,12 @@ static void pci_p2pdma_release(void *data)
> if (!pdev->p2pdma)
> return;
>
> - wait_for_completion(&pdev->p2pdma->devmap_ref_done);
> - percpu_ref_exit(&pdev->p2pdma->devmap_ref);
> + /* Flush and disable pci_alloc_p2p_mem() */
> + pdev->p2pdma = NULL;
> + synchronize_rcu();
>
> gen_pool_destroy(pdev->p2pdma->pool);
I missed this on my initial review, but it became obvious when I tried
to test the series: this is a NULL dereference seeing pdev->p2pdma was
set to NULL a few lines up.
When I fix this by storing p2pdma in a local variable, the patch set
works and never seems to crash when I hot remove p2pdma memory.
> void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size)
> {
> - void *ret;
> + void *ret = NULL;
> + struct percpu_ref *ref;
>
> + rcu_read_lock();
> if (unlikely(!pdev->p2pdma))
> - return NULL;
Using RCU here makes sense to me, however I expect we should be using
the proper rcu_assign_pointer(), rcu_dereference() and __rcu tag with
pdev->p2pdma. If only to better document what's being protected with the
new RCU calls.
Logan
next prev parent reply other threads:[~2019-03-29 17:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 15:27 [PATCH 0/6] mm/devm_memremap_pages: Fix page release race Dan Williams
2019-03-29 15:27 ` [PATCH 1/6] drivers/base/devres: Introduce devm_release_action() Dan Williams
2019-03-29 15:27 ` [PATCH 2/6] mm/devm_memremap_pages: Introduce devm_memunmap_pages Dan Williams
2019-03-29 15:27 ` [PATCH 3/6] pci/p2pdma: Fix the gen_pool_add_virt() failure path Dan Williams
2019-03-29 17:24 ` Bjorn Helgaas
2019-03-29 15:27 ` [PATCH 4/6] lib/genalloc: Introduce chunk owners Dan Williams
2019-03-29 15:27 ` [PATCH 5/6] pci/p2pdma: Track pgmap references per resource, not globally Dan Williams
2019-03-29 17:50 ` Logan Gunthorpe [this message]
2019-03-29 19:32 ` Dan Williams
2019-03-29 15:27 ` [PATCH 6/6] mm/devm_memremap_pages: Fix final page put race Dan Williams
2019-03-29 9:46 ` Ira Weiny
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=cfda881b-d99c-7c53-64cb-745ff4b257b0@deltatee.com \
--to=logang@deltatee.com \
--cc=akpm@linux-foundation.org \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-pci@vger.kernel.org \
/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