* [PATCH 0/6] Remove page_mapping()
@ 2024-04-23 22:55 Matthew Wilcox (Oracle)
2024-04-23 22:55 ` [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio Matthew Wilcox (Oracle)
` (5 more replies)
0 siblings, 6 replies; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
There are only a few users left. Convert them all to either call
folio_mapping() or just use folio->mapping directly.
Matthew Wilcox (Oracle) (6):
fscrypt: Convert bh_get_inode_and_lblk_num to use a folio
f2fs: Convert f2fs_clear_page_cache_dirty_tag to use a folio
memory-failure: Remove calls to page_mapping()
migrate: Expand the use of folio in __migrate_device_pages()
userfault; Expand folio use in mfill_atomic_install_pte()
mm: Remove page_mapping()
fs/crypto/inline_crypt.c | 6 +++---
fs/f2fs/data.c | 5 +++--
include/linux/pagemap.h | 1 -
mm/folio-compat.c | 6 ------
mm/memory-failure.c | 6 ++++--
mm/migrate_device.c | 13 +++++--------
mm/userfaultfd.c | 5 ++---
7 files changed, 17 insertions(+), 25 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
@ 2024-04-23 22:55 ` Matthew Wilcox (Oracle)
2024-04-23 23:34 ` Eric Biggers
2024-04-24 11:53 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 2/6] f2fs: Convert f2fs_clear_page_cache_dirty_tag " Matthew Wilcox (Oracle)
` (4 subsequent siblings)
5 siblings, 2 replies; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
Remove uses of page->index, page_mapping() and b_page. Saves a call
to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/crypto/inline_crypt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c
index b4002aea7cdb..40de69860dcf 100644
--- a/fs/crypto/inline_crypt.c
+++ b/fs/crypto/inline_crypt.c
@@ -284,7 +284,7 @@ static bool bh_get_inode_and_lblk_num(const struct buffer_head *bh,
const struct inode **inode_ret,
u64 *lblk_num_ret)
{
- struct page *page = bh->b_page;
+ struct folio *folio = bh->b_folio;
const struct address_space *mapping;
const struct inode *inode;
@@ -292,13 +292,13 @@ static bool bh_get_inode_and_lblk_num(const struct buffer_head *bh,
* The ext4 journal (jbd2) can submit a buffer_head it directly created
* for a non-pagecache page. fscrypt doesn't care about these.
*/
- mapping = page_mapping(page);
+ mapping = folio_mapping(folio);
if (!mapping)
return false;
inode = mapping->host;
*inode_ret = inode;
- *lblk_num_ret = ((u64)page->index << (PAGE_SHIFT - inode->i_blkbits)) +
+ *lblk_num_ret = ((u64)folio->index << (PAGE_SHIFT - inode->i_blkbits)) +
(bh_offset(bh) >> inode->i_blkbits);
return true;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/6] f2fs: Convert f2fs_clear_page_cache_dirty_tag to use a folio
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
2024-04-23 22:55 ` [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio Matthew Wilcox (Oracle)
@ 2024-04-23 22:55 ` Matthew Wilcox (Oracle)
2024-04-24 11:53 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 3/6] memory-failure: Remove calls to page_mapping() Matthew Wilcox (Oracle)
` (3 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
Removes uses of page_mapping() and page_index().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/f2fs/data.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 5d641fac02ba..9f74c867d790 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -4100,11 +4100,12 @@ const struct address_space_operations f2fs_dblock_aops = {
void f2fs_clear_page_cache_dirty_tag(struct page *page)
{
- struct address_space *mapping = page_mapping(page);
+ struct folio *folio = page_folio(page);
+ struct address_space *mapping = folio->mapping;
unsigned long flags;
xa_lock_irqsave(&mapping->i_pages, flags);
- __xa_clear_mark(&mapping->i_pages, page_index(page),
+ __xa_clear_mark(&mapping->i_pages, folio->index,
PAGECACHE_TAG_DIRTY);
xa_unlock_irqrestore(&mapping->i_pages, flags);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/6] memory-failure: Remove calls to page_mapping()
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
2024-04-23 22:55 ` [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio Matthew Wilcox (Oracle)
2024-04-23 22:55 ` [PATCH 2/6] f2fs: Convert f2fs_clear_page_cache_dirty_tag " Matthew Wilcox (Oracle)
@ 2024-04-23 22:55 ` Matthew Wilcox (Oracle)
2024-04-23 23:52 ` Sidhartha Kumar
` (2 more replies)
2024-04-23 22:55 ` [PATCH 4/6] migrate: Expand the use of folio in __migrate_device_pages() Matthew Wilcox (Oracle)
` (2 subsequent siblings)
5 siblings, 3 replies; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
This is mostly just inlining page_mapping() into the two callers.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory-failure.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e065dd9be21e..62aa3db17854 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -216,6 +216,7 @@ EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value);
static int hwpoison_filter_dev(struct page *p)
{
+ struct folio *folio = page_folio(p);
struct address_space *mapping;
dev_t dev;
@@ -223,7 +224,7 @@ static int hwpoison_filter_dev(struct page *p)
hwpoison_filter_dev_minor == ~0U)
return 0;
- mapping = page_mapping(p);
+ mapping = folio_mapping(folio);
if (mapping == NULL || mapping->host == NULL)
return -EINVAL;
@@ -1090,7 +1091,8 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
*/
static int me_pagecache_dirty(struct page_state *ps, struct page *p)
{
- struct address_space *mapping = page_mapping(p);
+ struct folio *folio = page_folio(p);
+ struct address_space *mapping = folio_mapping(folio);
/* TBD: print more information about the file. */
if (mapping) {
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 4/6] migrate: Expand the use of folio in __migrate_device_pages()
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2024-04-23 22:55 ` [PATCH 3/6] memory-failure: Remove calls to page_mapping() Matthew Wilcox (Oracle)
@ 2024-04-23 22:55 ` Matthew Wilcox (Oracle)
2024-04-24 11:54 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte() Matthew Wilcox (Oracle)
2024-04-23 22:55 ` [PATCH 6/6] mm: Remove page_mapping() Matthew Wilcox (Oracle)
5 siblings, 1 reply; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
Removes a few calls to compound_head() and a call to page_mapping().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/migrate_device.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index a68616c1965f..aecc71972a87 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -692,6 +692,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
struct page *newpage = migrate_pfn_to_page(dst_pfns[i]);
struct page *page = migrate_pfn_to_page(src_pfns[i]);
struct address_space *mapping;
+ struct folio *folio;
int r;
if (!newpage) {
@@ -726,15 +727,12 @@ static void __migrate_device_pages(unsigned long *src_pfns,
continue;
}
- mapping = page_mapping(page);
+ folio = page_folio(page);
+ mapping = folio_mapping(folio);
if (is_device_private_page(newpage) ||
is_device_coherent_page(newpage)) {
if (mapping) {
- struct folio *folio;
-
- folio = page_folio(page);
-
/*
* For now only support anonymous memory migrating to
* device private or coherent memory.
@@ -757,11 +755,10 @@ static void __migrate_device_pages(unsigned long *src_pfns,
if (migrate && migrate->fault_page == page)
r = migrate_folio_extra(mapping, page_folio(newpage),
- page_folio(page),
- MIGRATE_SYNC_NO_COPY, 1);
+ folio, MIGRATE_SYNC_NO_COPY, 1);
else
r = migrate_folio(mapping, page_folio(newpage),
- page_folio(page), MIGRATE_SYNC_NO_COPY);
+ folio, MIGRATE_SYNC_NO_COPY);
if (r != MIGRATEPAGE_SUCCESS)
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte()
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2024-04-23 22:55 ` [PATCH 4/6] migrate: Expand the use of folio in __migrate_device_pages() Matthew Wilcox (Oracle)
@ 2024-04-23 22:55 ` Matthew Wilcox (Oracle)
2024-04-24 11:55 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 6/6] mm: Remove page_mapping() Matthew Wilcox (Oracle)
5 siblings, 1 reply; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
Call page_folio() a little earlier so we can use folio_mapping()
instead of page_mapping(), saving a call to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/userfaultfd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index d9dcc7d71a39..e6486923263c 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -180,9 +180,9 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd,
pte_t _dst_pte, *dst_pte;
bool writable = dst_vma->vm_flags & VM_WRITE;
bool vm_shared = dst_vma->vm_flags & VM_SHARED;
- bool page_in_cache = page_mapping(page);
spinlock_t *ptl;
- struct folio *folio;
+ struct folio *folio = page_folio(page);
+ bool page_in_cache = folio_mapping(folio);
_dst_pte = mk_pte(page, dst_vma->vm_page_prot);
_dst_pte = pte_mkdirty(_dst_pte);
@@ -212,7 +212,6 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd,
if (!pte_none_mostly(ptep_get(dst_pte)))
goto out_unlock;
- folio = page_folio(page);
if (page_in_cache) {
/* Usually, cache pages are already added to LRU */
if (newly_allocated)
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 6/6] mm: Remove page_mapping()
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2024-04-23 22:55 ` [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte() Matthew Wilcox (Oracle)
@ 2024-04-23 22:55 ` Matthew Wilcox (Oracle)
2024-04-24 11:55 ` David Hildenbrand
5 siblings, 1 reply; 18+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-23 22:55 UTC (permalink / raw)
To: Andrew Morton, linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-fscrypt, linux-f2fs-devel
All callers are now converted, delete this compatibility wrapper.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 1 -
mm/folio-compat.c | 6 ------
2 files changed, 7 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index b6f14e9a2d98..941f7ed714b9 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -399,7 +399,6 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
#endif
}
-struct address_space *page_mapping(struct page *);
struct address_space *folio_mapping(struct folio *);
struct address_space *swapcache_mapping(struct folio *);
diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index f31e0ce65b11..f05906006b3c 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -10,12 +10,6 @@
#include <linux/swap.h>
#include "internal.h"
-struct address_space *page_mapping(struct page *page)
-{
- return folio_mapping(page_folio(page));
-}
-EXPORT_SYMBOL(page_mapping);
-
void unlock_page(struct page *page)
{
return folio_unlock(page_folio(page));
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio
2024-04-23 22:55 ` [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio Matthew Wilcox (Oracle)
@ 2024-04-23 23:34 ` Eric Biggers
2024-04-24 11:53 ` David Hildenbrand
1 sibling, 0 replies; 18+ messages in thread
From: Eric Biggers @ 2024-04-23 23:34 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Andrew Morton, linux-mm, linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On Tue, Apr 23, 2024 at 11:55:32PM +0100, Matthew Wilcox (Oracle) wrote:
> Remove uses of page->index, page_mapping() and b_page. Saves a call
> to compound_head().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/crypto/inline_crypt.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c
> index b4002aea7cdb..40de69860dcf 100644
> --- a/fs/crypto/inline_crypt.c
> +++ b/fs/crypto/inline_crypt.c
> @@ -284,7 +284,7 @@ static bool bh_get_inode_and_lblk_num(const struct buffer_head *bh,
> const struct inode **inode_ret,
> u64 *lblk_num_ret)
> {
> - struct page *page = bh->b_page;
> + struct folio *folio = bh->b_folio;
> const struct address_space *mapping;
> const struct inode *inode;
>
> @@ -292,13 +292,13 @@ static bool bh_get_inode_and_lblk_num(const struct buffer_head *bh,
> * The ext4 journal (jbd2) can submit a buffer_head it directly created
> * for a non-pagecache page. fscrypt doesn't care about these.
> */
> - mapping = page_mapping(page);
> + mapping = folio_mapping(folio);
> if (!mapping)
> return false;
> inode = mapping->host;
>
> *inode_ret = inode;
> - *lblk_num_ret = ((u64)page->index << (PAGE_SHIFT - inode->i_blkbits)) +
> + *lblk_num_ret = ((u64)folio->index << (PAGE_SHIFT - inode->i_blkbits)) +
> (bh_offset(bh) >> inode->i_blkbits);
> return true;
> }
Reviewed-by: Eric Biggers <ebiggers@google.com>
- Eric
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] memory-failure: Remove calls to page_mapping()
2024-04-23 22:55 ` [PATCH 3/6] memory-failure: Remove calls to page_mapping() Matthew Wilcox (Oracle)
@ 2024-04-23 23:52 ` Sidhartha Kumar
2024-04-24 11:54 ` David Hildenbrand
2024-04-25 6:21 ` Miaohe Lin
2 siblings, 0 replies; 18+ messages in thread
From: Sidhartha Kumar @ 2024-04-23 23:52 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 4/23/24 3:55 PM, Matthew Wilcox (Oracle) wrote:
> This is mostly just inlining page_mapping() into the two callers.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> mm/memory-failure.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index e065dd9be21e..62aa3db17854 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -216,6 +216,7 @@ EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value);
>
> static int hwpoison_filter_dev(struct page *p)
> {
> + struct folio *folio = page_folio(p);
> struct address_space *mapping;
> dev_t dev;
>
> @@ -223,7 +224,7 @@ static int hwpoison_filter_dev(struct page *p)
> hwpoison_filter_dev_minor == ~0U)
> return 0;
>
> - mapping = page_mapping(p);
> + mapping = folio_mapping(folio);
> if (mapping == NULL || mapping->host == NULL)
> return -EINVAL;
>
> @@ -1090,7 +1091,8 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
> */
> static int me_pagecache_dirty(struct page_state *ps, struct page *p)
> {
> - struct address_space *mapping = page_mapping(p);
> + struct folio *folio = page_folio(p);
> + struct address_space *mapping = folio_mapping(folio);
>
> /* TBD: print more information about the file. */
> if (mapping) {
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio
2024-04-23 22:55 ` [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio Matthew Wilcox (Oracle)
2024-04-23 23:34 ` Eric Biggers
@ 2024-04-24 11:53 ` David Hildenbrand
1 sibling, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2024-04-24 11:53 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> Remove uses of page->index, page_mapping() and b_page. Saves a call
> to compound_head().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/6] f2fs: Convert f2fs_clear_page_cache_dirty_tag to use a folio
2024-04-23 22:55 ` [PATCH 2/6] f2fs: Convert f2fs_clear_page_cache_dirty_tag " Matthew Wilcox (Oracle)
@ 2024-04-24 11:53 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2024-04-24 11:53 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> Removes uses of page_mapping() and page_index().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/f2fs/data.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 5d641fac02ba..9f74c867d790 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -4100,11 +4100,12 @@ const struct address_space_operations f2fs_dblock_aops = {
>
> void f2fs_clear_page_cache_dirty_tag(struct page *page)
> {
> - struct address_space *mapping = page_mapping(page);
> + struct folio *folio = page_folio(page);
> + struct address_space *mapping = folio->mapping;
> unsigned long flags;
>
> xa_lock_irqsave(&mapping->i_pages, flags);
> - __xa_clear_mark(&mapping->i_pages, page_index(page),
> + __xa_clear_mark(&mapping->i_pages, folio->index,
> PAGECACHE_TAG_DIRTY);
> xa_unlock_irqrestore(&mapping->i_pages, flags);
> }
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] memory-failure: Remove calls to page_mapping()
2024-04-23 22:55 ` [PATCH 3/6] memory-failure: Remove calls to page_mapping() Matthew Wilcox (Oracle)
2024-04-23 23:52 ` Sidhartha Kumar
@ 2024-04-24 11:54 ` David Hildenbrand
2024-04-25 6:21 ` Miaohe Lin
2 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2024-04-24 11:54 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> This is mostly just inlining page_mapping() into the two callers.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/6] migrate: Expand the use of folio in __migrate_device_pages()
2024-04-23 22:55 ` [PATCH 4/6] migrate: Expand the use of folio in __migrate_device_pages() Matthew Wilcox (Oracle)
@ 2024-04-24 11:54 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2024-04-24 11:54 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> Removes a few calls to compound_head() and a call to page_mapping().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte()
2024-04-23 22:55 ` [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte() Matthew Wilcox (Oracle)
@ 2024-04-24 11:55 ` David Hildenbrand
0 siblings, 0 replies; 18+ messages in thread
From: David Hildenbrand @ 2024-04-24 11:55 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> Call page_folio() a little earlier so we can use folio_mapping()
> instead of page_mapping(), saving a call to compound_head().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/6] mm: Remove page_mapping()
2024-04-23 22:55 ` [PATCH 6/6] mm: Remove page_mapping() Matthew Wilcox (Oracle)
@ 2024-04-24 11:55 ` David Hildenbrand
2024-04-24 23:34 ` Andrew Morton
0 siblings, 1 reply; 18+ messages in thread
From: David Hildenbrand @ 2024-04-24 11:55 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton, linux-mm
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> All callers are now converted, delete this compatibility wrapper.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/pagemap.h | 1 -
> mm/folio-compat.c | 6 ------
> 2 files changed, 7 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index b6f14e9a2d98..941f7ed714b9 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -399,7 +399,6 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
> #endif
> }
>
> -struct address_space *page_mapping(struct page *);
> struct address_space *folio_mapping(struct folio *);
> struct address_space *swapcache_mapping(struct folio *);
>
> diff --git a/mm/folio-compat.c b/mm/folio-compat.c
> index f31e0ce65b11..f05906006b3c 100644
> --- a/mm/folio-compat.c
> +++ b/mm/folio-compat.c
> @@ -10,12 +10,6 @@
> #include <linux/swap.h>
> #include "internal.h"
>
> -struct address_space *page_mapping(struct page *page)
> -{
> - return folio_mapping(page_folio(page));
> -}
> -EXPORT_SYMBOL(page_mapping);
> -
> void unlock_page(struct page *page)
> {
> return folio_unlock(page_folio(page));
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/6] mm: Remove page_mapping()
2024-04-24 11:55 ` David Hildenbrand
@ 2024-04-24 23:34 ` Andrew Morton
2024-04-24 23:59 ` Matthew Wilcox
0 siblings, 1 reply; 18+ messages in thread
From: Andrew Morton @ 2024-04-24 23:34 UTC (permalink / raw)
To: David Hildenbrand
Cc: Matthew Wilcox (Oracle),
linux-mm, linux-fsdevel, linux-fscrypt, linux-f2fs-devel
On Wed, 24 Apr 2024 13:55:32 +0200 David Hildenbrand <david@redhat.com> wrote:
> On 24.04.24 00:55, Matthew Wilcox (Oracle) wrote:
> > All callers are now converted, delete this compatibility wrapper.
> >
For some reason,
mm/hugetlb.c: In function 'hugetlb_page_mapping_lock_write':
mm/hugetlb.c:2164:41: error: implicit declaration of function 'page_mapping'; did you mean 'page_mapped'? [-Werror=implicit-function-declaration]
2164 | struct address_space *mapping = page_mapping(hpage);
| ^~~~~~~~~~~~
| page_mapped
mm/hugetlb.c:2164:41: error: initialization of 'struct address_space *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
I'll disable "mm: Remove page_mapping()" pending review of the below,
please.
From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm: convert hugetlb_page_mapping_lock_write() to hugetlb_folio_mapping_lock_write
Date: Wed Apr 24 04:20:30 PM PDT 2024
Convert this to use folios, so we can remove page_mapping()
Cc: David Hildenbrand <david@redhat.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/hugetlb.h | 6 +++---
mm/hugetlb.c | 6 +++---
mm/memory-failure.c | 4 ++--
mm/migrate.c | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
--- a/mm/hugetlb.c~mm-convert-hugetlb_page_mapping_lock_write-to-hugetlb_folio_mapping_lock_write
+++ a/mm/hugetlb.c
@@ -2155,13 +2155,13 @@ static bool prep_compound_gigantic_folio
/*
* Find and lock address space (mapping) in write mode.
*
- * Upon entry, the page is locked which means that page_mapping() is
+ * Upon entry, the folio is locked which means that folio_mapping() is
* stable. Due to locking order, we can only trylock_write. If we can
* not get the lock, simply return NULL to caller.
*/
-struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage)
+struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio)
{
- struct address_space *mapping = page_mapping(hpage);
+ struct address_space *mapping = folio_mapping(folio);
if (!mapping)
return mapping;
--- a/mm/memory-failure.c~mm-convert-hugetlb_page_mapping_lock_write-to-hugetlb_folio_mapping_lock_write
+++ a/mm/memory-failure.c
@@ -1595,7 +1595,7 @@ static bool hwpoison_user_mappings(struc
* XXX: the dirty test could be racy: set_page_dirty() may not always
* be called inside page lock (it's recommended but not enforced).
*/
- mapping = page_mapping(hpage);
+ mapping = folio_mapping(folio);
if (!(flags & MF_MUST_KILL) && !PageDirty(hpage) && mapping &&
mapping_can_writeback(mapping)) {
if (page_mkclean(hpage)) {
@@ -1622,7 +1622,7 @@ static bool hwpoison_user_mappings(struc
* TTU_RMAP_LOCKED to indicate we have taken the lock
* at this higher level.
*/
- mapping = hugetlb_page_mapping_lock_write(hpage);
+ mapping = hugetlb_folio_mapping_lock_write(folio);
if (mapping) {
try_to_unmap(folio, ttu|TTU_RMAP_LOCKED);
i_mmap_unlock_write(mapping);
--- a/include/linux/hugetlb.h~mm-convert-hugetlb_page_mapping_lock_write-to-hugetlb_folio_mapping_lock_write
+++ a/include/linux/hugetlb.h
@@ -178,7 +178,7 @@ bool hugetlbfs_pagecache_present(struct
struct vm_area_struct *vma,
unsigned long address);
-struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage);
+struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio);
extern int sysctl_hugetlb_shm_group;
extern struct list_head huge_boot_pages[MAX_NUMNODES];
@@ -297,8 +297,8 @@ static inline unsigned long hugetlb_tota
return 0;
}
-static inline struct address_space *hugetlb_page_mapping_lock_write(
- struct page *hpage)
+static inline struct address_space *hugetlb_folio_mapping_lock_write(
+ struct folio *folio)
{
return NULL;
}
--- a/mm/migrate.c~mm-convert-hugetlb_page_mapping_lock_write-to-hugetlb_folio_mapping_lock_write
+++ a/mm/migrate.c
@@ -1425,7 +1425,7 @@ static int unmap_and_move_huge_page(new_
* semaphore in write mode here and set TTU_RMAP_LOCKED
* to let lower levels know we have taken the lock.
*/
- mapping = hugetlb_page_mapping_lock_write(&src->page);
+ mapping = hugetlb_folio_mapping_lock_write(src);
if (unlikely(!mapping))
goto unlock_put_anon;
_
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/6] mm: Remove page_mapping()
2024-04-24 23:34 ` Andrew Morton
@ 2024-04-24 23:59 ` Matthew Wilcox
0 siblings, 0 replies; 18+ messages in thread
From: Matthew Wilcox @ 2024-04-24 23:59 UTC (permalink / raw)
To: Andrew Morton
Cc: David Hildenbrand, linux-mm, linux-fsdevel, linux-fscrypt,
linux-f2fs-devel
On Wed, Apr 24, 2024 at 04:34:23PM -0700, Andrew Morton wrote:
> For some reason,
>
> mm/hugetlb.c: In function 'hugetlb_page_mapping_lock_write':
> mm/hugetlb.c:2164:41: error: implicit declaration of function 'page_mapping'; did you mean 'page_mapped'? [-Werror=implicit-function-declaration]
> 2164 | struct address_space *mapping = page_mapping(hpage);
> | ^~~~~~~~~~~~
> | page_mapped
> mm/hugetlb.c:2164:41: error: initialization of 'struct address_space *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
>
>
> I'll disable "mm: Remove page_mapping()" pending review of the below,
> please.
Looks pretty similar to
https://lore.kernel.org/linux-mm/20240412193510.2356957-7-willy@infradead.org/
Sorry, I thought you'd picked up that series; I think it's fully
reviewed by now?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/6] memory-failure: Remove calls to page_mapping()
2024-04-23 22:55 ` [PATCH 3/6] memory-failure: Remove calls to page_mapping() Matthew Wilcox (Oracle)
2024-04-23 23:52 ` Sidhartha Kumar
2024-04-24 11:54 ` David Hildenbrand
@ 2024-04-25 6:21 ` Miaohe Lin
2 siblings, 0 replies; 18+ messages in thread
From: Miaohe Lin @ 2024-04-25 6:21 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: linux-fsdevel, linux-fscrypt, linux-f2fs-devel, Andrew Morton, linux-mm
On 2024/4/24 6:55, Matthew Wilcox (Oracle) wrote:
> This is mostly just inlining page_mapping() into the two callers.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Thanks.
.
> ---
> mm/memory-failure.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index e065dd9be21e..62aa3db17854 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -216,6 +216,7 @@ EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value);
>
> static int hwpoison_filter_dev(struct page *p)
> {
> + struct folio *folio = page_folio(p);
> struct address_space *mapping;
> dev_t dev;
>
> @@ -223,7 +224,7 @@ static int hwpoison_filter_dev(struct page *p)
> hwpoison_filter_dev_minor == ~0U)
> return 0;
>
> - mapping = page_mapping(p);
> + mapping = folio_mapping(folio);
> if (mapping == NULL || mapping->host == NULL)
> return -EINVAL;
>
> @@ -1090,7 +1091,8 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
> */
> static int me_pagecache_dirty(struct page_state *ps, struct page *p)
> {
> - struct address_space *mapping = page_mapping(p);
> + struct folio *folio = page_folio(p);
> + struct address_space *mapping = folio_mapping(folio);
>
> /* TBD: print more information about the file. */
> if (mapping) {
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2024-04-25 6:22 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 22:55 [PATCH 0/6] Remove page_mapping() Matthew Wilcox (Oracle)
2024-04-23 22:55 ` [PATCH 1/6] fscrypt: Convert bh_get_inode_and_lblk_num to use a folio Matthew Wilcox (Oracle)
2024-04-23 23:34 ` Eric Biggers
2024-04-24 11:53 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 2/6] f2fs: Convert f2fs_clear_page_cache_dirty_tag " Matthew Wilcox (Oracle)
2024-04-24 11:53 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 3/6] memory-failure: Remove calls to page_mapping() Matthew Wilcox (Oracle)
2024-04-23 23:52 ` Sidhartha Kumar
2024-04-24 11:54 ` David Hildenbrand
2024-04-25 6:21 ` Miaohe Lin
2024-04-23 22:55 ` [PATCH 4/6] migrate: Expand the use of folio in __migrate_device_pages() Matthew Wilcox (Oracle)
2024-04-24 11:54 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte() Matthew Wilcox (Oracle)
2024-04-24 11:55 ` David Hildenbrand
2024-04-23 22:55 ` [PATCH 6/6] mm: Remove page_mapping() Matthew Wilcox (Oracle)
2024-04-24 11:55 ` David Hildenbrand
2024-04-24 23:34 ` Andrew Morton
2024-04-24 23:59 ` Matthew Wilcox
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).