Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp894078pxb; Wed, 3 Nov 2021 14:19:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLkRnV4b9OAULKvcfMwaDXKFEZoJLm2OY703DAZ7Crw87XweHkbh35nm0RBeGNJC3xIg5r X-Received: by 2002:a05:6402:455:: with SMTP id p21mr23084132edw.384.1635974358828; Wed, 03 Nov 2021 14:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635974358; cv=none; d=google.com; s=arc-20160816; b=rv4D4TnQ4aszTp+5Q9gq4jWxyN7XVbcdZV5NB7OfgY+0EyFA2ct81p7nEZgrYh+bSF peBGMmPEmX7fLlawGrT0yacNGnrSsRgJOR1WKtpWIeqcC9bF04tGaBAdH+05K/6aRnsZ sVFTvHiyo/cgXgpC8w45cQYC+Hl4cyz+imgYxoRHfKKgMhejEcXNWqVna78ABfAKNv8I C/J7SoWQ2R7T5SYMqoUQ2nPRWnzMg7EkGH2W27ij501PNshap8n8K03tBWemoQIuS2Cd 8VQKdXrdy4k+HtIQaZOKjC0L6j6zroqUSG127V4qZNsiOK+k4wHU08bbx311XiXYYL1t SKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ziHWGG9wYzboaNHSdrkbBSoBiAqC6GyIdPB9aaKDTCY=; b=cu2C7JZYCcE0mkesswGQw3BrYOWb65lX7CIxx8Ngh6Pxp4PFYGnMb37F8r3y7AQ2zC JK7N0j75biV74mEd9tf1ATSlt7mwxM4gh1oDgJ3P7FkP7sXG9xmLaSnjnnGCeqSFSrrY j9qsXSJqWLoC/YhPlaHk4Rk992Ii06jSOLdf6zl1+zcpT9X7Q72aQG9MeqnOlvLBV09I pzDrNb0vxGu9Pokz7Jj6M58CPVmClc2TzXzYumN26TVc4boj/5MQhy4lUdRnYH+c6Czj 7Qtg1DNwS9tcMvh4emVWGcX2BzqvyXgo3z14WE94ShNiIaFkezh84dpUh8tw3qP3I11L SZLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si7817754edb.72.2021.11.03.14.18.52; Wed, 03 Nov 2021 14:19:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbhKCVTe (ORCPT + 99 others); Wed, 3 Nov 2021 17:19:34 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:52582 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbhKCVTd (ORCPT ); Wed, 3 Nov 2021 17:19:33 -0400 Received: from pop-os.home ([86.243.171.122]) by smtp.orange.fr with ESMTPA id iNcsmLYXlBazoiNcsmwyh5; Wed, 03 Nov 2021 22:16:55 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 03 Nov 2021 22:16:55 +0100 X-ME-IP: 86.243.171.122 From: Christophe JAILLET To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] PCI/P2PDMA: Save a few cycles in 'pci_alloc_p2pmem()' Date: Wed, 3 Nov 2021 22:16:53 +0100 Message-Id: X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use 'percpu_ref_tryget_live_rcu()' instead of 'percpu_ref_tryget_live()' to save a few cycles when it is known that the rcu lock is already taken/released. Signed-off-by: Christophe JAILLET --- drivers/pci/p2pdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 8d47cb7218d1..081c391690d4 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; -- 2.30.2