Message ID | 20230315051444.3229621-4-willy@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2144899wrd; Tue, 14 Mar 2023 22:15:45 -0700 (PDT) X-Google-Smtp-Source: AK7set+9htyLKDRJj0c+LCn+7DvqywCcuqhUrlHJLb9tfpIvW1EsNqmUao/Z1nuBJjOxmOkBLpVv X-Received: by 2002:a17:903:210b:b0:19e:baa6:5860 with SMTP id o11-20020a170903210b00b0019ebaa65860mr1290438ple.2.1678857345419; Tue, 14 Mar 2023 22:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678857345; cv=none; d=google.com; s=arc-20160816; b=AhRidDVyGWlrc/ofxf41ul+pNbeidflsKMbQCdwR+RQlvVXQhHdF0l8971/qPr/GiD gpHt8HwVnDFdZWOMCYMuOfzAF5aPwWzgfyAIn7hcTWUCC5tFtnkqU2bhhmPNYX27u/DQ DzVZiftjF75ORcTqjF42XeUdmr6yEgQ2DFTvQ6nBho2/NrWbTQ0eQbCFznskv1k3D+Yz C0uKZfUB8Eg+ZZbGvgRVSzSl6mfH2YOSTzaZvlS8oQB/gBNJKWi/Y/mNxvV6b57PLM3G O2j03uvo4e6aVA6NEqC/crx6JPnDYsFEqolpQXrCAIclDrP/Vz5YAjmpOmuP2xlcEyiP 0JjQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=n6Ti8OhlWeNjG2zsHJM+UjK+Z9Pmy+kwTwNJ+mNPVvs=; b=h5Y1JSF7g8zIyEGOy+xKfruNFVduUiwwhmMnBPoLwhbY9RNjY2WN8D+EHB184vJ0UR nNoDu3zZ0Q9/1AMjhDNdXZLd3vZ9dd3TMpOO4Aow28H7LkWqvwaY2HGZ0Ad/jjmGV/iK 3yCs5SLnyKGI9i9w8cgjB3o4KJoBizHv8vNEm+o2x74VvHuVEkIrPuurII2f4HPqCl36 v1plfsdQEaY7PnAKOyKGPXNT97EzqxdFMgqdy7aPNNNoU6rlYZTz2+Ci6jr2VtcS/Q4d WZzBbPs6XuGZX1TqTaa28QiYso4Lc+g8ocht0X6eBmvb4CmMHMRFlNwam7o8hKlg3IuW hZ5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="jXJA/lY+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf2-20020a170902b90200b0019b0b007981si3907935plb.531.2023.03.14.22.15.32; Tue, 14 Mar 2023 22:15:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="jXJA/lY+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230357AbjCOFOv (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Wed, 15 Mar 2023 01:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjCOFOt (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Mar 2023 01:14:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE24199C2; Tue, 14 Mar 2023 22:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=n6Ti8OhlWeNjG2zsHJM+UjK+Z9Pmy+kwTwNJ+mNPVvs=; b=jXJA/lY+mNfxjhnHMcPpOcZktl OP+tmmLUZQplcYMr969H3MlWVh4M8UbWKPP0xxgrWVRdnUZfOR6zLHYFG5wszll0o8pRkCNcOL1JY 16o+kcpPH9LNx1+TKFXHq8TGywKk7dGmxX4G+FSKewMk4lNllHqIF8s8FE+JBz4BDhl7hboF4RL+i CcXrAlV4h3+QyiJJ86OYjHScPv47+m2a0lvGzrAztGy1kUuS1eyTHhvuhboviz5liEIJSJiRABoHg aTUpEB1zZKKrLCb3K+tpcEVwrXjhbemDdSy63QoH8fw5+QNfVJStj6gMw88C4OF4r1znXsskP0ZQ2 +NIVpg0w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pcJTK-00DYAv-LY; Wed, 15 Mar 2023 05:14:46 +0000 From: "Matthew Wilcox (Oracle)" <willy@infradead.org> To: linux-arch@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 03/36] mm: Add folio_flush_mapping() Date: Wed, 15 Mar 2023 05:14:11 +0000 Message-Id: <20230315051444.3229621-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230315051444.3229621-1-willy@infradead.org> References: <20230315051444.3229621-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760409519724022509?= X-GMAIL-MSGID: =?utf-8?q?1760409519724022509?= |
Series |
New page table range API
|
|
Commit Message
Matthew Wilcox
March 15, 2023, 5:14 a.m. UTC
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) <willy@infradead.org>
---
include/linux/pagemap.h | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
Comments
On Wed, Mar 15, 2023 at 05:14:11AM +0000, 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) <willy@infradead.org> Acked-by: Mike Rapoport (IBM) <rppt@kernel.org> > --- > 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)); > } > > /** > -- > 2.39.2 >
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) <willy@infradead.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > 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)); > } > > /**
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)); } /**