From: Christophe JAILLET Date: Wed, 3 Nov 2021 21:16:53 +0000 (+0100) Subject: PCI/P2PDMA: Use percpu_ref_tryget_live_rcu() inside RCU critical section X-Git-Tag: v5.17-rc1~73^2~23^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69f457b18fa2b9a793ce61e8d1cf295983aca3a9;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Bjorn Helgaas Reviewed-by: Krzysztof WilczyƄski Reviewed-by: Logan Gunthorpe --- diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 8d47cb7218d15..081c391690d45 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -710,7 +710,7 @@ void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size) if (!ret) 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); ret = NULL; goto out;