diff mbox series

[01/10] sh: Remove use of PG_arch_1 on individual pages

Message ID 20240326171045.410737-2-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
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(-)

Comments

kernel test robot March 27, 2024, 6:45 p.m. UTC | #1
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
Matthew Wilcox March 27, 2024, 6:49 p.m. UTC | #2
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
diff mbox series

Patch

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