From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
David Hildenbrand <david@redhat.com>
Subject: [RFC PATCH 1/3] mm: Constify folio_mapping() and swapcache_mapping()
Date: Mon, 10 Feb 2025 21:21:39 +0000 [thread overview]
Message-ID: <20250210212142.4002210-2-willy@infradead.org> (raw)
In-Reply-To: <20250210212142.4002210-1-willy@infradead.org>
Neither of these functions modify their argument; make it const
so the compiler knows this and can optimise accordingly.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 4 ++--
mm/debug.c | 2 +-
mm/swapfile.c | 2 +-
mm/util.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 47bfc6b1b632..8a9b2d201706 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -532,8 +532,8 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
#endif
}
-struct address_space *folio_mapping(struct folio *);
-struct address_space *swapcache_mapping(struct folio *);
+struct address_space *folio_mapping(const struct folio *);
+struct address_space *swapcache_mapping(const struct folio *);
/**
* folio_file_mapping - Find the mapping this folio belongs to.
diff --git a/mm/debug.c b/mm/debug.c
index 8d2acf432385..fa3d9686034c 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -67,7 +67,7 @@ static const char *page_type_name(unsigned int page_type)
return page_type_names[i];
}
-static void __dump_folio(struct folio *folio, struct page *page,
+static void __dump_folio(const struct folio *folio, struct page *page,
unsigned long pfn, unsigned long idx)
{
struct address_space *mapping = folio_mapping(folio);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6e867c16ea93..ccaed8c2f761 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3658,7 +3658,7 @@ struct swap_info_struct *swp_swap_info(swp_entry_t entry)
/*
* out-of-line methods to avoid include hell.
*/
-struct address_space *swapcache_mapping(struct folio *folio)
+struct address_space *swapcache_mapping(const struct folio *folio)
{
return swp_swap_info(folio->swap)->swap_file->f_mapping;
}
diff --git a/mm/util.c b/mm/util.c
index b6b9684a1438..682ecdb1b1c2 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -845,7 +845,7 @@ struct anon_vma *folio_anon_vma(const struct folio *folio)
* You can call this for folios which aren't in the swap cache or page
* cache and it will return NULL.
*/
-struct address_space *folio_mapping(struct folio *folio)
+struct address_space *folio_mapping(const struct folio *folio)
{
struct address_space *mapping;
--
2.47.2
next prev parent reply other threads:[~2025-02-10 21:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 21:21 [RFC PATCH 0/3] snapshot_page() Matthew Wilcox (Oracle)
2025-02-10 21:21 ` Matthew Wilcox (Oracle) [this message]
2025-02-11 20:04 ` [RFC PATCH 1/3] mm: Constify folio_mapping() and swapcache_mapping() David Hildenbrand
2025-02-12 8:56 ` Shivank Garg
2025-02-10 21:21 ` [RFC PATCH 2/3] mm: Create snapshot_page() Matthew Wilcox (Oracle)
2025-02-12 8:54 ` Shivank Garg
2025-02-14 21:18 ` David Hildenbrand
2025-04-17 13:52 ` David Hildenbrand
2025-02-10 21:21 ` [RFC PATCH 3/3] proc: Use snapshot_page() in kpageflags Matthew Wilcox (Oracle)
2025-02-11 21:17 ` Zi Yan
2025-02-12 8:57 ` Shivank Garg
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=20250210212142.4002210-2-willy@infradead.org \
--to=willy@infradead.org \
--cc=david@redhat.com \
--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