From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 02/12] filemap: Use folio_put_refs() in filemap_free_folio()
Date: Mon, 17 Jan 2022 18:56:41 +0300 [thread overview]
Message-ID: <20220117155641.u5ysambg72nq2p6y@box.shutemov.name> (raw)
In-Reply-To: <20220116121822.1727633-3-willy@infradead.org>
On Sun, Jan 16, 2022 at 12:18:12PM +0000, Matthew Wilcox (Oracle) wrote:
> This shrinks filemap_free_folio() by 55 bytes in my .config; 24 bytes
> from removing the VM_BUG_ON_FOLIO() and 31 bytes from unifying the
> small/large folio paths.
>
> We could just use folio_ref_sub() here since the caller should hold a
> reference (as the VM_BUG_ON_FOLIO() was asserting), but that's fragile.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> mm/filemap.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 2fd9b2f24025..afc8f5ca85ac 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -231,17 +231,15 @@ void __filemap_remove_folio(struct folio *folio, void *shadow)
> void filemap_free_folio(struct address_space *mapping, struct folio *folio)
> {
> void (*freepage)(struct page *);
> + int refs = 1;
>
> freepage = mapping->a_ops->freepage;
> if (freepage)
> freepage(&folio->page);
>
> - if (folio_test_large(folio) && !folio_test_hugetlb(folio)) {
> - folio_ref_sub(folio, folio_nr_pages(folio));
> - VM_BUG_ON_FOLIO(folio_ref_count(folio) <= 0, folio);
> - } else {
> - folio_put(folio);
> - }
> + if (folio_test_large(folio) && !folio_test_hugetlb(folio))
> + refs = folio_nr_pages(folio);
Isn't folio_test_large() check redundant? folio_nr_pages() would return 1
for non-large folio, wouldn't it?
> + folio_put_refs(folio, refs);
> }
>
> /**
> --
> 2.34.1
>
--
Kirill A. Shutemov
next prev parent reply other threads:[~2022-01-17 15:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-16 12:18 [PATCH 00/12] Enabling large folios for 5.17 Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 01/12] mm: Add folio_put_refs() Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 02/12] filemap: Use folio_put_refs() in filemap_free_folio() Matthew Wilcox (Oracle)
2022-01-17 15:56 ` Kirill A. Shutemov [this message]
2022-01-17 16:11 ` Matthew Wilcox
2022-01-16 12:18 ` [PATCH 03/12] filemap: Allow large folios to be added to the page cache Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 04/12] mm/vmscan: Free non-shmem folios without splitting them Matthew Wilcox (Oracle)
2022-01-17 16:06 ` Kirill A. Shutemov
2022-01-17 16:10 ` Matthew Wilcox
2022-01-17 21:00 ` Kirill A. Shutemov
2022-01-16 12:18 ` [PATCH 05/12] mm: Fix READ_ONLY_THP warning Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 06/12] mm/vmscan: Optimise shrink_page_list for non-PMD-sized folios Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 07/12] mm: Make large folios depend on THP Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 08/12] mm/readahead: Add large folio readahead Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 09/12] mm/readahead: Align file mappings for non-DAX Matthew Wilcox (Oracle)
2022-01-17 3:17 ` Rongwei Wang
2022-01-17 4:40 ` Matthew Wilcox
2022-01-16 12:18 ` [PATCH 10/12] mm/readahead: Switch to page_cache_ra_order Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 11/12] mm/filemap: Support VM_HUGEPAGE for file mappings Matthew Wilcox (Oracle)
2022-01-16 12:18 ` [PATCH 12/12] selftests/vm/transhuge-stress: Support file-backed PMD folios 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=20220117155641.u5ysambg72nq2p6y@box.shutemov.name \
--to=kirill@shutemov.name \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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).