diff mbox series

[07/10] mm: Convert arch_clear_hugepage_flags to take a folio

Message ID 20240326171045.410737-8-willy@infradead.org (mailing list archive)
State New
Headers show
Series Various page->flags cleanups | expand

Commit Message

Matthew Wilcox March 26, 2024, 5:10 p.m. UTC
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(-)

Comments

Ryan Roberts March 27, 2024, 1:02 p.m. UTC | #1
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
Matthew Wilcox March 27, 2024, 2:37 p.m. UTC | #2
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
kernel test robot March 27, 2024, 3:48 p.m. UTC | #3
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
kernel test robot March 27, 2024, 5:01 p.m. UTC | #4
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
diff mbox series

Patch

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);
 	}