Re: [PATCH v2 04/28] fs: Rename AS_THP_SUPPORT and mapping_thp_support

From: Matthew Wilcox
Date: Mon Nov 15 2021 - 11:04:01 EST


On Tue, Nov 09, 2021 at 12:41:19AM -0800, Christoph Hellwig wrote:
> On Mon, Nov 08, 2021 at 04:05:27AM +0000, Matthew Wilcox (Oracle) wrote:
> > These are now indicators of multi-page folio support, not THP support.
>
> Given that we don't use the large foltio term anywhere else this really
> needs to grow a comment explaining what the flag means.

I think I prefer the term 'large' to 'multi'. What would you think to
this patch (not on top of any particular branch; just to show the scope
of it ...)

+++ b/include/linux/page-flags.h
@@ -692,7 +692,7 @@ static inline bool folio_test_single(struct folio *folio)
return !folio_test_head(folio);
}

-static inline bool folio_test_multi(struct folio *folio)
+static inline bool folio_test_large(struct folio *folio)
{
return folio_test_head(folio);
}
+++ b/mm/filemap.c
@@ -192,9 +192,9 @@ static void filemap_unaccount_folio(struct address_space *mapping,
__lruvec_stat_mod_folio(folio, NR_FILE_PAGES, -nr);
if (folio_test_swapbacked(folio)) {
__lruvec_stat_mod_folio(folio, NR_SHMEM, -nr);
- if (folio_test_multi(folio))
+ if (folio_test_large(folio))
__lruvec_stat_mod_folio(folio, NR_SHMEM_THPS, -nr);
- } else if (folio_test_multi(folio)) {
+ } else if (folio_test_large(folio)) {
__lruvec_stat_mod_folio(folio, NR_FILE_THPS, -nr);
filemap_nr_thps_dec(mapping);
}
@@ -236,7 +236,7 @@ void filemap_free_folio(struct address_space *mapping, struct folio *folio)
if (freepage)
freepage(&folio->page);

- if (folio_test_multi(folio) && !folio_test_hugetlb(folio)) {
+ 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 {
+++ b/mm/memcontrol.c
@@ -5558,7 +5558,7 @@ static int mem_cgroup_move_account(struct page *page,

VM_BUG_ON(from == to);
VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
- VM_BUG_ON(compound && !folio_test_multi(folio));
+ VM_BUG_ON(compound && !folio_test_large(folio));

/*
* Prevent mem_cgroup_migrate() from looking at