From patchwork Wed Nov 3 21:35:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12601727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 936ECC433EF for ; Wed, 3 Nov 2021 21:35:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 21004610A8 for ; Wed, 3 Nov 2021 21:35:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 21004610A8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=wanadoo.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3A8BD6B006C; Wed, 3 Nov 2021 17:35:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 358776B0072; Wed, 3 Nov 2021 17:35:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26E166B0073; Wed, 3 Nov 2021 17:35:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1709A6B006C for ; Wed, 3 Nov 2021 17:35:38 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BC33C8249980 for ; Wed, 3 Nov 2021 21:35:37 +0000 (UTC) X-FDA: 78768925914.15.842E6E3 Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 500F730000AE for ; Wed, 3 Nov 2021 21:35:26 +0000 (UTC) Received: from pop-os.home ([86.243.171.122]) by smtp.orange.fr with ESMTPA id iNuxmLey8BazoiNuxmx1Ci; Wed, 03 Nov 2021 22:35:36 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 03 Nov 2021 22:35:36 +0100 X-ME-IP: 86.243.171.122 From: Christophe JAILLET To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] mm/mremap_pages: Save a few cycles in 'get_dev_pagemap()' Date: Wed, 3 Nov 2021 22:35:34 +0100 Message-Id: X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 500F730000AE X-Stat-Signature: x5tf1akdn5fte57zhpctd9zjtac5hi9p Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=none (imf08.hostedemail.com: domain of christophe.jaillet@wanadoo.fr has no SPF policy when checking 80.12.242.124) smtp.mailfrom=christophe.jaillet@wanadoo.fr X-HE-Tag: 1635975326-967306 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000442, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- mm/memremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memremap.c b/mm/memremap.c index 84de22c14567..012e8d23d365 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -506,7 +506,7 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn, /* fall back to slow path lookup */ rcu_read_lock(); pgmap = xa_load(&pgmap_array, PHYS_PFN(phys)); - if (pgmap && !percpu_ref_tryget_live(pgmap->ref)) + if (pgmap && !percpu_ref_tryget_live_rcu(pgmap->ref)) pgmap = NULL; rcu_read_unlock();