PCI/P2PDMA: Use percpu_ref_tryget_live_rcu() inside RCU critical section

Since pci_alloc_p2pmem() has already called rcu_read_lock(), we're in an
RCU read-side critical section and don't need to take the lock again.  Use
percpu_ref_tryget_live_rcu() instead of percpu_ref_tryget_live() to save a
few cycles.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/ab80164f4d5b32f9e6240aa4863c3a147ff9c89f.1635974126.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
This commit is contained in:
Christophe JAILLET 2021-11-03 22:16:53 +01:00 committed by Bjorn Helgaas
parent 133bc542db
commit 69f457b18f

View File

@ -710,7 +710,7 @@ void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size)
if (!ret) if (!ret)
goto out; goto out;
if (unlikely(!percpu_ref_tryget_live(ref))) { if (unlikely(!percpu_ref_tryget_live_rcu(ref))) {
gen_pool_free(p2pdma->pool, (unsigned long) ret, size); gen_pool_free(p2pdma->pool, (unsigned long) ret, size);
ret = NULL; ret = NULL;
goto out; goto out;