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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D00EC77B7C for ; Thu, 25 May 2023 02:35:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCF3C6B007D; Wed, 24 May 2023 22:35:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7FB36B007E; Wed, 24 May 2023 22:35:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6EC7900002; Wed, 24 May 2023 22:35:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B364E6B007D for ; Wed, 24 May 2023 22:35:24 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6DFFD40ABF for ; Thu, 25 May 2023 02:35:24 +0000 (UTC) X-FDA: 80827210968.09.60EFF8C Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id A9C3820010 for ; Thu, 25 May 2023 02:35:22 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684982122; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w4Ju90t7/n+A9QnjB9UFGFyDMupmYJ3YbO05CpRsr84=; b=TDNfPgEUvQ5PX9oiU8eB1YHDrN2RizP1/KMA5ZucjQv4PvuV5jtT8qBjpcWtvt/tM6YScM ZeIzEWc2uOVohTUUiobRyGe/0u3MlmAxEId8pEmxzAo66cu6CDnuuccwv6yRU1MFAjy+03 rVh/rB6apLxNNrfRGPMqhiuLmhCY0N4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684982122; a=rsa-sha256; cv=none; b=8JykDeZo8KnYuEDzerg5aB6VpcBfh0IY7PY0oL+fif8eMsbB/YrLAvVyaCn/3pmftZb2id 6S67lxxCLuxiIzUZbAQy6/BSzfoA3RKTx63Rdp4CI6HYFVCuM0Yz/hzw4vfNLBNdu83FtB g+4gQoiBLIdqbe2aRmu5hDNoT8XXfiw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CD5061042; Wed, 24 May 2023 19:36:06 -0700 (PDT) Received: from [10.162.43.6] (unknown [10.162.43.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7AC6F3F762; Wed, 24 May 2023 19:35:20 -0700 (PDT) Message-ID: <0729b811-92f2-13a7-5f97-8ea249c88adf@arm.com> Date: Thu, 25 May 2023 08:05:17 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4 03/36] mm: Add folio_flush_mapping() Content-Language: en-US To: "Matthew Wilcox (Oracle)" , linux-arch@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230315051444.3229621-1-willy@infradead.org> <20230315051444.3229621-4-willy@infradead.org> From: Anshuman Khandual In-Reply-To: <20230315051444.3229621-4-willy@infradead.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: A9C3820010 X-Rspam-User: X-Stat-Signature: 8r7afsn47hzfqy9hrrfh9am7xgwigeto X-Rspamd-Server: rspam03 X-HE-Tag: 1684982122-986130 X-HE-Meta: U2FsdGVkX1+ODuH4cWHS0alvbCFXvNO8SGDp8vU9OI+8Chqf4hu715ObAqERNvj+0x085NBN2qIUdfl9uje0ZI22qbDPQmUF68RApcrT90FD2xILU8FpZ7j/MjOrGmF50sy1hsCk9bj9ZRUlEUiCypq7hl1urk3sYZ5VaqwRHNZQbARAIg35SvA0hyfWwWlP595oeCFyXOh5HRgnWZwUKt/pKScX5xNFGygCwYUyuii14ranlrTkBFt2Re5sr8Sw3ug8V07dO2waQ9rC7euD0NJXFiVYBX61iFv5fB0hSOx4vRpp8L7KntTArcnWIH+4imp4xDf0DxITi7DUPrvSIbjBnvzaSGDrtxkbC5M53mscRYQPVkaKUO5o8sH2guq8uT/uORMzGDyYdfYx7ruLJsk6CuZxYh0xX8VBbkyhhagDlIbZ3Pi4iHEayIG/TFanSqm6sQaTlF295tq7b3bv9D77TaEhcRQn/EcjIlawycXtKZJ4v1C9r6A3XSpk3Rq6a8VOM4zqWeu28FW0MGIjY64iaGmunOq3EZsgJk3aAIkuxE7n2CCD2jeqQbXllbyd85HuXjKAzEsRHqgTT/D5hhJnyR7scs8Kr8uLvEVxQ1Eg3XX2ZO7SiGYfRAketCM3stnG74KHCAkZmGEz9E8ZLsJfCF1Sg8MJpsjJwpBJtmQCp+5MLySpdFEnUTFKCnjINaRgkn2hJ9wKF6sd90QXK9MqaS9hQmgzqNPkVOuHiEzYH64mmFqd6zPSGpWiX0b4DWlb7F59KuGKzYFBJjurnMkGQI3V6Al18GJgkiCxdxq2pO2J9+oDgWCPveuPI0mp851gaXt5lDATppivfA3ArxYxbY7rHpoIUkEaFakFE2tT9SiYz/8X78bhDBJImcA/hV74dx507FMjENwz9SCdaojdkzrvsKJTFrN+keqPzj5ev8+yaWySrcdQHKg83FHpbwBKzwJz/OGrVNoMc11 Diwb062T RYzu8OgstA39LOHQDtVa9RJc1pQelGBV9DiuwHQCT5N6gLuNerOwQLMQSSUUwkImQvER/pgDI0kbHyULmB7+QQuW3hqjoB27NaY8kgs2yPOnJ4mVE1P8GkvCYZ4IzvXdDrCrKGFVVaPnOPGIrJFZk7Kk878MYg15gCmvaWp8VFTTY6wkJFuzSoCPSDCtNtaEN/MvP9HXI3sajPCmUZueOYUT1kCizuv9g5fuxKLan3SxaJ1CO2mSmJX08Hz/doe7UkBIxoTQ3OktR8zOn2088jOP1Wg== 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 3/15/23 10:44, Matthew Wilcox (Oracle) wrote: > This is the folio equivalent of page_mapping_file(), but rename it > to make it clear that it's very different from page_file_mapping(). > Theoretically, there's nothing flush-only about it, but there are no > other users today, and I doubt there will be; it's almost always more > useful to know the swapfile's mapping or the swapcache's mapping. > > Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Anshuman Khandual > --- > include/linux/pagemap.h | 26 +++++++++++++++++++++----- > 1 file changed, 21 insertions(+), 5 deletions(-) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index a56308a9d1a4..e56c2023aa0e 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -369,6 +369,26 @@ static inline struct address_space *folio_file_mapping(struct folio *folio) > return folio->mapping; > } > > +/** > + * folio_flush_mapping - Find the file mapping this folio belongs to. > + * @folio: The folio. > + * > + * For folios which are in the page cache, return the mapping that this > + * page belongs to. Anonymous folios return NULL, even if they're in > + * the swap cache. Other kinds of folio also return NULL. > + * > + * This is ONLY used by architecture cache flushing code. If you aren't > + * writing cache flushing code, you want either folio_mapping() or > + * folio_file_mapping(). > + */ > +static inline struct address_space *folio_flush_mapping(struct folio *folio) > +{ > + if (unlikely(folio_test_swapcache(folio))) > + return NULL; > + > + return folio_mapping(folio); > +} > + > static inline struct address_space *page_file_mapping(struct page *page) > { > return folio_file_mapping(page_folio(page)); > @@ -379,11 +399,7 @@ static inline struct address_space *page_file_mapping(struct page *page) > */ > static inline struct address_space *page_mapping_file(struct page *page) > { > - struct folio *folio = page_folio(page); > - > - if (unlikely(folio_test_swapcache(folio))) > - return NULL; > - return folio_mapping(folio); > + return folio_flush_mapping(page_folio(page)); > } > > /**