Skip to content

Commit 69f457b

Browse files
tititiou36bjorn-helgaas
authored andcommitted
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>
1 parent 133bc54 commit 69f457b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/pci/p2pdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size)
710710
if (!ret)
711711
goto out;
712712

713-
if (unlikely(!percpu_ref_tryget_live(ref))) {
713+
if (unlikely(!percpu_ref_tryget_live_rcu(ref))) {
714714
gen_pool_free(p2pdma->pool, (unsigned long) ret, size);
715715
ret = NULL;
716716
goto out;

0 commit comments

Comments
 (0)