From mboxrd@z Thu Jan 1 00:00:00 1970 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 140B3C433F5 for ; Wed, 3 Nov 2021 22:03:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 93F3D610EA for ; Wed, 3 Nov 2021 22:03:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 93F3D610EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2A48C940007; Wed, 3 Nov 2021 18:03:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 228656B0072; Wed, 3 Nov 2021 18:03:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F16A940007; Wed, 3 Nov 2021 18:03:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id EF73D6B006C for ; Wed, 3 Nov 2021 18:03:38 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4454374BC0 for ; Wed, 3 Nov 2021 22:03:38 +0000 (UTC) X-FDA: 78768996516.03.26BF881 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id AFF0DD0000A8 for ; Wed, 3 Nov 2021 22:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=XfqOcxMTNpce/H2cBChjbLc+Fz6a0SnCl4wsO4N8gnY=; b=l9KDMuDTY6G4Q8mwbSHvRaQUC2 x9bxYxR/3FGTLD3rIADdw/By9FKQUhsioU96mw/u4mWT5P0UFJVRj80k2tJ4tqfQcKpLN/dyHCuPh zdg0pKopSL8ffZPqLNf2w9jlAP+B7aSsu0mrjkXbqRGiV51iEswNzmtj3UfBSyvSLW93cuNVPXVl4 gHV90gdVY1VEKlxDV13Nm5OZnVqtDrGJaaaUscj46xZbQu1IyoVGMHe0lAQuDWLfHJpeEQt4x46uP 8LFt7NOvYVtY50ixpzCeM0Kibam+0BoOv8ocZc+kmfdvoQHegXFbji4RjaxjdHFLu4RVGP8u+y1HQ mSYb6Qew==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1miOKJ-005Ufv-2C; Wed, 03 Nov 2021 22:02:15 +0000 Date: Wed, 3 Nov 2021 22:01:47 +0000 From: Matthew Wilcox To: Christophe JAILLET Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] mm/mremap_pages: Save a few cycles in 'get_dev_pagemap()' Message-ID: References: <5da6ef93-97c6-6165-8a73-eb1050589ba7@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <5da6ef93-97c6-6165-8a73-eb1050589ba7@wanadoo.fr> X-Rspamd-Queue-Id: AFF0DD0000A8 X-Stat-Signature: 3p3bf4c94xi6ywcd7hcnrw9jdsrhw6h3 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=l9KDMuDT; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam01 X-HE-Tag: 1635977007-38838 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 03, 2021 at 10:54:09PM +0100, Christophe JAILLET wrote: > Le 03/11/2021 =E0 22:41, Matthew Wilcox a =E9crit=A0: > > On Wed, Nov 03, 2021 at 10:35:34PM +0100, Christophe JAILLET wrote: > > > Use 'percpu_ref_tryget_live_rcu()' instead of 'percpu_ref_tryget_li= ve()' to > > > save a few cycles when it is known that the rcu lock is already > > > taken/released. > >=20 > > If this is really important, we can add an __xa_load() which doesn't > > take the RCU read lock. >=20 > There are a few: > rcu_read_lock(); > mem =3D xa_load(...); > rcu_read_unlock(); > patterns here and there. If that's all they are, then the rcu_read_lock() and unlock can be deleted. if they're actually rcu_read_lock() mem =3D xa_load(...); try_get_ref(mem); rcu_read_unlock(); then of course they can't be. > I don't have any numbers of if saving some rcu_read_lock/rcu_read_unloc= k > would be useful in these cases. >=20 > The only numbers I have are in [1]. >=20 > [1]: https://lore.kernel.org/linux-kernel/cover.1634822969.git.asml.sil= ence@gmail.com/ It may not be worth hyperoptimising the slow path like this patch ...