Message ID | 20230710204339.3554919-5-willy@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp62742vqm; Mon, 10 Jul 2023 13:46:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlF7PY8A65Tn/tq6rs8dFiP7nfbYOpuNUWXMCY8AwlxaGME2xtwl7rAw++Bzt3XVc/cK+FqK X-Received: by 2002:aa7:cd5a:0:b0:51d:a181:d78e with SMTP id v26-20020aa7cd5a000000b0051da181d78emr13887854edw.27.1689021963364; Mon, 10 Jul 2023 13:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689021963; cv=none; d=google.com; s=arc-20160816; b=i1rOjbvqK/wBgPh7qmJpkmw/ZFh6XlapbucjIP5zkZ6qSb9Rv+qvUKE/8CKO4HFe8I uN5H09pLvdnkpmy/Gpn6JOrpDwltU2ppvkbRFbhRDIMK+W6x5DJj4lxclqUL5mKCi1QE QjuzQg3kZ5RSXKBH/cGZLUg2veUeu5JgWZuSrfgnPfrBKdhA/0a/JVy7mAiwOltCtnKZ o8z9vlLJwmDPYXc4peU9gCCcuMF/a+4Zamk+OiGHkC/xolkNKVSY1erfWRoDOUNH8Zxw vGq+/4g2WoeWigyRQP4nHB/NM/lmOa8HyaQJToqldCkeWL+Fj+3pVin5h7tsvlpRf/sc mwrg== 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=aGQ2GHttWzJ+Nk3XqgE1qMHvrVsWPVFdkiJHip5axuY=; fh=Sw3T8HVdJ2SNfjr8InIonpqb67K59zr0WnKWm9/Paxo=; b=PlwYysg0QTeyg9EpyGm6pQ793LoRQnNCVBEdzd9DOIWpQS87Q1PhbGv6k/C8Pb9lNd YRfwlJzBelbEJUk5oNzoICKf1SP6Yr6i+WrcBBOKPEhD509p08wp0foo79zYYIZ16OO2 W/YV7ACn9wgNa2c9K1K6D419QdougKjZPnHyifjfrH3TuN+o0zjKpN2B0GnHPLgbD5n6 wphHkvcDSMAJOBMe6jTI31PMX8G7HtqlgyEAC6L1cKvWAQzg79pzWBxhiKJsBC5MUTSg C2Udx/sv/1MYrWJxkrDol09fgVCMocdjeGcqkxoTYMvKqE1vCrUKaovtsy16kVBho+A3 QlRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hnJ+NuJo; 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 f14-20020aa7d84e000000b0051a3fb6c050si332784eds.187.2023.07.10.13.45.39; Mon, 10 Jul 2023 13:46:03 -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=hnJ+NuJo; 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 S232158AbjGJUny (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Mon, 10 Jul 2023 16:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbjGJUnx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 10 Jul 2023 16:43:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88648E42; Mon, 10 Jul 2023 13:43:43 -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=aGQ2GHttWzJ+Nk3XqgE1qMHvrVsWPVFdkiJHip5axuY=; b=hnJ+NuJoHrGWnFQIHj5mwikc3Y f+ynvhq+4B/aEwy8FCPsgFshOQWVrWerLCxpuQBbeUnTyyz1X0U1Nqmo5shKPFaE2oMcX+P2NwLlm Hx6TYojYAi/XeM3hRmgQle7OUe0P4VkJ/Tt345eZQ34NwKAAmjbTCS8gD+17k8LCVxA5Uw2bKNxGK 2pBd5RYRhgtJ8EnVR9p6jVnQj2YQK6aJ3WeDQX+ZdDJGeDEqNezcYGk0XiuPM9EbIuKOpAhQmmDC0 VsWF9mJJKPpNAkiMNKSDiBc99gmwms10qIVtaqz0HiRd1zfD+6eV29vnvCGa1faKf7Aum+Nodg8wh gzQnfLWQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qIxjR-00EuoL-Fj; Mon, 10 Jul 2023 20:43:41 +0000 From: "Matthew Wilcox (Oracle)" <willy@infradead.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport <rppt@kernel.org>, Anshuman Khandual <anshuman.khandual@arm.com> Subject: [PATCH v5 04/38] mm: Add folio_flush_mapping() Date: Mon, 10 Jul 2023 21:43:05 +0100 Message-Id: <20230710204339.3554919-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230710204339.3554919-1-willy@infradead.org> References: <20230710204339.3554919-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1771067894395101444 X-GMAIL-MSGID: 1771067894395101444 |
Series |
New page table range API
|
|
Commit Message
Matthew Wilcox
July 10, 2023, 8:43 p.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> Acked-by: Mike Rapoport (IBM) <rppt@kernel.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> --- include/linux/pagemap.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
Comments
On Mon, 10 Jul 2023 21:43:05 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> 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> > +++ b/include/linux/pagemap.h > @@ -389,6 +389,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); > +} The name makes it sound like it flushes something. Wouldn't folio_flushable_mapping() be clearer? > static inline struct address_space *page_file_mapping(struct page *page) > { > return folio_file_mapping(page_folio(page)); > @@ -399,11 +419,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)); > }
On Mon, Jul 10, 2023 at 04:17:27PM -0700, Andrew Morton wrote: > On Mon, 10 Jul 2023 21:43:05 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote: > > +static inline struct address_space *folio_flush_mapping(struct folio *folio) > > +{ > > + if (unlikely(folio_test_swapcache(folio))) > > + return NULL; > > + > > + return folio_mapping(folio); > > +} > > The name makes it sound like it flushes something. Wouldn't > folio_flushable_mapping() be clearer? Yes; I wasn't a big fan of the name, but I wasn't a fan of perpetuating the page_file_mapping / page_mapping_file confusio either. Do you want me to send you a set of fixup patches, or will you run them through sed -i ? ;-)
On Tue, 11 Jul 2023 03:33:42 +0100 Matthew Wilcox <willy@infradead.org> wrote: > On Mon, Jul 10, 2023 at 04:17:27PM -0700, Andrew Morton wrote: > > On Mon, 10 Jul 2023 21:43:05 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote: > > > +static inline struct address_space *folio_flush_mapping(struct folio *folio) > > > +{ > > > + if (unlikely(folio_test_swapcache(folio))) > > > + return NULL; > > > + > > > + return folio_mapping(folio); > > > +} > > > > The name makes it sound like it flushes something. Wouldn't > > folio_flushable_mapping() be clearer? > > Yes; I wasn't a big fan of the name, but I wasn't a fan of perpetuating > the page_file_mapping / page_mapping_file confusio either. Do you want > me to send you a set of fixup patches, or will you run them through sed > -i ? ;-) I sedded.
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 69b99b61ed72..794e4e55dc38 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -389,6 +389,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)); @@ -399,11 +419,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)); } /**