All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Various page->flags cleanups
@ 2024-03-26 17:10 Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages Matthew Wilcox (Oracle)
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

The first two patches are bug fixes, although I'm not sure that either
architecture will have noticed.  There aren't a lot of uses of page->flags
left!  The big build-up here is to reworking stable_page_flags(), which
will definitely be a user-visible change.  I think a welcome one, given
the special case we had to spread the Slab flag into all tail pages.

Matthew Wilcox (Oracle) (10):
  sh: Remove use of PG_arch_1 on individual pages
  xtensa: Remove uses of PG_arch_1 on individual pages
  mm: Make page_ext_get() take a const argument
  mm: Make folio_test_idle and folio_test_young take a const argument
  mm: Make is_free_buddy_page() take a const argument
  mm: Make page_mapped() take a const argument
  mm: Convert arch_clear_hugepage_flags to take a folio
  slub: Remove use of page->flags
  Remove references to page->flags in documentation
  proc: Rewrite stable_page_flags()

 .../admin-guide/cgroup-v1/memory.rst          |  4 +-
 Documentation/mm/vmemmap_dedup.rst            | 22 +------
 .../translations/zh_CN/core-api/cachetlb.rst  |  2 +-
 arch/arm/include/asm/hugetlb.h                |  6 +-
 arch/arm64/include/asm/hugetlb.h              |  6 +-
 arch/riscv/include/asm/hugetlb.h              |  6 +-
 arch/s390/include/asm/hugetlb.h               |  6 +-
 arch/sh/include/asm/hugetlb.h                 |  6 +-
 arch/sh/mm/cache-sh4.c                        |  5 +-
 arch/xtensa/mm/cache.c                        |  6 +-
 fs/proc/page.c                                | 66 ++++++++++---------
 include/linux/huge_mm.h                       |  4 +-
 include/linux/hugetlb.h                       |  4 +-
 include/linux/mm.h                            | 12 ++--
 include/linux/page-flags.h                    |  4 +-
 include/linux/page_ext.h                      |  4 +-
 include/linux/page_idle.h                     | 10 +--
 include/linux/pgalloc_tag.h                   |  2 -
 mm/hugetlb.c                                  |  4 +-
 mm/internal.h                                 |  7 +-
 mm/migrate.c                                  |  2 +-
 mm/page_alloc.c                               |  8 +--
 mm/page_ext.c                                 |  2 +-
 mm/rmap.c                                     |  6 +-
 mm/slub.c                                     | 10 +--
 25 files changed, 97 insertions(+), 117 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-27 18:45   ` kernel test robot
  2024-03-26 17:10 ` [PATCH 02/10] xtensa: Remove uses " Matthew Wilcox (Oracle)
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

Since switching to the new page table range API, we do not set the
PG_arch_1 (aka dcache clean) flag on tail pages, only on the folio.
Test it on the folio.  Also use page_mapped() instead of page_mapcount()
as it is more efficient.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/sh/mm/cache-sh4.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 862046f26981..cea8f1693908 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -241,13 +241,14 @@ static void sh4_flush_cache_page(void *args)
 	if ((vma->vm_mm == current->active_mm))
 		vaddr = NULL;
 	else {
+		struct folio *folio = page_folio(page);
 		/*
 		 * Use kmap_coherent or kmap_atomic to do flushes for
 		 * another ASID than the current one.
 		 */
 		map_coherent = (current_cpu_data.dcache.n_aliases &&
-			test_bit(PG_dcache_clean, &page->flags) &&
-			page_mapcount(page));
+			test_bit(PG_dcache_clean, folio_flags(folio)) &&
+			page_mapped(page));
 		if (map_coherent)
 			vaddr = kmap_coherent(page, address);
 		else
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/10] xtensa: Remove uses of PG_arch_1 on individual pages
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-28 19:36   ` Svetly Todorov
  2024-03-26 17:10 ` [PATCH 03/10] mm: Make page_ext_get() take a const argument Matthew Wilcox (Oracle)
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, Svetly Todorov

Since switching to the new page table range API, we disregard the
PG_arch_1 (aka dcache dirty) flag on tail pages, and only pay attention
to it on the folio.  Fix these two missed spots where we were setting it
on arbitrary pages.

Reported-by: Svetly Todorov <svetly.todorov@memverge.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/xtensa/mm/cache.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c
index 7ec66a79f472..23be0e7516ce 100644
--- a/arch/xtensa/mm/cache.c
+++ b/arch/xtensa/mm/cache.c
@@ -87,12 +87,13 @@ static inline void *coherent_kvaddr(struct page *page, unsigned long base,
 
 void clear_user_highpage(struct page *page, unsigned long vaddr)
 {
+	struct folio *folio = page_folio(page);
 	unsigned long paddr;
 	void *kvaddr = coherent_kvaddr(page, TLBTEMP_BASE_1, vaddr, &paddr);
 
 	preempt_disable();
 	kmap_invalidate_coherent(page, vaddr);
-	set_bit(PG_arch_1, &page->flags);
+	set_bit(PG_arch_1, folio_flags(folio, 0));
 	clear_page_alias(kvaddr, paddr);
 	preempt_enable();
 }
@@ -101,6 +102,7 @@ EXPORT_SYMBOL(clear_user_highpage);
 void copy_user_highpage(struct page *dst, struct page *src,
 			unsigned long vaddr, struct vm_area_struct *vma)
 {
+	struct folio *folio = page_folio(dst);
 	unsigned long dst_paddr, src_paddr;
 	void *dst_vaddr = coherent_kvaddr(dst, TLBTEMP_BASE_1, vaddr,
 					  &dst_paddr);
@@ -109,7 +111,7 @@ void copy_user_highpage(struct page *dst, struct page *src,
 
 	preempt_disable();
 	kmap_invalidate_coherent(dst, vaddr);
-	set_bit(PG_arch_1, &dst->flags);
+	set_bit(PG_arch_1, folio_flags(folio, 0));
 	copy_page_alias(dst_vaddr, src_vaddr, dst_paddr, src_paddr);
 	preempt_enable();
 }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/10] mm: Make page_ext_get() take a const argument
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 02/10] xtensa: Remove uses " Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 04/10] mm: Make folio_test_idle and folio_test_young " Matthew Wilcox (Oracle)
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

In order to constify other functions, we need page_ext_get() to be const.
This is no problem as lookup_page_ext() already takes a const argument.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/page_ext.h    | 4 ++--
 include/linux/pgalloc_tag.h | 2 --
 mm/page_ext.c               | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
index 07e0656898f9..e4b48a0dda24 100644
--- a/include/linux/page_ext.h
+++ b/include/linux/page_ext.h
@@ -77,7 +77,7 @@ static inline void page_ext_init(void)
 }
 #endif
 
-extern struct page_ext *page_ext_get(struct page *page);
+extern struct page_ext *page_ext_get(const struct page *page);
 extern void page_ext_put(struct page_ext *page_ext);
 
 static inline void *page_ext_data(struct page_ext *page_ext,
@@ -117,7 +117,7 @@ static inline void page_ext_init_flatmem(void)
 {
 }
 
-static inline struct page_ext *page_ext_get(struct page *page)
+static inline struct page_ext *page_ext_get(const struct page *page)
 {
 	return NULL;
 }
diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h
index 62d8dad74b37..86ba5d33e43b 100644
--- a/include/linux/pgalloc_tag.h
+++ b/include/linux/pgalloc_tag.h
@@ -12,8 +12,6 @@
 #include <linux/page_ext.h>
 
 extern struct page_ext_operations page_alloc_tagging_ops;
-extern struct page_ext *page_ext_get(struct page *page);
-extern void page_ext_put(struct page_ext *page_ext);
 
 static inline union codetag_ref *codetag_ref_from_page_ext(struct page_ext *page_ext)
 {
diff --git a/mm/page_ext.c b/mm/page_ext.c
index e7d8f1a5589e..95dd8ffeaf81 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -514,7 +514,7 @@ void __meminit pgdat_page_ext_init(struct pglist_data *pgdat)
  * Context: Any context.  Caller may not sleep until they have called
  * page_ext_put().
  */
-struct page_ext *page_ext_get(struct page *page)
+struct page_ext *page_ext_get(const struct page *page)
 {
 	struct page_ext *page_ext;
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/10] mm: Make folio_test_idle and folio_test_young take a const argument
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 03/10] mm: Make page_ext_get() take a const argument Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 05/10] mm: Make is_free_buddy_page() " Matthew Wilcox (Oracle)
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

If these functions are defined in page-flags.h, they already take a
const argument; make it true for these alternate definitions too.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/page_idle.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h
index d8f344840643..511e22ef459f 100644
--- a/include/linux/page_idle.h
+++ b/include/linux/page_idle.h
@@ -13,7 +13,7 @@
  * If there is not enough space to store Idle and Young bits in page flags, use
  * page ext flags instead.
  */
-static inline bool folio_test_young(struct folio *folio)
+static inline bool folio_test_young(const struct folio *folio)
 {
 	struct page_ext *page_ext = page_ext_get(&folio->page);
 	bool page_young;
@@ -52,7 +52,7 @@ static inline bool folio_test_clear_young(struct folio *folio)
 	return page_young;
 }
 
-static inline bool folio_test_idle(struct folio *folio)
+static inline bool folio_test_idle(const struct folio *folio)
 {
 	struct page_ext *page_ext = page_ext_get(&folio->page);
 	bool page_idle;
@@ -60,7 +60,7 @@ static inline bool folio_test_idle(struct folio *folio)
 	if (unlikely(!page_ext))
 		return false;
 
-	page_idle =  test_bit(PAGE_EXT_IDLE, &page_ext->flags);
+	page_idle = test_bit(PAGE_EXT_IDLE, &page_ext->flags);
 	page_ext_put(page_ext);
 
 	return page_idle;
@@ -91,7 +91,7 @@ static inline void folio_clear_idle(struct folio *folio)
 
 #else /* !CONFIG_PAGE_IDLE_FLAG */
 
-static inline bool folio_test_young(struct folio *folio)
+static inline bool folio_test_young(const struct folio *folio)
 {
 	return false;
 }
@@ -105,7 +105,7 @@ static inline bool folio_test_clear_young(struct folio *folio)
 	return false;
 }
 
-static inline bool folio_test_idle(struct folio *folio)
+static inline bool folio_test_idle(const struct folio *folio)
 {
 	return false;
 }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/10] mm: Make is_free_buddy_page() take a const argument
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (3 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 04/10] mm: Make folio_test_idle and folio_test_young " Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 06/10] mm: Make page_mapped() " Matthew Wilcox (Oracle)
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

This function does not modify its argument; let the callers know that
so they can make better optimisation decisions.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/page-flags.h | 2 +-
 mm/page_alloc.c            | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 0163d6da6283..eaecf544039f 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -1088,7 +1088,7 @@ static inline bool is_page_hwpoison(const struct page *page)
 	return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
 }
 
-extern bool is_free_buddy_page(struct page *page);
+bool is_free_buddy_page(const struct page *page);
 
 PAGEFLAG(Isolated, isolated, PF_ANY);
 
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 370ea1711828..a00a2d7d8d9f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6786,16 +6786,16 @@ void __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
 /*
  * This function returns a stable result only if called under zone lock.
  */
-bool is_free_buddy_page(struct page *page)
+bool is_free_buddy_page(const struct page *page)
 {
 	unsigned long pfn = page_to_pfn(page);
 	unsigned int order;
 
 	for (order = 0; order < NR_PAGE_ORDERS; order++) {
-		struct page *page_head = page - (pfn & ((1 << order) - 1));
+		const struct page *head = page - (pfn & ((1 << order) - 1));
 
-		if (PageBuddy(page_head) &&
-		    buddy_order_unsafe(page_head) >= order)
+		if (PageBuddy(head) &&
+		    buddy_order_unsafe(head) >= order)
 			break;
 	}
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/10] mm: Make page_mapped() take a const argument
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (4 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 05/10] mm: Make is_free_buddy_page() " Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Matthew Wilcox (Oracle)
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

None of the functions called by page_mapped() modify the page or folio,
so mark them all as const.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/mm.h | 12 ++++++------
 mm/internal.h      |  7 ++++---
 mm/rmap.c          |  2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index e329f09fbb9c..d226c1929f98 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1200,7 +1200,7 @@ static inline int is_vmalloc_or_module_addr(const void *x)
  * debugging purposes - it does not include PTE-mapped sub-pages; look
  * at folio_mapcount() or page_mapcount() instead.
  */
-static inline int folio_entire_mapcount(struct folio *folio)
+static inline int folio_entire_mapcount(const struct folio *folio)
 {
 	VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
 	return atomic_read(&folio->_entire_mapcount) + 1;
@@ -1240,7 +1240,7 @@ static inline int page_mapcount(struct page *page)
 	return mapcount;
 }
 
-int folio_total_mapcount(struct folio *folio);
+int folio_total_mapcount(const struct folio *folio);
 
 /**
  * folio_mapcount() - Calculate the number of mappings of this folio.
@@ -1253,14 +1253,14 @@ int folio_total_mapcount(struct folio *folio);
  *
  * Return: The number of times this folio is mapped.
  */
-static inline int folio_mapcount(struct folio *folio)
+static inline int folio_mapcount(const struct folio *folio)
 {
 	if (likely(!folio_test_large(folio)))
 		return atomic_read(&folio->_mapcount) + 1;
 	return folio_total_mapcount(folio);
 }
 
-static inline bool folio_large_is_mapped(struct folio *folio)
+static inline bool folio_large_is_mapped(const struct folio *folio)
 {
 	/*
 	 * Reading _entire_mapcount below could be omitted if hugetlb
@@ -1288,7 +1288,7 @@ static inline bool folio_mapped(struct folio *folio)
  * For compound page it returns true if any sub-page of compound page is mapped,
  * even if this particular sub-page is not itself mapped by any PTE or PMD.
  */
-static inline bool page_mapped(struct page *page)
+static inline bool page_mapped(const struct page *page)
 {
 	if (likely(!PageCompound(page)))
 		return atomic_read(&page->_mapcount) >= 0;
@@ -2070,7 +2070,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
  *
  * Return: A positive power of two.
  */
-static inline long folio_nr_pages(struct folio *folio)
+static inline long folio_nr_pages(const struct folio *folio)
 {
 	if (!folio_test_large(folio))
 		return 1;
diff --git a/mm/internal.h b/mm/internal.h
index 5dbfa1c12e89..8e11f7b2da21 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -71,7 +71,7 @@ void page_writeback_init(void);
  * How many individual pages have an elevated _mapcount.  Excludes
  * the folio's entire_mapcount.
  */
-static inline int folio_nr_pages_mapped(struct folio *folio)
+static inline int folio_nr_pages_mapped(const struct folio *folio)
 {
 	return atomic_read(&folio->_nr_pages_mapped) & FOLIO_PAGES_MAPPED;
 }
@@ -81,7 +81,8 @@ static inline int folio_nr_pages_mapped(struct folio *folio)
  * folio. We cannot rely on folio->swap as there is no guarantee that it has
  * been initialized. Used for calling arch_swap_restore()
  */
-static inline swp_entry_t folio_swap(swp_entry_t entry, struct folio *folio)
+static inline swp_entry_t folio_swap(swp_entry_t entry,
+		const struct folio *folio)
 {
 	swp_entry_t swap = {
 		.val = ALIGN_DOWN(entry.val, folio_nr_pages(folio)),
@@ -90,7 +91,7 @@ static inline swp_entry_t folio_swap(swp_entry_t entry, struct folio *folio)
 	return swap;
 }
 
-static inline void *folio_raw_mapping(struct folio *folio)
+static inline void *folio_raw_mapping(const struct folio *folio)
 {
 	unsigned long mapping = (unsigned long)folio->mapping;
 
diff --git a/mm/rmap.c b/mm/rmap.c
index 3746a5531018..d52759aa3ff7 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1134,7 +1134,7 @@ int pfn_mkclean_range(unsigned long pfn, unsigned long nr_pages, pgoff_t pgoff,
 	return page_vma_mkclean_one(&pvmw);
 }
 
-int folio_total_mapcount(struct folio *folio)
+int folio_total_mapcount(const struct folio *folio)
 {
 	int mapcount = folio_entire_mapcount(folio);
 	int nr_pages;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (5 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 06/10] mm: Make page_mapped() " Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-27 13:02   ` Ryan Roberts
                     ` (2 more replies)
  2024-03-26 17:10 ` [PATCH 08/10] slub: Remove use of page->flags Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  9 siblings, 3 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

All implementations that aren't no-ops just set a bit in the flags,
and we want to use the folio flags rather than the page flags for that.
Rename it to arch_clear_hugetlb_flags() while we're touching it so nobody
thinks it's used for THP.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/arm/include/asm/hugetlb.h   | 6 +++---
 arch/arm64/include/asm/hugetlb.h | 6 +++---
 arch/riscv/include/asm/hugetlb.h | 6 +++---
 arch/s390/include/asm/hugetlb.h  | 6 +++---
 arch/sh/include/asm/hugetlb.h    | 6 +++---
 include/linux/hugetlb.h          | 4 ++--
 mm/hugetlb.c                     | 4 ++--
 7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/arch/arm/include/asm/hugetlb.h b/arch/arm/include/asm/hugetlb.h
index a3a82b7158d4..b766c4b373f6 100644
--- a/arch/arm/include/asm/hugetlb.h
+++ b/arch/arm/include/asm/hugetlb.h
@@ -15,10 +15,10 @@
 #include <asm/hugetlb-3level.h>
 #include <asm-generic/hugetlb.h>
 
-static inline void arch_clear_hugepage_flags(struct page *page)
+static inline void arch_clear_hugetlb_flags(struct folio *folio)
 {
-	clear_bit(PG_dcache_clean, &page->flags);
+	clear_bit(PG_dcache_clean, &folio->flags);
 }
-#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 
 #endif /* _ASM_ARM_HUGETLB_H */
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index 2ddc33d93b13..3954cbd2ff56 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -18,11 +18,11 @@
 extern bool arch_hugetlb_migration_supported(struct hstate *h);
 #endif
 
-static inline void arch_clear_hugepage_flags(struct page *page)
+static inline void arch_clear_hugetlb_flags(struct folio *folio)
 {
-	clear_bit(PG_dcache_clean, &page->flags);
+	clear_bit(PG_dcache_clean, &folio->flags);
 }
-#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 
 pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags);
 #define arch_make_huge_pte arch_make_huge_pte
diff --git a/arch/riscv/include/asm/hugetlb.h b/arch/riscv/include/asm/hugetlb.h
index 22deb7a2a6ec..b1ce97a9dbfc 100644
--- a/arch/riscv/include/asm/hugetlb.h
+++ b/arch/riscv/include/asm/hugetlb.h
@@ -5,11 +5,11 @@
 #include <asm/cacheflush.h>
 #include <asm/page.h>
 
-static inline void arch_clear_hugepage_flags(struct page *page)
+static inline void arch_clear_hugetlb_flags(struct folio *folio)
 {
-	clear_bit(PG_dcache_clean, &page->flags);
+	clear_bit(PG_dcache_clean, &folio->flags);
 }
-#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 
 #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
 bool arch_hugetlb_migration_supported(struct hstate *h);
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index deb198a61039..ce5f4fe8be4d 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -39,11 +39,11 @@ static inline int prepare_hugepage_range(struct file *file,
 	return 0;
 }
 
-static inline void arch_clear_hugepage_flags(struct page *page)
+static inline void arch_clear_hugetlb_flags(struct folio *folio)
 {
-	clear_bit(PG_arch_1, &page->flags);
+	clear_bit(PG_arch_1, &folio->flags);
 }
-#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 
 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
 				  pte_t *ptep, unsigned long sz)
diff --git a/arch/sh/include/asm/hugetlb.h b/arch/sh/include/asm/hugetlb.h
index 4d3ba39e681c..75028bd568ba 100644
--- a/arch/sh/include/asm/hugetlb.h
+++ b/arch/sh/include/asm/hugetlb.h
@@ -27,11 +27,11 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
 	return *ptep;
 }
 
-static inline void arch_clear_hugepage_flags(struct page *page)
+static inline void arch_clear_hugetlb_flags(struct folio *folio)
 {
-	clear_bit(PG_dcache_clean, &page->flags);
+	clear_bit(PG_dcache_clean, &folio->flags);
 }
-#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 
 #include <asm-generic/hugetlb.h>
 
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index d748628efc5e..cc420c42a773 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -837,8 +837,8 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 #endif
 
 #ifndef arch_clear_hugepage_flags
-static inline void arch_clear_hugepage_flags(struct page *page) { }
-#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+static inline void arch_clear_hugetlb_flags(struct folio *folio) { }
+#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 #endif
 
 #ifndef arch_make_huge_pte
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f9640a81226e..0fdbd1f6c575 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1726,7 +1726,7 @@ static void add_hugetlb_folio(struct hstate *h, struct folio *folio,
 		 */
 		return;
 
-	arch_clear_hugepage_flags(&folio->page);
+	arch_clear_hugetlb_flags(folio);
 	enqueue_hugetlb_folio(h, folio);
 }
 
@@ -2024,7 +2024,7 @@ void free_huge_folio(struct folio *folio)
 		spin_unlock_irqrestore(&hugetlb_lock, flags);
 		update_and_free_hugetlb_folio(h, folio, true);
 	} else {
-		arch_clear_hugepage_flags(&folio->page);
+		arch_clear_hugetlb_flags(folio);
 		enqueue_hugetlb_folio(h, folio);
 		spin_unlock_irqrestore(&hugetlb_lock, flags);
 	}
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/10] slub: Remove use of page->flags
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (6 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-04-04 18:29   ` David Hildenbrand
  2024-03-26 17:10 ` [PATCH 09/10] Remove references to page->flags in documentation Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 10/10] proc: Rewrite stable_page_flags() Matthew Wilcox (Oracle)
  9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

Use slub->__page_flags instead.  We can also remove the assertion that
it's not a tail page as struct slab never points to a tail page.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/slub.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index ceee8d76e1a9..1500546a9b68 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -616,18 +616,12 @@ slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects)
  */
 static __always_inline void slab_lock(struct slab *slab)
 {
-	struct page *page = slab_page(slab);
-
-	VM_BUG_ON_PAGE(PageTail(page), page);
-	bit_spin_lock(PG_locked, &page->flags);
+	bit_spin_lock(PG_locked, &slab->__page_flags);
 }
 
 static __always_inline void slab_unlock(struct slab *slab)
 {
-	struct page *page = slab_page(slab);
-
-	VM_BUG_ON_PAGE(PageTail(page), page);
-	bit_spin_unlock(PG_locked, &page->flags);
+	bit_spin_unlock(PG_locked, &slab->__page_flags);
 }
 
 static inline bool
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/10] Remove references to page->flags in documentation
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (7 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 08/10] slub: Remove use of page->flags Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  2024-03-26 17:10 ` [PATCH 10/10] proc: Rewrite stable_page_flags() Matthew Wilcox (Oracle)
  9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm

Mostly rewording, but remove entirely the copy of page_fixed_fake_head()
in the documentation; we can refer people to the actual source if
necessary.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 .../admin-guide/cgroup-v1/memory.rst          |  4 ++--
 Documentation/mm/vmemmap_dedup.rst            | 22 +------------------
 .../translations/zh_CN/core-api/cachetlb.rst  |  2 +-
 mm/migrate.c                                  |  2 +-
 mm/rmap.c                                     |  4 ++--
 5 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst
index ca7d9402f6be..46110e6a31bb 100644
--- a/Documentation/admin-guide/cgroup-v1/memory.rst
+++ b/Documentation/admin-guide/cgroup-v1/memory.rst
@@ -300,14 +300,14 @@ When oom event notifier is registered, event will be delivered.
 
 Lock order is as follows::
 
-  Page lock (PG_locked bit of page->flags)
+  folio_lock
     mm->page_table_lock or split pte_lock
       folio_memcg_lock (memcg->move_lock)
         mapping->i_pages lock
           lruvec->lru_lock.
 
 Per-node-per-memcgroup LRU (cgroup's private LRU) is guarded by
-lruvec->lru_lock; PG_lru bit of page->flags is cleared before
+lruvec->lru_lock; the folio LRU flag is cleared before
 isolating a page from its LRU under lruvec->lru_lock.
 
 .. _cgroup-v1-memory-kernel-extension:
diff --git a/Documentation/mm/vmemmap_dedup.rst b/Documentation/mm/vmemmap_dedup.rst
index 593ede6d314b..b4a55b6569fa 100644
--- a/Documentation/mm/vmemmap_dedup.rst
+++ b/Documentation/mm/vmemmap_dedup.rst
@@ -180,27 +180,7 @@ this correctly. There is only **one** head ``struct page``, the tail
 ``struct page`` with ``PG_head`` are fake head ``struct page``.  We need an
 approach to distinguish between those two different types of ``struct page`` so
 that ``compound_head()`` can return the real head ``struct page`` when the
-parameter is the tail ``struct page`` but with ``PG_head``. The following code
-snippet describes how to distinguish between real and fake head ``struct page``.
-
-.. code-block:: c
-
-	if (test_bit(PG_head, &page->flags)) {
-		unsigned long head = READ_ONCE(page[1].compound_head);
-
-		if (head & 1) {
-			if (head == (unsigned long)page + 1)
-				/* head struct page */
-			else
-				/* tail struct page */
-		} else {
-			/* head struct page */
-		}
-	}
-
-We can safely access the field of the **page[1]** with ``PG_head`` because the
-page is a compound page composed with at least two contiguous pages.
-The implementation refers to ``page_fixed_fake_head()``.
+parameter is the tail ``struct page`` but with ``PG_head``.
 
 Device DAX
 ==========
diff --git a/Documentation/translations/zh_CN/core-api/cachetlb.rst b/Documentation/translations/zh_CN/core-api/cachetlb.rst
index b4a76ec75daa..64295c61d1c1 100644
--- a/Documentation/translations/zh_CN/core-api/cachetlb.rst
+++ b/Documentation/translations/zh_CN/core-api/cachetlb.rst
@@ -260,7 +260,7 @@ HyperSparc cpu就是这样一个具有这种属性的cpu。
 	如果D-cache别名不是一个问题,这个程序可以简单地定义为该架构上
 	的nop。
 
-	在page->flags (PG_arch_1)中有一个位是“架构私有”。内核保证,
+	在folio->flags (PG_arch_1)中有一个位是“架构私有”。内核保证,
 	对于分页缓存的页面,当这样的页面第一次进入分页缓存时,它将清除
 	这个位。
 
diff --git a/mm/migrate.c b/mm/migrate.c
index 6dc73c438717..5c546583594d 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -113,7 +113,7 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode)
 	if (!mops->isolate_page(&folio->page, mode))
 		goto out_no_isolated;
 
-	/* Driver shouldn't use PG_isolated bit of page->flags */
+	/* Driver shouldn't use the isolated flag */
 	WARN_ON_ONCE(folio_test_isolated(folio));
 	folio_set_isolated(folio);
 	folio_unlock(folio);
diff --git a/mm/rmap.c b/mm/rmap.c
index d52759aa3ff7..5ee9e338d09b 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -23,7 +23,7 @@
  * inode->i_rwsem	(while writing or truncating, not reading or faulting)
  *   mm->mmap_lock
  *     mapping->invalidate_lock (in filemap_fault)
- *       page->flags PG_locked (lock_page)
+ *       folio_lock
  *         hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share, see hugetlbfs below)
  *           vma_start_write
  *             mapping->i_mmap_rwsem
@@ -50,7 +50,7 @@
  *   hugetlb_fault_mutex (hugetlbfs specific page fault mutex)
  *     vma_lock (hugetlb specific lock for pmd_sharing)
  *       mapping->i_mmap_rwsem (also used for hugetlb pmd sharing)
- *         page->flags PG_locked (lock_page)
+ *         folio_lock
  */
 
 #include <linux/mm.h>
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/10] proc: Rewrite stable_page_flags()
  2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
                   ` (8 preceding siblings ...)
  2024-03-26 17:10 ` [PATCH 09/10] Remove references to page->flags in documentation Matthew Wilcox (Oracle)
@ 2024-03-26 17:10 ` Matthew Wilcox (Oracle)
  9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-03-26 17:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-mm, Svetly Todorov

Reduce the usage of PageFlag tests and reduce the number of
compound_head() calls.

For multi-page folios, we'll now show all pages as having the flags that
apply to them, e.g. if it's dirty, all pages will have the dirty flag
set instead of just the head page.  The mapped flag is still per page,
as is the hwpoison flag.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Svetly Todorov <svetly.todorov@memverge.com>
---
 fs/proc/page.c             | 66 ++++++++++++++++++++------------------
 include/linux/huge_mm.h    |  4 +--
 include/linux/page-flags.h |  2 +-
 3 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/fs/proc/page.c b/fs/proc/page.c
index 9223856c934b..d6953f95e3b4 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -107,10 +107,13 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit)
 	return ((kflags >> kbit) & 1) << ubit;
 }
 
-u64 stable_page_flags(struct page *page)
+u64 stable_page_flags(const struct page *page)
 {
-	u64 k;
-	u64 u;
+	const struct folio *folio;
+	unsigned long k;
+	unsigned long mapping;
+	bool is_anon;
+	u64 u = 0;
 
 	/*
 	 * pseudo flag: KPF_NOPAGE
@@ -118,49 +121,47 @@ u64 stable_page_flags(struct page *page)
 	 */
 	if (!page)
 		return 1 << KPF_NOPAGE;
+	folio = page_folio(page);
 
-	k = page->flags;
-	u = 0;
+	k = folio->flags;
+	mapping = (unsigned long)folio->mapping;
+	is_anon = mapping & PAGE_MAPPING_ANON;
 
 	/*
 	 * pseudo flags for the well known (anonymous) memory mapped pages
 	 */
 	if (page_mapped(page))
 		u |= 1 << KPF_MMAP;
-	if (PageAnon(page))
+	if (is_anon) {
 		u |= 1 << KPF_ANON;
-	if (PageKsm(page))
-		u |= 1 << KPF_KSM;
+		if (mapping & PAGE_MAPPING_KSM)
+			u |= 1 << KPF_KSM;
+	}
 
 	/*
 	 * compound pages: export both head/tail info
 	 * they together define a compound page's start/end pos and order
 	 */
-	if (PageHead(page))
-		u |= 1 << KPF_COMPOUND_HEAD;
-	if (PageTail(page))
+	if (page == &folio->page)
+		u |= kpf_copy_bit(k, KPF_COMPOUND_HEAD, PG_head);
+	else
 		u |= 1 << KPF_COMPOUND_TAIL;
-	if (PageHuge(page))
+	if (folio_test_hugetlb(folio))
 		u |= 1 << KPF_HUGE;
 	/*
-	 * PageTransCompound can be true for non-huge compound pages (slab
-	 * pages or pages allocated by drivers with __GFP_COMP) because it
-	 * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon
+	 * We need to check PageLRU/PageAnon
 	 * to make sure a given page is a thp, not a non-huge compound page.
 	 */
-	else if (PageTransCompound(page)) {
-		struct page *head = compound_head(page);
-
-		if (PageLRU(head) || PageAnon(head))
+	else if (folio_test_large(folio)) {
+		if ((k & PG_lru) || is_anon)
 			u |= 1 << KPF_THP;
-		else if (is_huge_zero_page(head)) {
+		else if (is_huge_zero_page(&folio->page)) {
 			u |= 1 << KPF_ZERO_PAGE;
 			u |= 1 << KPF_THP;
 		}
 	} else if (is_zero_pfn(page_to_pfn(page)))
 		u |= 1 << KPF_ZERO_PAGE;
 
-
 	/*
 	 * Caveats on high order pages: PG_buddy and PG_slab will only be set
 	 * on the head page.
@@ -175,15 +176,15 @@ u64 stable_page_flags(struct page *page)
 	if (PageTable(page))
 		u |= 1 << KPF_PGTABLE;
 
-	if (page_is_idle(page))
+#if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT)
+	u |= kpf_copy_bit(k, KPF_IDLE,          PG_idle);
+#else
+	if (folio_test_idle(folio))
 		u |= 1 << KPF_IDLE;
+#endif
 
 	u |= kpf_copy_bit(k, KPF_LOCKED,	PG_locked);
-
 	u |= kpf_copy_bit(k, KPF_SLAB,		PG_slab);
-	if (PageTail(page) && PageSlab(page))
-		u |= 1 << KPF_SLAB;
-
 	u |= kpf_copy_bit(k, KPF_ERROR,		PG_error);
 	u |= kpf_copy_bit(k, KPF_DIRTY,		PG_dirty);
 	u |= kpf_copy_bit(k, KPF_UPTODATE,	PG_uptodate);
@@ -194,7 +195,8 @@ u64 stable_page_flags(struct page *page)
 	u |= kpf_copy_bit(k, KPF_ACTIVE,	PG_active);
 	u |= kpf_copy_bit(k, KPF_RECLAIM,	PG_reclaim);
 
-	if (PageSwapCache(page))
+#define SWAPCACHE ((1 << PG_swapbacked) | (1 << PG_swapcache))
+	if ((k & SWAPCACHE) == SWAPCACHE)
 		u |= 1 << KPF_SWAPCACHE;
 	u |= kpf_copy_bit(k, KPF_SWAPBACKED,	PG_swapbacked);
 
@@ -202,7 +204,10 @@ u64 stable_page_flags(struct page *page)
 	u |= kpf_copy_bit(k, KPF_MLOCKED,	PG_mlocked);
 
 #ifdef CONFIG_MEMORY_FAILURE
-	u |= kpf_copy_bit(k, KPF_HWPOISON,	PG_hwpoison);
+	if (u & KPF_HUGE)
+		u |= kpf_copy_bit(k, KPF_HWPOISON,	PG_hwpoison);
+	else
+		u |= kpf_copy_bit(page->flags, KPF_HWPOISON,	PG_hwpoison);
 #endif
 
 #ifdef CONFIG_ARCH_USES_PG_UNCACHED
@@ -228,7 +233,6 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
 {
 	const unsigned long max_dump_pfn = get_max_dump_pfn();
 	u64 __user *out = (u64 __user *)buf;
-	struct page *ppage;
 	unsigned long src = *ppos;
 	unsigned long pfn;
 	ssize_t ret = 0;
@@ -245,9 +249,9 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
 		 * TODO: ZONE_DEVICE support requires to identify
 		 * memmaps that were actually initialized.
 		 */
-		ppage = pfn_to_online_page(pfn);
+		struct page *page = pfn_to_online_page(pfn);
 
-		if (put_user(stable_page_flags(ppage), out)) {
+		if (put_user(stable_page_flags(page), out)) {
 			ret = -EFAULT;
 			break;
 		}
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 7576025db55d..1540a1481daf 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -351,7 +351,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf);
 extern struct page *huge_zero_page;
 extern unsigned long huge_zero_pfn;
 
-static inline bool is_huge_zero_page(struct page *page)
+static inline bool is_huge_zero_page(const struct page *page)
 {
 	return READ_ONCE(huge_zero_page) == page;
 }
@@ -480,7 +480,7 @@ static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
 	return 0;
 }
 
-static inline bool is_huge_zero_page(struct page *page)
+static inline bool is_huge_zero_page(const struct page *page)
 {
 	return false;
 }
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index eaecf544039f..888353c209c0 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -734,7 +734,7 @@ static __always_inline bool PageKsm(const struct page *page)
 TESTPAGEFLAG_FALSE(Ksm, ksm)
 #endif
 
-u64 stable_page_flags(struct page *page);
+u64 stable_page_flags(const struct page *page);
 
 /**
  * folio_xor_flags_has_waiters - Change some folio flags.
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
  2024-03-26 17:10 ` [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Matthew Wilcox (Oracle)
@ 2024-03-27 13:02   ` Ryan Roberts
  2024-03-27 14:37     ` Matthew Wilcox
  2024-03-27 15:48   ` kernel test robot
  2024-03-27 17:01   ` kernel test robot
  2 siblings, 1 reply; 20+ messages in thread
From: Ryan Roberts @ 2024-03-27 13:02 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm

Hi Matthew,

On 26/03/2024 17:10, Matthew Wilcox (Oracle) wrote:
> All implementations that aren't no-ops just set a bit in the flags,
> and we want to use the folio flags rather than the page flags for that.
> Rename it to arch_clear_hugetlb_flags() while we're touching it so nobody
> thinks it's used for THP.
> 

[...]

> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index d748628efc5e..cc420c42a773 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -837,8 +837,8 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
>  #endif
>  
>  #ifndef arch_clear_hugepage_flags

You need to update this line to the new name. Currently failing to build on
arm64 since it now defines the new arch_clear_hugetlb_flags.

> -static inline void arch_clear_hugepage_flags(struct page *page) { }
> -#define arch_clear_hugepage_flags arch_clear_hugepage_flags
> +static inline void arch_clear_hugetlb_flags(struct folio *folio) { }
> +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
>  #endif

Thanks,
Ryan




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
  2024-03-27 13:02   ` Ryan Roberts
@ 2024-03-27 14:37     ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2024-03-27 14:37 UTC (permalink / raw)
  To: Ryan Roberts; +Cc: Andrew Morton, linux-mm

On Wed, Mar 27, 2024 at 01:02:24PM +0000, Ryan Roberts wrote:
> >  #ifndef arch_clear_hugepage_flags
> 
> You need to update this line to the new name. Currently failing to build on
> arm64 since it now defines the new arch_clear_hugetlb_flags.

Oops.  Andrew, please add -fix:

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 5001d1b6c46d..1a17d03b2fa5 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -836,7 +836,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 #define is_hugepage_only_range is_hugepage_only_range
 #endif
 
-#ifndef arch_clear_hugepage_flags
+#ifndef arch_clear_hugetlb_flags
 static inline void arch_clear_hugetlb_flags(struct folio *folio) { }
 #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 #endif


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
  2024-03-26 17:10 ` [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Matthew Wilcox (Oracle)
  2024-03-27 13:02   ` Ryan Roberts
@ 2024-03-27 15:48   ` kernel test robot
  2024-03-27 17:01   ` kernel test robot
  2 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2024-03-27 15:48 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton
  Cc: llvm, oe-kbuild-all, Linux Memory Management List,
	Matthew Wilcox (Oracle)

Hi Matthew,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on next-20240327]
[cannot apply to jcmvbkbc-xtensa/xtensa-for-next arm64/for-next/core s390/features tj-cgroup/for-next linus/master vbabka-slab/for-next v6.9-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/sh-Remove-use-of-PG_arch_1-on-individual-pages/20240327-011221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240326171045.410737-8-willy%40infradead.org
patch subject: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20240327/202403272336.lPdKvPYd-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 23de3862dce582ce91c1aa914467d982cb1a73b4)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240327/202403272336.lPdKvPYd-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403272336.lPdKvPYd-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/riscv/mm/init.c:10:
   In file included from include/linux/mm.h:2239:
   include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from arch/riscv/mm/init.c:22:
   include/linux/hugetlb.h:840:20: error: redefinition of 'arch_clear_hugetlb_flags'
     840 | static inline void arch_clear_hugetlb_flags(struct folio *folio) { }
         |                    ^
   arch/riscv/include/asm/hugetlb.h:12:34: note: expanded from macro 'arch_clear_hugetlb_flags'
      12 | #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
         |                                  ^
   arch/riscv/include/asm/hugetlb.h:8:20: note: previous definition is here
       8 | static inline void arch_clear_hugetlb_flags(struct folio *folio)
         |                    ^
>> arch/riscv/mm/init.c:112:22: warning: implicit conversion from 'unsigned long long' to 'u32' (aka 'unsigned int') changes value from 1099511627776 to 0 [-Wconstant-conversion]
     112 |                    (((t) - (b)) >> LOG2_SZ_1T));
         |                                    ^~~~~~~~~~
   include/linux/printk.h:520:36: note: expanded from macro 'pr_notice'
     520 |         printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
         |                                           ^~~~~~~~~~~
   include/linux/printk.h:457:60: note: expanded from macro 'printk'
     457 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
         |                                                            ^~~~~~~~~~~
   include/linux/printk.h:429:19: note: expanded from macro 'printk_index_wrap'
     429 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                                 ^~~~~~~~~~~
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/uapi/linux/const.h:20:20: note: expanded from macro '__AC'
      20 | #define __AC(X,Y)       (X##Y)
         |                          ^~~~
   <scratch space>:5:1: note: expanded from here
       5 | 0x10000000000ULL
         | ^~~~~~~~~~~~~~~~
   include/linux/log2.h:162:14: note: expanded from macro 'ilog2'
     162 |         __ilog2_u32(n) :                \
         |         ~~~~~~~~~~~ ^
   arch/riscv/mm/init.c:122:43: warning: implicit conversion from 'unsigned long long' to 'u32' (aka 'unsigned int') changes value from 1099511627776 to 0 [-Wconstant-conversion]
     122 |         if (IS_ENABLED(CONFIG_64BIT) && (diff >> LOG2_SZ_1T) >= 10)
         |                                                  ^~~~~~~~~~
   arch/riscv/mm/init.c:88:27: note: expanded from macro 'LOG2_SZ_1T'
      88 | #define LOG2_SZ_1T  ilog2(SZ_1T)
         |                     ~~~~~~^~~~~~
   include/linux/sizes.h:55:18: note: expanded from macro 'SZ_1T'
      55 | #define SZ_1T                           _AC(0x10000000000, ULL)
         |                                         ^~~~~~~~~~~~~~~~~~~~~~~
   include/uapi/linux/const.h:21:18: note: expanded from macro '_AC'
      21 | #define _AC(X,Y)        __AC(X,Y)
         |                         ^~~~~~~~~
   include/uapi/linux/const.h:20:20: note: expanded from macro '__AC'
      20 | #define __AC(X,Y)       (X##Y)
         |                          ^~~~
   <scratch space>:10:1: note: expanded from here
      10 | 0x10000000000ULL
         | ^~~~~~~~~~~~~~~~
   include/linux/log2.h:162:14: note: expanded from macro 'ilog2'
     162 |         __ilog2_u32(n) :                \
         |         ~~~~~~~~~~~ ^
   3 warnings and 1 error generated.


vim +112 arch/riscv/mm/init.c

26b8f69edda85a Alexandre Ghiti 2021-12-06  107  
26b8f69edda85a Alexandre Ghiti 2021-12-06  108  #ifdef CONFIG_64BIT
26b8f69edda85a Alexandre Ghiti 2021-12-06  109  static inline void print_mlt(char *name, unsigned long b, unsigned long t)
26b8f69edda85a Alexandre Ghiti 2021-12-06  110  {
26b8f69edda85a Alexandre Ghiti 2021-12-06  111  	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld TB)\n", name, b, t,
26b8f69edda85a Alexandre Ghiti 2021-12-06 @112  		   (((t) - (b)) >> LOG2_SZ_1T));
26b8f69edda85a Alexandre Ghiti 2021-12-06  113  }
26b8f69edda85a Alexandre Ghiti 2021-12-06  114  #else
26b8f69edda85a Alexandre Ghiti 2021-12-06  115  #define print_mlt(n, b, t) do {} while (0)
26b8f69edda85a Alexandre Ghiti 2021-12-06  116  #endif
26b8f69edda85a Alexandre Ghiti 2021-12-06  117  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
  2024-03-26 17:10 ` [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Matthew Wilcox (Oracle)
  2024-03-27 13:02   ` Ryan Roberts
  2024-03-27 15:48   ` kernel test robot
@ 2024-03-27 17:01   ` kernel test robot
  2 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2024-03-27 17:01 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton
  Cc: oe-kbuild-all, Linux Memory Management List, Matthew Wilcox (Oracle)

Hi Matthew,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on next-20240327]
[cannot apply to jcmvbkbc-xtensa/xtensa-for-next arm64/for-next/core s390/features tj-cgroup/for-next linus/master vbabka-slab/for-next v6.9-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/sh-Remove-use-of-PG_arch_1-on-individual-pages/20240327-011221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240326171045.410737-8-willy%40infradead.org
patch subject: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio
config: riscv-randconfig-r064-20240327 (https://download.01.org/0day-ci/archive/20240328/202403280031.hBtWedPW-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240328/202403280031.hBtWedPW-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403280031.hBtWedPW-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/hugetlb.h:828,
                    from mm/filemap.c:37:
>> arch/riscv/include/asm/hugetlb.h:12:34: error: redefinition of 'arch_clear_hugetlb_flags'
      12 | #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
         |                                  ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/hugetlb.h:840:20: note: in expansion of macro 'arch_clear_hugetlb_flags'
     840 | static inline void arch_clear_hugetlb_flags(struct folio *folio) { }
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/hugetlb.h:8:20: note: previous definition of 'arch_clear_hugetlb_flags' with type 'void(struct folio *)'
       8 | static inline void arch_clear_hugetlb_flags(struct folio *folio)
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~


vim +/arch_clear_hugetlb_flags +12 arch/riscv/include/asm/hugetlb.h

     7	
     8	static inline void arch_clear_hugetlb_flags(struct folio *folio)
     9	{
    10		clear_bit(PG_dcache_clean, &folio->flags);
    11	}
  > 12	#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
    13	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages
  2024-03-26 17:10 ` [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages Matthew Wilcox (Oracle)
@ 2024-03-27 18:45   ` kernel test robot
  2024-03-27 18:49     ` Matthew Wilcox
  0 siblings, 1 reply; 20+ messages in thread
From: kernel test robot @ 2024-03-27 18:45 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton
  Cc: oe-kbuild-all, Linux Memory Management List, Matthew Wilcox (Oracle)

Hi Matthew,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on jcmvbkbc-xtensa/xtensa-for-next arm64/for-next/core s390/features tj-cgroup/for-next linus/master vbabka-slab/for-next v6.9-rc1 next-20240327]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/sh-Remove-use-of-PG_arch_1-on-individual-pages/20240327-011221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240326171045.410737-2-willy%40infradead.org
patch subject: [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages
config: sh-defconfig (https://download.01.org/0day-ci/archive/20240328/202403280209.6eW34UZ5-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240328/202403280209.6eW34UZ5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403280209.6eW34UZ5-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/thread_info.h:27,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/sh/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:79,
                    from include/linux/spinlock.h:56,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:7,
                    from include/linux/mm.h:7,
                    from arch/sh/mm/cache-sh4.c:14:
   arch/sh/mm/cache-sh4.c: In function 'sh4_flush_cache_page':
>> arch/sh/mm/cache-sh4.c:250:51: error: too few arguments to function 'folio_flags'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                                                   ^~~~~~~~~~~
   include/linux/bitops.h:50:44: note: in definition of macro 'bitop'
      50 |           __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
         |                                            ^~~~
   arch/sh/mm/cache-sh4.c:250:25: note: in expansion of macro 'test_bit'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                         ^~~~~~~~
   In file included from include/linux/mmzone.h:23:
   include/linux/page-flags.h:317:23: note: declared here
     317 | static unsigned long *folio_flags(struct folio *folio, unsigned n)
         |                       ^~~~~~~~~~~
>> arch/sh/mm/cache-sh4.c:250:51: error: too few arguments to function 'folio_flags'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                                                   ^~~~~~~~~~~
   include/linux/bitops.h:51:23: note: in definition of macro 'bitop'
      51 |           (uintptr_t)(addr) != (uintptr_t)NULL &&                       \
         |                       ^~~~
   arch/sh/mm/cache-sh4.c:250:25: note: in expansion of macro 'test_bit'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                         ^~~~~~~~
   include/linux/page-flags.h:317:23: note: declared here
     317 | static unsigned long *folio_flags(struct folio *folio, unsigned n)
         |                       ^~~~~~~~~~~
>> arch/sh/mm/cache-sh4.c:250:51: error: too few arguments to function 'folio_flags'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                                                   ^~~~~~~~~~~
   include/linux/bitops.h:52:57: note: in definition of macro 'bitop'
      52 |           __builtin_constant_p(*(const unsigned long *)(addr))) ?       \
         |                                                         ^~~~
   arch/sh/mm/cache-sh4.c:250:25: note: in expansion of macro 'test_bit'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                         ^~~~~~~~
   include/linux/page-flags.h:317:23: note: declared here
     317 | static unsigned long *folio_flags(struct folio *folio, unsigned n)
         |                       ^~~~~~~~~~~
>> arch/sh/mm/cache-sh4.c:250:51: error: too few arguments to function 'folio_flags'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                                                   ^~~~~~~~~~~
   include/linux/bitops.h:53:24: note: in definition of macro 'bitop'
      53 |          const##op(nr, addr) : op(nr, addr))
         |                        ^~~~
   arch/sh/mm/cache-sh4.c:250:25: note: in expansion of macro 'test_bit'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                         ^~~~~~~~
   include/linux/page-flags.h:317:23: note: declared here
     317 | static unsigned long *folio_flags(struct folio *folio, unsigned n)
         |                       ^~~~~~~~~~~
>> arch/sh/mm/cache-sh4.c:250:51: error: too few arguments to function 'folio_flags'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                                                   ^~~~~~~~~~~
   include/linux/bitops.h:53:39: note: in definition of macro 'bitop'
      53 |          const##op(nr, addr) : op(nr, addr))
         |                                       ^~~~
   arch/sh/mm/cache-sh4.c:250:25: note: in expansion of macro 'test_bit'
     250 |                         test_bit(PG_dcache_clean, folio_flags(folio)) &&
         |                         ^~~~~~~~
   include/linux/page-flags.h:317:23: note: declared here
     317 | static unsigned long *folio_flags(struct folio *folio, unsigned n)
         |                       ^~~~~~~~~~~
   arch/sh/mm/cache-sh4.c: In function 'sh4_flush_cache_range':
   arch/sh/mm/cache-sh4.c:287:30: warning: variable 'end' set but not used [-Wunused-but-set-variable]
     287 |         unsigned long start, end;
         |                              ^~~
   arch/sh/mm/cache-sh4.c:287:23: warning: variable 'start' set but not used [-Wunused-but-set-variable]
     287 |         unsigned long start, end;
         |                       ^~~~~
   arch/sh/mm/cache-sh4.c: At top level:
   arch/sh/mm/cache-sh4.c:385:13: warning: no previous prototype for 'sh4_cache_init' [-Wmissing-prototypes]
     385 | void __init sh4_cache_init(void)
         |             ^~~~~~~~~~~~~~


vim +/folio_flags +250 arch/sh/mm/cache-sh4.c

   207	
   208	/*
   209	 * Write back and invalidate I/D-caches for the page.
   210	 *
   211	 * ADDR: Virtual Address (U0 address)
   212	 * PFN: Physical page number
   213	 */
   214	static void sh4_flush_cache_page(void *args)
   215	{
   216		struct flusher_data *data = args;
   217		struct vm_area_struct *vma;
   218		struct page *page;
   219		unsigned long address, pfn, phys;
   220		int map_coherent = 0;
   221		pmd_t *pmd;
   222		pte_t *pte;
   223		void *vaddr;
   224	
   225		vma = data->vma;
   226		address = data->addr1 & PAGE_MASK;
   227		pfn = data->addr2;
   228		phys = pfn << PAGE_SHIFT;
   229		page = pfn_to_page(pfn);
   230	
   231		if (cpu_context(smp_processor_id(), vma->vm_mm) == NO_CONTEXT)
   232			return;
   233	
   234		pmd = pmd_off(vma->vm_mm, address);
   235		pte = pte_offset_kernel(pmd, address);
   236	
   237		/* If the page isn't present, there is nothing to do here. */
   238		if (!(pte_val(*pte) & _PAGE_PRESENT))
   239			return;
   240	
   241		if ((vma->vm_mm == current->active_mm))
   242			vaddr = NULL;
   243		else {
   244			struct folio *folio = page_folio(page);
   245			/*
   246			 * Use kmap_coherent or kmap_atomic to do flushes for
   247			 * another ASID than the current one.
   248			 */
   249			map_coherent = (current_cpu_data.dcache.n_aliases &&
 > 250				test_bit(PG_dcache_clean, folio_flags(folio)) &&
   251				page_mapped(page));
   252			if (map_coherent)
   253				vaddr = kmap_coherent(page, address);
   254			else
   255				vaddr = kmap_atomic(page);
   256	
   257			address = (unsigned long)vaddr;
   258		}
   259	
   260		flush_cache_one(CACHE_OC_ADDRESS_ARRAY |
   261				(address & shm_align_mask), phys);
   262	
   263		if (vma->vm_flags & VM_EXEC)
   264			flush_icache_all();
   265	
   266		if (vaddr) {
   267			if (map_coherent)
   268				kunmap_coherent(vaddr);
   269			else
   270				kunmap_atomic(vaddr);
   271		}
   272	}
   273	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages
  2024-03-27 18:45   ` kernel test robot
@ 2024-03-27 18:49     ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2024-03-27 18:49 UTC (permalink / raw)
  To: kernel test robot
  Cc: Andrew Morton, oe-kbuild-all, Linux Memory Management List

On Thu, Mar 28, 2024 at 02:45:40AM +0800, kernel test robot wrote:
> Hi Matthew,
> 
> kernel test robot noticed the following build errors:

Guess who doesn't actually build for sh4 because it's a dead
architecture?

Andrew, please include this fixup:

diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index cea8f1693908..9a1e581cd192 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -247,7 +247,7 @@ static void sh4_flush_cache_page(void *args)
 		 * another ASID than the current one.
 		 */
 		map_coherent = (current_cpu_data.dcache.n_aliases &&
-			test_bit(PG_dcache_clean, folio_flags(folio)) &&
+			test_bit(PG_dcache_clean, folio_flags(folio, 0)) &&
 			page_mapped(page));
 		if (map_coherent)
 			vaddr = kmap_coherent(page, address);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 5001d1b6c46d..1a17d03b2fa5 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -836,7 +836,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 #define is_hugepage_only_range is_hugepage_only_range
 #endif
 
-#ifndef arch_clear_hugepage_flags
+#ifndef arch_clear_hugetlb_flags
 static inline void arch_clear_hugetlb_flags(struct folio *folio) { }
 #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
 #endif

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 02/10] xtensa: Remove uses of PG_arch_1 on individual pages
  2024-03-26 17:10 ` [PATCH 02/10] xtensa: Remove uses " Matthew Wilcox (Oracle)
@ 2024-03-28 19:36   ` Svetly Todorov
  2024-03-28 19:40     ` Matthew Wilcox
  0 siblings, 1 reply; 20+ messages in thread
From: Svetly Todorov @ 2024-03-28 19:36 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm

The fix for this particular file looks good,
but some other architectures still use page->flags
to test/set PG_arch_1 aliases:

./arch/arc/include/asm/cacheflush.h:#define PG_dc_clean PG_arch_1
./arch/arm/include/asm/cacheflush.h:#define PG_dcache_clean PG_arch_1
./arch/arm64/include/asm/cacheflush.h:#define PG_dcache_clean PG_arch_1

(in arch): grep -rI . -e 'page->flags'

./s390/include/asm/hugetlb.h:   clear_bit(PG_arch_1, &page->flags);
./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
./s390/kernel/uv.c:     set_bit(PG_arch_1, &page->flags);
./s390/kernel/uv.c:     if (!test_bit(PG_arch_1, &page->flags))
./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
./s390/mm/gmap.c:       set_bit(PG_arch_1, &page->flags);
./s390/mm/hugetlbpage.c: if (!test_and_set_bit(PG_arch_1, &page->flags))
./sh/include/asm/hugetlb.h: clear_bit(PG_dcache_clean, &page->flags);
./sh/mm/cache-sh4.c:     test_bit(PG_dcache_clean, &page->flags) &&

... (not an exhaustive list) ...

But at least for xtensa, this LGTM.

Reviewed-by: Svetly Todorov <svetly.todorov@memverge.com>

Svetly


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 02/10] xtensa: Remove uses of PG_arch_1 on individual pages
  2024-03-28 19:36   ` Svetly Todorov
@ 2024-03-28 19:40     ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2024-03-28 19:40 UTC (permalink / raw)
  To: Svetly Todorov; +Cc: Andrew Morton, linux-mm

On Thu, Mar 28, 2024 at 12:36:30PM -0700, Svetly Todorov wrote:
> The fix for this particular file looks good,
> but some other architectures still use page->flags
> to test/set PG_arch_1 aliases:
> 
> ./arch/arc/include/asm/cacheflush.h:#define PG_dc_clean PG_arch_1
> ./arch/arm/include/asm/cacheflush.h:#define PG_dcache_clean PG_arch_1
> ./arch/arm64/include/asm/cacheflush.h:#define PG_dcache_clean PG_arch_1
> 
> (in arch): grep -rI . -e 'page->flags'
> 
> ./s390/include/asm/hugetlb.h:   clear_bit(PG_arch_1, &page->flags);
> ./s390/mm/hugetlbpage.c: if (!test_and_set_bit(PG_arch_1, &page->flags))
> ./sh/include/asm/hugetlb.h: clear_bit(PG_dcache_clean, &page->flags);
> ./sh/mm/cache-sh4.c:     test_bit(PG_dcache_clean, &page->flags) &&

Fixed elsewhere in this patch series.

> ./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
> ./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
> ./s390/kernel/uv.c:     set_bit(PG_arch_1, &page->flags);
> ./s390/kernel/uv.c:     if (!test_bit(PG_arch_1, &page->flags))
> ./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
> ./s390/kernel/uv.c:             clear_bit(PG_arch_1, &page->flags);
> ./s390/mm/gmap.c:       set_bit(PG_arch_1, &page->flags);
> 
> ... (not an exhaustive list) ...

s390 is a disaster area for use of page->flags.  I've sent patches
with no response or "we can't do that" responses.  I'm ignoring them
until I get more useful responses.

> But at least for xtensa, this LGTM.
> 
> Reviewed-by: Svetly Todorov <svetly.todorov@memverge.com>

Thanks.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/10] slub: Remove use of page->flags
  2024-03-26 17:10 ` [PATCH 08/10] slub: Remove use of page->flags Matthew Wilcox (Oracle)
@ 2024-04-04 18:29   ` David Hildenbrand
  0 siblings, 0 replies; 20+ messages in thread
From: David Hildenbrand @ 2024-04-04 18:29 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-mm

On 26.03.24 18:10, Matthew Wilcox (Oracle) wrote:
> Use slub->__page_flags instead.  We can also remove the assertion that
> it's not a tail page as struct slab never points to a tail page.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   mm/slub.c | 10 ++--------
>   1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index ceee8d76e1a9..1500546a9b68 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -616,18 +616,12 @@ slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects)
>    */
>   static __always_inline void slab_lock(struct slab *slab)
>   {
> -	struct page *page = slab_page(slab);
> -
> -	VM_BUG_ON_PAGE(PageTail(page), page);
> -	bit_spin_lock(PG_locked, &page->flags);
> +	bit_spin_lock(PG_locked, &slab->__page_flags);
>   }
>   
>   static __always_inline void slab_unlock(struct slab *slab)
>   {
> -	struct page *page = slab_page(slab);
> -
> -	VM_BUG_ON_PAGE(PageTail(page), page);
> -	bit_spin_unlock(PG_locked, &page->flags);
> +	bit_spin_unlock(PG_locked, &slab->__page_flags);
>   }
>   
>   static inline bool

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-04-04 18:29 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26 17:10 [PATCH 00/10] Various page->flags cleanups Matthew Wilcox (Oracle)
2024-03-26 17:10 ` [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages Matthew Wilcox (Oracle)
2024-03-27 18:45   ` kernel test robot
2024-03-27 18:49     ` Matthew Wilcox
2024-03-26 17:10 ` [PATCH 02/10] xtensa: Remove uses " Matthew Wilcox (Oracle)
2024-03-28 19:36   ` Svetly Todorov
2024-03-28 19:40     ` Matthew Wilcox
2024-03-26 17:10 ` [PATCH 03/10] mm: Make page_ext_get() take a const argument Matthew Wilcox (Oracle)
2024-03-26 17:10 ` [PATCH 04/10] mm: Make folio_test_idle and folio_test_young " Matthew Wilcox (Oracle)
2024-03-26 17:10 ` [PATCH 05/10] mm: Make is_free_buddy_page() " Matthew Wilcox (Oracle)
2024-03-26 17:10 ` [PATCH 06/10] mm: Make page_mapped() " Matthew Wilcox (Oracle)
2024-03-26 17:10 ` [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Matthew Wilcox (Oracle)
2024-03-27 13:02   ` Ryan Roberts
2024-03-27 14:37     ` Matthew Wilcox
2024-03-27 15:48   ` kernel test robot
2024-03-27 17:01   ` kernel test robot
2024-03-26 17:10 ` [PATCH 08/10] slub: Remove use of page->flags Matthew Wilcox (Oracle)
2024-04-04 18:29   ` David Hildenbrand
2024-03-26 17:10 ` [PATCH 09/10] Remove references to page->flags in documentation Matthew Wilcox (Oracle)
2024-03-26 17:10 ` [PATCH 10/10] proc: Rewrite stable_page_flags() Matthew Wilcox (Oracle)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.