From: Miaohe Lin <linmiaohe@huawei.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
<linux-fsdevel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 05/10] mm: Convert remove_mapping() to take a folio
Date: Tue, 15 Feb 2022 16:33:14 +0800 [thread overview]
Message-ID: <1bdef0a9-7f76-1cc2-0a30-d2d90c6d6916@huawei.com> (raw)
In-Reply-To: <20220214200017.3150590-6-willy@infradead.org>
On 2022/2/15 4:00, Matthew Wilcox (Oracle) wrote:
> Add kernel-doc and return the number of pages removed in order to
> get the statistics right in __invalidate_mapping_pages().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
LGTM. Thanks.
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> fs/splice.c | 5 ++---
> include/linux/swap.h | 2 +-
> mm/truncate.c | 2 +-
> mm/vmscan.c | 23 ++++++++++++++---------
> 4 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 23ff9c303abc..047b79db8eb5 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -46,8 +46,7 @@
> static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe,
> struct pipe_buffer *buf)
> {
> - struct page *page = buf->page;
> - struct folio *folio = page_folio(page);
> + struct folio *folio = page_folio(buf->page);
> struct address_space *mapping;
>
> folio_lock(folio);
> @@ -74,7 +73,7 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe,
> * If we succeeded in removing the mapping, set LRU flag
> * and return good.
> */
> - if (remove_mapping(mapping, page)) {
> + if (remove_mapping(mapping, folio)) {
> buf->flags |= PIPE_BUF_FLAG_LRU;
> return true;
> }
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index e7cb7a1e6ceb..304f174b4d31 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -395,7 +395,7 @@ extern unsigned long mem_cgroup_shrink_node(struct mem_cgroup *mem,
> unsigned long *nr_scanned);
> extern unsigned long shrink_all_memory(unsigned long nr_pages);
> extern int vm_swappiness;
> -extern int remove_mapping(struct address_space *mapping, struct page *page);
> +long remove_mapping(struct address_space *mapping, struct folio *folio);
>
> extern unsigned long reclaim_pages(struct list_head *page_list);
> #ifdef CONFIG_NUMA
> diff --git a/mm/truncate.c b/mm/truncate.c
> index d67fa8871b75..8aa86e294775 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
> @@ -292,7 +292,7 @@ int invalidate_inode_page(struct page *page)
> if (folio_has_private(folio) && !filemap_release_folio(folio, 0))
> return 0;
>
> - return remove_mapping(mapping, page);
> + return remove_mapping(mapping, folio);
> }
>
> /**
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 2965be8df713..7959df4d611b 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1335,23 +1335,28 @@ static int __remove_mapping(struct address_space *mapping, struct folio *folio,
> return 0;
> }
>
> -/*
> - * Attempt to detach a locked page from its ->mapping. If it is dirty or if
> - * someone else has a ref on the page, abort and return 0. If it was
> - * successfully detached, return 1. Assumes the caller has a single ref on
> - * this page.
> +/**
> + * remove_mapping() - Attempt to remove a folio from its mapping.
> + * @mapping: The address space.
> + * @folio: The folio to remove.
> + *
> + * If the folio is dirty, under writeback or if someone else has a ref
> + * on it, removal will fail.
> + * Return: The number of pages removed from the mapping. 0 if the folio
> + * could not be removed.
> + * Context: The caller should have a single refcount on the folio and
> + * hold its lock.
> */
> -int remove_mapping(struct address_space *mapping, struct page *page)
> +long remove_mapping(struct address_space *mapping, struct folio *folio)
> {
> - struct folio *folio = page_folio(page);
> if (__remove_mapping(mapping, folio, false, NULL)) {
> /*
> - * Unfreezing the refcount with 1 rather than 2 effectively
> + * Unfreezing the refcount with 1 effectively
> * drops the pagecache ref for us without requiring another
> * atomic operation.
> */
> folio_ref_unfreeze(folio, 1);
> - return 1;
> + return folio_nr_pages(folio);
> }
> return 0;
> }
>
next prev parent reply other threads:[~2022-02-15 8:33 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 20:00 [PATCH 00/10] Various fixes around invalidate_page() Matthew Wilcox (Oracle)
2022-02-14 20:00 ` [PATCH 01/10] splice: Use a folio in page_cache_pipe_buf_try_steal() Matthew Wilcox (Oracle)
2022-02-15 7:15 ` Christoph Hellwig
2022-02-15 8:32 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 02/10] mm/truncate: Inline invalidate_complete_page() into its one caller Matthew Wilcox (Oracle)
2022-02-14 23:09 ` John Hubbard
2022-02-14 23:32 ` Matthew Wilcox
2022-02-14 23:51 ` John Hubbard
2022-02-15 7:17 ` Christoph Hellwig
2022-02-15 7:45 ` Miaohe Lin
2022-02-15 20:09 ` Matthew Wilcox
2022-02-16 2:36 ` Miaohe Lin
2022-02-16 2:45 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 03/10] mm/truncate: Convert invalidate_inode_page() to use a folio Matthew Wilcox (Oracle)
2022-02-15 7:18 ` Christoph Hellwig
2022-02-15 8:32 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 04/10] mm/truncate: Replace page_mapped() call in invalidate_inode_page() Matthew Wilcox (Oracle)
2022-02-15 7:19 ` Christoph Hellwig
2022-02-15 20:12 ` Matthew Wilcox
2022-02-15 8:32 ` Miaohe Lin
2022-02-25 1:31 ` Matthew Wilcox
2022-02-25 3:27 ` Matthew Wilcox
2022-02-14 20:00 ` [PATCH 05/10] mm: Convert remove_mapping() to take a folio Matthew Wilcox (Oracle)
2022-02-15 7:21 ` Christoph Hellwig
2022-02-15 8:33 ` Miaohe Lin [this message]
2022-02-14 20:00 ` [PATCH 06/10] mm/truncate: Split invalidate_inode_page() into mapping_shrink_folio() Matthew Wilcox (Oracle)
2022-02-15 7:23 ` Christoph Hellwig
2022-02-15 9:37 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 07/10] mm/truncate: Convert __invalidate_mapping_pages() to use a folio Matthew Wilcox (Oracle)
2022-02-15 7:24 ` Christoph Hellwig
2022-02-15 9:37 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 08/10] mm: Turn deactivate_file_page() into deactivate_file_folio() Matthew Wilcox (Oracle)
2022-02-15 7:25 ` Christoph Hellwig
2022-02-15 8:26 ` Miaohe Lin
2022-02-15 20:33 ` Matthew Wilcox
2022-02-16 2:45 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 09/10] mm/truncate: Combine invalidate_mapping_pagevec() and __invalidate_mapping_pages() Matthew Wilcox (Oracle)
2022-02-15 7:26 ` Christoph Hellwig
2022-02-15 9:37 ` Miaohe Lin
2022-02-14 20:00 ` [PATCH 10/10] fs: Move many prototypes to pagemap.h Matthew Wilcox (Oracle)
2022-02-15 7:27 ` Christoph Hellwig
2022-02-15 9:38 ` Miaohe Lin
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=1bdef0a9-7f76-1cc2-0a30-d2d90c6d6916@huawei.com \
--to=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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).