* [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio
@ 2022-06-01 19:23 Matthew Wilcox (Oracle)
2022-06-01 19:23 ` [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() Matthew Wilcox (Oracle)
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-06-01 19:23 UTC (permalink / raw)
To: linux-mm
Cc: Matthew Wilcox (Oracle), linux-fsdevel, Mike Kravetz, Muchun Song
Remove the last caller of add_to_page_cache()
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/hugetlbfs/inode.c | 2 +-
mm/hugetlb.c | 14 ++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 62408047e8d7..ae2524480f23 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -759,7 +759,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
SetHPageMigratable(page);
/*
- * unlock_page because locked by add_to_page_cache()
+ * unlock_page because locked by huge_add_to_page_cache()
* put_page() due to reference from alloc_huge_page()
*/
unlock_page(page);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7c468ac1d069..eb9d6fe9c492 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5406,19 +5406,25 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
pgoff_t idx)
{
+ struct folio *folio = page_folio(page);
struct inode *inode = mapping->host;
struct hstate *h = hstate_inode(inode);
- int err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
+ int err;
- if (err)
+ __folio_set_locked(folio);
+ err = __filemap_add_folio(mapping, folio, idx, GFP_KERNEL, NULL);
+
+ if (unlikely(err)) {
+ __folio_clear_locked(folio);
return err;
+ }
ClearHPageRestoreReserve(page);
/*
- * set page dirty so that it will not be removed from cache/file
+ * mark folio dirty so that it will not be removed from cache/file
* by non-hugetlbfs specific code paths.
*/
- set_page_dirty(page);
+ folio_mark_dirty(folio);
spin_lock(&inode->i_lock);
inode->i_blocks += blocks_per_huge_page(h);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() 2022-06-01 19:23 [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Matthew Wilcox (Oracle) @ 2022-06-01 19:23 ` Matthew Wilcox (Oracle) 2022-06-01 20:56 ` Mike Kravetz 2022-06-02 2:49 ` Muchun Song 2022-06-01 20:50 ` [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Mike Kravetz 2022-06-02 2:49 ` Muchun Song 2 siblings, 2 replies; 6+ messages in thread From: Matthew Wilcox (Oracle) @ 2022-06-01 19:23 UTC (permalink / raw) To: linux-mm Cc: Matthew Wilcox (Oracle), linux-fsdevel, Mike Kravetz, Muchun Song These functions have no more users, so delete them. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- .../admin-guide/cgroup-v1/memcg_test.rst | 2 +- include/linux/pagemap.h | 18 ----------------- mm/filemap.c | 20 ------------------- mm/shmem.c | 2 +- mm/swap_state.c | 2 +- 5 files changed, 3 insertions(+), 41 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v1/memcg_test.rst b/Documentation/admin-guide/cgroup-v1/memcg_test.rst index 45b94f7b3beb..a402359abb99 100644 --- a/Documentation/admin-guide/cgroup-v1/memcg_test.rst +++ b/Documentation/admin-guide/cgroup-v1/memcg_test.rst @@ -97,7 +97,7 @@ Under below explanation, we assume CONFIG_MEM_RES_CTRL_SWAP=y. ============= Page Cache is charged at - - add_to_page_cache_locked(). + - filemap_add_folio(). The logic is very clear. (About migration, see below) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index ce96866fbec4..5555689ea809 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1098,8 +1098,6 @@ size_t fault_in_subpage_writeable(char __user *uaddr, size_t size); size_t fault_in_safe_writeable(const char __user *uaddr, size_t size); size_t fault_in_readable(const char __user *uaddr, size_t size); -int add_to_page_cache_locked(struct page *page, struct address_space *mapping, - pgoff_t index, gfp_t gfp); int add_to_page_cache_lru(struct page *page, struct address_space *mapping, pgoff_t index, gfp_t gfp); int filemap_add_folio(struct address_space *mapping, struct folio *folio, @@ -1119,22 +1117,6 @@ bool filemap_release_folio(struct folio *folio, gfp_t gfp); loff_t mapping_seek_hole_data(struct address_space *, loff_t start, loff_t end, int whence); -/* - * Like add_to_page_cache_locked, but used to add newly allocated pages: - * the page is new, so we can just run __SetPageLocked() against it. - */ -static inline int add_to_page_cache(struct page *page, - struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask) -{ - int error; - - __SetPageLocked(page); - error = add_to_page_cache_locked(page, mapping, offset, gfp_mask); - if (unlikely(error)) - __ClearPageLocked(page); - return error; -} - /* Must be non-static for BPF error injection */ int __filemap_add_folio(struct address_space *mapping, struct folio *folio, pgoff_t index, gfp_t gfp, void **shadowp); diff --git a/mm/filemap.c b/mm/filemap.c index 9daeaab36081..1e66eea98a7e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -929,26 +929,6 @@ noinline int __filemap_add_folio(struct address_space *mapping, } ALLOW_ERROR_INJECTION(__filemap_add_folio, ERRNO); -/** - * add_to_page_cache_locked - add a locked page to the pagecache - * @page: page to add - * @mapping: the page's address_space - * @offset: page index - * @gfp_mask: page allocation mode - * - * This function is used to add a page to the pagecache. It must be locked. - * This function does not add the page to the LRU. The caller must do that. - * - * Return: %0 on success, negative error code otherwise. - */ -int add_to_page_cache_locked(struct page *page, struct address_space *mapping, - pgoff_t offset, gfp_t gfp_mask) -{ - return __filemap_add_folio(mapping, page_folio(page), offset, - gfp_mask, NULL); -} -EXPORT_SYMBOL(add_to_page_cache_locked); - int filemap_add_folio(struct address_space *mapping, struct folio *folio, pgoff_t index, gfp_t gfp) { diff --git a/mm/shmem.c b/mm/shmem.c index a6f565308133..60fdfc0208fd 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -693,7 +693,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ /* - * Like add_to_page_cache_locked, but error if expected item has gone. + * Like filemap_add_folio, but error if expected item has gone. */ static int shmem_add_to_page_cache(struct folio *folio, struct address_space *mapping, diff --git a/mm/swap_state.c b/mm/swap_state.c index 778d57d2d92d..f5b6f5638908 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -95,7 +95,7 @@ void *get_shadow_from_swap_cache(swp_entry_t entry) } /* - * add_to_swap_cache resembles add_to_page_cache_locked on swapper_space, + * add_to_swap_cache resembles filemap_add_folio on swapper_space, * but sets SwapCache flag and private instead of mapping and index. */ int add_to_swap_cache(struct page *page, swp_entry_t entry, -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() 2022-06-01 19:23 ` [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() Matthew Wilcox (Oracle) @ 2022-06-01 20:56 ` Mike Kravetz 2022-06-02 2:49 ` Muchun Song 1 sibling, 0 replies; 6+ messages in thread From: Mike Kravetz @ 2022-06-01 20:56 UTC (permalink / raw) To: Matthew Wilcox (Oracle), linux-mm; +Cc: linux-fsdevel, Muchun Song On 6/1/22 12:23, Matthew Wilcox (Oracle) wrote: > These functions have no more users, so delete them. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > .../admin-guide/cgroup-v1/memcg_test.rst | 2 +- > include/linux/pagemap.h | 18 ----------------- > mm/filemap.c | 20 ------------------- > mm/shmem.c | 2 +- > mm/swap_state.c | 2 +- > 5 files changed, 3 insertions(+), 41 deletions(-) grep comes up empty, Acked-by: Mike Kravetz <mike.kravetz@oracle.com> -- Mike Kravetz ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() 2022-06-01 19:23 ` [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() Matthew Wilcox (Oracle) 2022-06-01 20:56 ` Mike Kravetz @ 2022-06-02 2:49 ` Muchun Song 1 sibling, 0 replies; 6+ messages in thread From: Muchun Song @ 2022-06-02 2:49 UTC (permalink / raw) To: Matthew Wilcox (Oracle); +Cc: linux-mm, linux-fsdevel, Mike Kravetz On Wed, Jun 01, 2022 at 08:23:33PM +0100, Matthew Wilcox (Oracle) wrote: > These functions have no more users, so delete them. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio 2022-06-01 19:23 [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Matthew Wilcox (Oracle) 2022-06-01 19:23 ` [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() Matthew Wilcox (Oracle) @ 2022-06-01 20:50 ` Mike Kravetz 2022-06-02 2:49 ` Muchun Song 2 siblings, 0 replies; 6+ messages in thread From: Mike Kravetz @ 2022-06-01 20:50 UTC (permalink / raw) To: Matthew Wilcox (Oracle), linux-mm; +Cc: linux-fsdevel, Muchun Song On 6/1/22 12:23, Matthew Wilcox (Oracle) wrote: > Remove the last caller of add_to_page_cache() > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > fs/hugetlbfs/inode.c | 2 +- > mm/hugetlb.c | 14 ++++++++++---- > 2 files changed, 11 insertions(+), 5 deletions(-) Thanks, Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> -- Mike Kravetz ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio 2022-06-01 19:23 [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Matthew Wilcox (Oracle) 2022-06-01 19:23 ` [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() Matthew Wilcox (Oracle) 2022-06-01 20:50 ` [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Mike Kravetz @ 2022-06-02 2:49 ` Muchun Song 2 siblings, 0 replies; 6+ messages in thread From: Muchun Song @ 2022-06-02 2:49 UTC (permalink / raw) To: Matthew Wilcox (Oracle); +Cc: linux-mm, linux-fsdevel, Mike Kravetz On Wed, Jun 01, 2022 at 08:23:32PM +0100, Matthew Wilcox (Oracle) wrote: > Remove the last caller of add_to_page_cache() > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-02 2:49 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-06-01 19:23 [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Matthew Wilcox (Oracle) 2022-06-01 19:23 ` [PATCH 2/2] filemap: Remove add_to_page_cache() and add_to_page_cache_locked() Matthew Wilcox (Oracle) 2022-06-01 20:56 ` Mike Kravetz 2022-06-02 2:49 ` Muchun Song 2022-06-01 20:50 ` [PATCH 1/2] hugetlb: Convert huge_add_to_page_cache() to use a folio Mike Kravetz 2022-06-02 2:49 ` Muchun Song
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).