linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 02/11] mm: Add put_folio
Date: Tue,  8 Dec 2020 19:46:44 +0000	[thread overview]
Message-ID: <20201208194653.19180-3-willy@infradead.org> (raw)
In-Reply-To: <20201208194653.19180-1-willy@infradead.org>

If we know we have a folio, we can call put_folio() instead of put_page()
and save the overhead of calling compound_head().  Also skips the
devmap checks.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/mm.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7db9a10f084b..80d38cc9561c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1189,9 +1189,15 @@ static inline __must_check bool try_get_page(struct page *page)
 	return true;
 }
 
+static inline void put_folio(struct folio *folio)
+{
+	if (put_page_testzero(&folio->page))
+		__put_page(&folio->page);
+}
+
 static inline void put_page(struct page *page)
 {
-	page = compound_head(page);
+	struct folio *folio = page_folio(page);
 
 	/*
 	 * For devmap managed pages we need to catch refcount transition from
@@ -1199,13 +1205,12 @@ static inline void put_page(struct page *page)
 	 * need to inform the device driver through callback. See
 	 * include/linux/memremap.h and HMM for details.
 	 */
-	if (page_is_devmap_managed(page)) {
-		put_devmap_managed_page(page);
+	if (page_is_devmap_managed(&folio->page)) {
+		put_devmap_managed_page(&folio->page);
 		return;
 	}
 
-	if (put_page_testzero(page))
-		__put_page(page);
+	put_folio(folio);
 }
 
 /*
-- 
2.29.2



  parent reply	other threads:[~2020-12-08 19:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 19:46 [RFC PATCH 00/11] Page folios Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 01/11] mm: Introduce struct folio Matthew Wilcox (Oracle)
2020-12-08 19:46 ` Matthew Wilcox (Oracle) [this message]
2020-12-08 19:46 ` [RFC PATCH 03/11] mm: Add get_folio Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 04/11] mm: Create FolioFlags Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 05/11] mm: Add unlock_folio Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 06/11] mm: Add lock_folio Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 07/11] mm: Add lock_folio_killable Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 08/11] mm/filemap: Convert end_page_writeback to use a folio Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 09/11] mm/filemap: Convert mapping_get_entry and pagecache_get_page to folio Matthew Wilcox (Oracle)
2020-12-08 19:46 ` [RFC PATCH 10/11] mm/filemap: Add folio_add_to_page_cache Matthew Wilcox (Oracle)
2020-12-11  8:32   ` Nikolay Borisov
2020-12-08 19:46 ` [RFC PATCH 11/11] mm/swap: Convert rotate_reclaimable_page to folio Matthew Wilcox (Oracle)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201208194653.19180-3-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).