From patchwork Fri Sep 2 16:39:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12964414 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9465BECAAD5 for ; Fri, 2 Sep 2022 16:39:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A7E8800DA; Fri, 2 Sep 2022 12:39:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2572D8D002B; Fri, 2 Sep 2022 12:39:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 146A7800DA; Fri, 2 Sep 2022 12:39:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0307A8D002B for ; Fri, 2 Sep 2022 12:39:57 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C81CE1C6CBE for ; Fri, 2 Sep 2022 16:39:56 +0000 (UTC) X-FDA: 79867707192.23.829AAEC Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by imf25.hostedemail.com (Postfix) with ESMTP id 7729BA005B for ; Fri, 2 Sep 2022 16:39:55 +0000 (UTC) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id U9hwotD6YjJi0U9hxo8ald; Fri, 02 Sep 2022 18:39:54 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 02 Sep 2022 18:39:54 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Andrew Morton Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-mm@kvack.org Subject: [PATCH v2] mm/mremap_pages: Save a few cycles in get_dev_pagemap() Date: Fri, 2 Sep 2022 18:39:52 +0200 Message-Id: <9ef1562a1975371360f3e263856e9f1c5749b656.1662136782.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662136795; a=rsa-sha256; cv=none; b=skZoJ+h57L3u/eFt+LiUHGFOGe47CApI1GRRzsTX9tEnzdlR8XtkBIhbCKtmY2eLiQiG1q FFz5JhqYWTtQ3/WVi3DhHQuMQWM1spuAoah/NN1HSFVShqyWeiU8/wDLeQNUr32C4+eznm JdrgwlWtD8545H9gvwmn4+Q6C/cBUZc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf25.hostedemail.com: domain of christophe.jaillet@wanadoo.fr designates 80.12.242.129 as permitted sender) smtp.mailfrom=christophe.jaillet@wanadoo.fr ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662136795; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=Z9IitS21cBtCKR6TZilE0ZEiEznv+RAyaJgr9VXDB18=; b=dXraYaP9qfRDSaUreiibsrjQthSAEORS3tNWx9BB0EiPsRm8wZs1/Itd5CypH8uY8cLkgZ hmq5xMHDpcyNbTy37C6q3ou3ihX8ZE3GC0eCpRIw1CxN5UCnPjJ8yOWCQTrLxi9rWk0x4d ClcxgvL2ASSU6S6r3b/Ubv9mohfS2A8= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7729BA005B Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf25.hostedemail.com: domain of christophe.jaillet@wanadoo.fr designates 80.12.242.129 as permitted sender) smtp.mailfrom=christophe.jaillet@wanadoo.fr X-Rspam-User: X-Stat-Signature: 5a6bpn6gock1qmetib3yis7k9b9hr7br X-HE-Tag: 1662136795-269953 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000024, 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 --- Matthew Wilcox commented on v1 that it is just a slow path... but it is also just an easy patch :) If considered as useless, let me know and I'll drop it from my WIP list. Changes in v2: * (no code change) * synch with latest -next v1: https://lore.kernel.org/all/b4a47154877853cc64be3a35dcfd594d40cc2bce.1635975283.git.christophe.jaillet@wanadoo.fr/ --- mm/memremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memremap.c b/mm/memremap.c index 58b20c3c300b..25029a474d30 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -454,7 +454,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();