hugetlb: arm64: add mte support
Subsystems (5)
PATCH v2 1/2 hugetlb: arm64: add mte support
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
--- arch/arm64/include/asm/hugetlb.h | 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +- 8 files changed, 90 insertions(+), 10 deletions(-)
v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.
arch/arm64/include/asm/hugetlb.h +10 -1
@@ -11,6 +11,7 @@#define __ASM_HUGETLB_H#include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
@@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h);static inline void arch_clear_hugetlb_flags (struct folio *folio) { -clear_bit (PG_dcache_clean, &folio->flags); +const unsigned long clear_flags =BIT (PG_dcache_clean) | +BIT (PG_mte_tagged) |BIT (PG_mte_lock); + +if (!system_supports_mte ()) { +clear_bit (PG_dcache_clean, &folio->flags); +return ; + } + + folio->flags &= ~clear_flags; }#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
arch/arm64/include/asm/mman.h +2 -1
@@ -28,7 +28,8 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)* backed by tags-capable memory. The vm_flags may be overridden by a * filesystem supporting MTE (RAM-based). */ -if (system_supports_mte () && (flags &MAP_ANONYMOUS )) +if (system_supports_mte () && + (flags & (MAP_ANONYMOUS |MAP_HUGETLB )))return VM_MTE_ALLOWED ;return 0 ;
arch/arm64/kernel/hibernate.c +7 -0
@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn =zone_end_pfn (zone);for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {struct page *page =pfn_to_online_page (pfn); +struct folio *folio;if (!page)continue ; + folio =page_folio (page); + +if (folio_test_hugetlb (folio) && + !page_mte_tagged (&folio->page)) +continue ; +if (!page_mte_tagged (page))continue ;
arch/arm64/kernel/mte.c +23 -2
@@ -38,7 +38,22 @@ EXPORT_SYMBOL_GPL(mte_async_or_asymm_mode);void mte_sync_tags (pte_t pte,unsigned int nr_pages) {struct page *page =pte_page (pte); -unsigned int i; +struct folio *folio =page_folio (page); +unsigned long i; + +if (folio_test_hugetlb (folio)) { +unsigned long nr =folio_nr_pages (folio); +/* Hugetlb MTE flags are set for head page only */ +if (try_page_mte_tagging (&folio->page)) { +for (i =0 ; i < nr; i++, page++) +mte_clear_page_tags (page_address (page)); +set_page_mte_tagged (&folio->page); + } + +smp_wmb (); + +return ; + }/* if PG_mte_tagged is set, tags have already been initialised */ for (i =0 ; i < nr_pages; i++, page++) {
@@ -410,6 +425,7 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,void *maddr;struct page *page =get_user_page_vma_remote (mm, addr, gup_flags, &vma); +struct folio *folio;if (IS_ERR (page)) { err =PTR_ERR (page);
@@ -428,7 +444,12 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,put_page (page);break ; } -WARN_ON_ONCE (!page_mte_tagged (page)); + + folio =page_folio (page); +if (folio_test_hugetlb (folio)) +WARN_ON_ONCE (!page_mte_tagged (&folio->page)); +else +WARN_ON_ONCE (!page_mte_tagged (page));/* limit access to the end of the page */ offset =offset_in_page (addr);
arch/arm64/kvm/guest.c +13 -3
@@ -1050,6 +1050,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,void *maddr;unsigned long num_tags;struct page *page; +struct folio *folio;if (is_error_noslot_pfn (pfn)) { ret = -EFAULT ;
@@ -1062,10 +1063,13 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, ret = -EFAULT ; goto out; } + folio =page_folio (page); maddr =page_address (page);if (!write) { -if (page_mte_tagged (page)) +if (page_mte_tagged (page) || + (folio_test_hugetlb (folio) && +page_mte_tagged (&folio->page))) num_tags =mte_copy_tags_to_user (tags, maddr,MTE_GRANULES_PER_PAGE );else
@@ -1079,14 +1083,20 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,* __set_ptes() in the VMM but still overriding the * tags, hence ignoring the return value. */ -try_page_mte_tagging (page); +if (folio_test_hugetlb (folio)) +try_page_mte_tagging (&folio->page); +else +try_page_mte_tagging (page); num_tags =mte_copy_tags_from_user (maddr, tags,MTE_GRANULES_PER_PAGE );/* uaccess failed, don't leave stale tags */ if (num_tags !=MTE_GRANULES_PER_PAGE )mte_clear_page_tags (maddr); -set_page_mte_tagged (page); +if (folio_test_hugetlb (folio)) +set_page_mte_tagged (&folio->page); +else +set_page_mte_tagged (page);kvm_release_pfn_dirty (pfn); }
arch/arm64/kvm/mmu.c +11 -0
@@ -1401,10 +1401,21 @@ static void sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn, {unsigned long i, nr_pages = size >>PAGE_SHIFT ;struct page *page =pfn_to_page (pfn); +struct folio *folio =page_folio (page);if (!kvm_has_mte (kvm))return ; +if (folio_test_hugetlb (folio)) { +/* Hugetlb has MTE flags set on head page only */ +if (try_page_mte_tagging (&folio->page)) { +for (i =0 ; i < nr_pages; i++, page++) +mte_clear_page_tags (page_address (page)); +set_page_mte_tagged (&folio->page); + } +return ; + } +for (i =0 ; i < nr_pages; i++, page++) {if (try_page_mte_tagging (page)) {mte_clear_page_tags (page_address (page));
arch/arm64/mm/copypage.c +23 -2
@@ -18,6 +18,9 @@ void copy_highpage(struct page *to, struct page *from) {void *kto =page_address (to);void *kfrom =page_address (from); +struct folio *src =page_folio (from); +struct folio *dst =page_folio (to); +unsigned int i, nr_pages;copy_page (kto, kfrom);
@@ -27,8 +30,26 @@ void copy_highpage(struct page *to, struct page *from)if (system_supports_mte () &&page_mte_tagged (from)) {/* It's a new page, shouldn't have been tagged yet */ WARN_ON_ONCE (!try_page_mte_tagging (to)); -mte_copy_page_tags (kto, kfrom); -set_page_mte_tagged (to); + +/* Populate tags for all subpages if hugetlb */ +if (folio_test_hugetlb (src)) { +/* +* MTE page flag is just set on the head page of +* hugetlb. If from has MTE flag set, it must be the +* head page. +*/ +VM_BUG_ON (!PageHead (from)); + nr_pages =folio_nr_pages (src); +for (i =0 ; i < nr_pages; i++, to++, from++) { + kto =page_address (to); + kfrom =page_address (from); +mte_copy_page_tags (kto, kfrom); + } +set_page_mte_tagged (&dst->page); + }else { +mte_copy_page_tags (kto, kfrom); +set_page_mte_tagged (to); + } } }EXPORT_SYMBOL (copy_highpage);
fs/hugetlbfs/inode.c +1 -1
@@ -110,7 +110,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)* way when do_mmap unwinds (may be important on powerpc * and ia64). */ -vm_flags_set (vma,VM_HUGETLB |VM_DONTEXPAND ); +vm_flags_set (vma,VM_HUGETLB |VM_DONTEXPAND |VM_MTE_ALLOWED ); vma->vm_ops = &hugetlb_vm_ops; ret =seal_check_write (info->seals, vma);
Signature · 1 line
2.41.0
PATCH v2 2/2 selftests: arm64: add hugetlb mte tests
The tests cover mmap, mprotect hugetlb with MTE prot and COW.
--- .../arm64/mte/check_hugetlb_options.c | 285 ++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 tools/testing/selftests/arm64/mte/check_hugetlb_options.c
tools/testing/selftests/arm64/mte/check_hugetlb_options.c new file +285 -0
@@ -0,0 +1,285 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2024 Ampere Computing LLC + +#define _GNU_SOURCE + +#include <errno.h> +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ucontext.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/wait.h> + +#include "kselftest.h" +#include "mte_common_util.h" +#include "mte_def.h" + +#define TAG_CHECK_ON 0 +#define TAG_CHECK_OFF 1 + +static unsigned long default_huge_page_size (void ) +{ +unsigned long hps =0 ; +char *line =NULL ; +size_t linelen =0 ; +FILE *f =fopen ("/proc/meminfo" ,"r" ); + +if (!f) +return 0 ; +while (getline (&line, &linelen, f) >0 ) { +if (sscanf (line,"Hugepagesize: %lu kB" , &hps) ==1 ) { + hps <<=10 ; +break ; + } + } + +free (line); +fclose (f); +return hps; +} + +static bool is_hugetlb_allocated (void ) +{ +unsigned long hps =0 ; +char *line =NULL ; +size_t linelen =0 ; +FILE *f =fopen ("/proc/meminfo" ,"r" ); + +if (!f) +return false; +while (getline (&line, &linelen, f) >0 ) { +if (sscanf (line,"Hugetlb: %lu kB" , &hps) ==1 ) { + hps <<=10 ; +break ; + } + } + +free (line); +fclose (f); + +if (hps >0 ) +return true; + +return false; +} + +static void write_sysfs (char *str,unsigned long val) +{ +FILE *f; + + f =fopen (str,"w" ); +if (!f) { +ksft_print_msg ("ERR: missing %s\n" , str); +return ; + } +fprintf (f,"%lu" , val); +fclose (f); +} + +static void allocate_hugetlb () +{ +write_sysfs ("/proc/sys/vm/nr_hugepages" ,2 ); +} + +static void free_hugetlb () +{ +write_sysfs ("/proc/sys/vm/nr_hugepages" ,0 ); +} + +static int check_child_tag_inheritance (char *ptr,int size,int mode) +{ +int i, parent_tag, child_tag, fault, child_status; +pid_t child; + + parent_tag =MT_FETCH_TAG ((uintptr_t )ptr); + fault =0 ; + + child =fork (); +if (child ==-1 ) { +ksft_print_msg ("FAIL: child process creation\n" ); +return KSFT_FAIL ; + }else if (child ==0 ) { +mte_initialize_current_context (mode, (uintptr_t )ptr, size); +/* Do copy on write */ +memset (ptr,'1' , size); +mte_wait_after_trig (); +if (cur_mte_cxt.fault_valid == true) { + fault =1 ; + goto check_child_tag_inheritance_err; + } +for (i =0 ; i < size; i +=MT_GRANULE_SIZE ) { + child_tag =MT_FETCH_TAG ((uintptr_t )(mte_get_tag_address (ptr + i))); +if (parent_tag != child_tag) { +ksft_print_msg ("FAIL: child mte tag (%d) mismatch\n" , i); + fault =1 ; + goto check_child_tag_inheritance_err; + } + } +check_child_tag_inheritance_err: +_exit (fault); + } +/* Wait for child process to terminate */ +wait (&child_status); +if (WIFEXITED (child_status)) + fault =WEXITSTATUS (child_status); +else + fault =1 ; +return (fault) ?KSFT_FAIL :KSFT_PASS ; +} + +static int check_mte_memory (char *ptr,int size,int mode,int tag_check) +{ +mte_initialize_current_context (mode, (uintptr_t )ptr, size); +memset (ptr,'1' , size); +mte_wait_after_trig (); +if (cur_mte_cxt.fault_valid == true) +return KSFT_FAIL ; + +return KSFT_PASS ; +} + +static int check_hugetlb_memory_mapping (int mem_type,int mode,int mapping,int tag_check) +{ +char *ptr, *map_ptr; +int result; +unsigned long map_size; + + map_size =default_huge_page_size (); + +mte_switch_mode (mode,MTE_ALLOW_NON_ZERO_TAG ); + map_ptr = (char *)mte_allocate_memory (map_size, mem_type, mapping, false); +if (check_allocated_memory (map_ptr, map_size, mem_type, false) !=KSFT_PASS ) +return KSFT_FAIL ; + +mte_initialize_current_context (mode, (uintptr_t )map_ptr, map_size); +/* Only mte enabled memory will allow tag insertion */ + ptr =mte_insert_tags ((void *)map_ptr, map_size); +if (!ptr || cur_mte_cxt.fault_valid == true) { +ksft_print_msg ("FAIL: Insert tags on anonymous mmap memory\n" ); +munmap ((void *)map_ptr, map_size); +return KSFT_FAIL ; + } + result =check_mte_memory (ptr, map_size, mode, tag_check); +mte_clear_tags ((void *)ptr, map_size); +mte_free_memory ((void *)map_ptr, map_size, mem_type, false); +if (result ==KSFT_FAIL ) +return KSFT_FAIL ; + +return KSFT_PASS ; +} + +static int check_clear_prot_mte_flag (int mem_type,int mode,int mapping) +{ +char *map_ptr; +int prot_flag, result; +unsigned long map_size; + + prot_flag =PROT_READ |PROT_WRITE ; +mte_switch_mode (mode,MTE_ALLOW_NON_ZERO_TAG ); + map_size =default_huge_page_size (); + map_ptr = (char *)mte_allocate_memory_tag_range (map_size, mem_type, mapping, +0 ,0 ); +if (check_allocated_memory_range (map_ptr, map_size, mem_type, +0 ,0 ) !=KSFT_PASS ) +return KSFT_FAIL ; +/* Try to clear PROT_MTE property and verify it by tag checking */ +if (mprotect (map_ptr, map_size, prot_flag)) { +mte_free_memory_tag_range ((void *)map_ptr, map_size, mem_type, +0 ,0 ); +ksft_print_msg ("FAIL: mprotect not ignoring clear PROT_MTE property\n" ); +return KSFT_FAIL ; + } + result =check_mte_memory (map_ptr, map_size, mode,TAG_CHECK_ON ); +mte_free_memory_tag_range ((void *)map_ptr, map_size, mem_type,0 ,0 ); +if (result !=KSFT_PASS ) +return KSFT_FAIL ; + +return KSFT_PASS ; +} + +static int check_child_hugetlb_memory_mapping (int mem_type,int mode,int mapping) +{ +char *ptr; +int result; +unsigned long map_size; + + map_size =default_huge_page_size (); + +mte_switch_mode (mode,MTE_ALLOW_NON_ZERO_TAG ); + ptr = (char *)mte_allocate_memory_tag_range (map_size, mem_type, mapping, +0 ,0 ); +if (check_allocated_memory_range (ptr, map_size, mem_type, +0 ,0 ) !=KSFT_PASS ) +return KSFT_FAIL ; + result =check_child_tag_inheritance (ptr, map_size, mode); +mte_free_memory_tag_range ((void *)ptr, map_size, mem_type,0 ,0 ); +if (result ==KSFT_FAIL ) +return result; + +return KSFT_PASS ; +} + +int main (int argc,char *argv[]) +{ +int err; + + err =mte_default_setup (); +if (err) +return err; + +/* Register signal handlers */ +mte_register_signal (SIGBUS , mte_default_handler); +mte_register_signal (SIGSEGV , mte_default_handler); + +allocate_hugetlb (); + +if (!is_hugetlb_allocated ()) { +ksft_print_msg ("ERR: Unable allocate hugetlb pages\n" ); +return KSFT_FAIL ; + } + +/* Set test plan */ +ksft_set_plan (12 ); + +mte_enable_pstate_tco (); + +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_OFF ), +"Check hugetlb memory with private mapping, sync error mode, mmap memory and tag check off\n" ); + +mte_disable_pstate_tco (); +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_NONE_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_OFF ), +"Check hugetlb memory with private mapping, no error mode, mmap memory and tag check off\n" ); + +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, sync error mode, mmap memory and tag check on\n" ); +evaluate_test (check_hugetlb_memory_mapping (USE_MPROTECT ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, sync error mode, mmap/mprotect memory and tag check on\n" ); +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, async error mode, mmap memory and tag check on\n" ); +evaluate_test (check_hugetlb_memory_mapping (USE_MPROTECT ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, async error mode, mmap/mprotect memory and tag check on\n" ); + +evaluate_test (check_clear_prot_mte_flag (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check clear PROT_MTE flags with private mapping, sync error mode and mmap memory\n" ); +evaluate_test (check_clear_prot_mte_flag (USE_MPROTECT ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check clear PROT_MTE flags with private mapping and sync error mode and mmap/mprotect memory\n" ); + +evaluate_test (check_child_hugetlb_memory_mapping (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap memory\n" ); +evaluate_test (check_child_hugetlb_memory_mapping (USE_MMAP ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap memory\n" ); +evaluate_test (check_child_hugetlb_memory_mapping (USE_MPROTECT ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n" ); +evaluate_test (check_child_hugetlb_memory_mapping (USE_MPROTECT ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n" ); + +mte_restore_setup (); +free_hugetlb (); +ksft_print_cnts (); +return ksft_get_fail_cnt () ==0 ?KSFT_PASS :KSFT_FAIL ; +}
Signature · 1 line
2.41.0
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Yang,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on kvmarm/next akpm-mm/mm-everything linus/master v6.11-rc5 next-20240823] [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/Yang-Shi/selftests-arm64-add-hugetlb-mte-tests/20240822-024935 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20240821184752.3535276-1-yang%40os.amperecomputing.com patch subject: [v2 PATCH 1/2] hugetlb: arm64: add mte support config: arm64-randconfig-004-20240824 (https://download.01.org/0day-ci/archive/20240826/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 08e5a1de8227512d4774a534b91cb2353cef6284) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240826/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from mm/gup.c:7:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/gup.c:18:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^
In file included from mm/gup.c:20:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~ 6 warnings and 1 error generated.
--
In file included from mm/swap.c:17:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/swap.c:26:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/swap.c:36:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^ 6 warnings and 1 error generated.
--
In file included from mm/shmem.c:28:
In file included from include/linux/ramfs.h:5:
In file included from include/linux/fs_parser.h:11:
In file included from include/linux/fs_context.h:14:
In file included from include/linux/security.h:33:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/shmem.c:39:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^
In file included from mm/shmem.c:58:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 | _calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~ 6 warnings and 1 error generated.
--
In file included from mm/mprotect.c:12:
In file included from include/linux/pagewalk.h:5:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/mprotect.c:13:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^
In file included from mm/mprotect.c:15:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 | _calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
In file included from mm/mprotect.c:30:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~ 8 warnings and 1 error generated.
--
In file included from mm/show_mem.c:8:
In file included from include/linux/blkdev.h:9:
In file included from include/linux/blk_types.h:10:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/arm64/include/asm/cacheflush.h:11:
In file included from include/linux/kgdb.h:19:
In file included from include/linux/kprobes.h:28:
In file included from include/linux/ftrace.h:13:
In file included from include/linux/kallsyms.h:13:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/show_mem.c:12:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^ 4 warnings and 1 error generated.
--
In file included from mm/mremap.c:11:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/mremap.c:12:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/mremap.c:13:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^
In file included from mm/mremap.c:16:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 | _calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~ 8 warnings and 1 error generated.
--
In file included from mm/huge_memory.c:8:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/huge_memory.c:14:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^
In file included from mm/huge_memory.c:19:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/huge_memory.c:27:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 | _calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~ 8 warnings and 1 error generated.
--
In file included from mm/vmscan.c:15:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
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_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/vmscan.c:30:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/vmscan.c:42:
In file included from include/linux/migrate.h:8:
In file included from include/linux/hugetlb.h:798:
>> arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'
25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
| ^
mm/vmscan.c:401:51: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
401 | size += zone_page_state(zone, NR_ZONE_LRU_BASE + lru);
| ~~~~~~~~~~~~~~~~ ^ ~~~
mm/vmscan.c:1729:4: warning: arithmetic between different enumeration types ('enum vm_event_item' and 'enum zone_type') [-Wenum-enum-conversion]
1729 | __count_zid_vm_events(PGSCAN_SKIP, zid, nr_skipped[zid]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:135:34: note: expanded from macro '__count_zid_vm_events'
135 | __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta)
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
mm/vmscan.c:2232:51: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
2232 | inactive = lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru);
| ~~~~~~~~~~~ ^ ~~~~~~~~~~~~
mm/vmscan.c:2233:49: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
2233 | active = lruvec_page_state(lruvec, NR_LRU_BASE + active_lru);
| ~~~~~~~~~~~ ^ ~~~~~~~~~~
mm/vmscan.c:6247:3: warning: arithmetic between different enumeration types ('enum vm_event_item' and 'enum zone_type') [-Wenum-enum-conversion]
6247 | __count_zid_vm_events(ALLOCSTALL, sc->reclaim_idx, 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/vmstat.h:135:34: note: expanded from macro '__count_zid_vm_events'
135 | __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta)
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
11 warnings and 1 error generated.
..
vim +/PG_mte_lock +25 arch/arm64/include/asm/hugetlb.h
21
22 static inline void arch_clear_hugetlb_flags(struct folio *folio)
23 {
24 const unsigned long clear_flags = BIT(PG_dcache_clean) |
> 25 BIT(PG_mte_tagged) | BIT(PG_mte_lock);
26
27 if (!system_supports_mte()) {
28 clear_bit(PG_dcache_clean, &folio->flags);
29 return;
30 }
31
32 folio->flags &= ~clear_flags;
33 }
34 #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
35 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 47 lines · kernel test robot
Hi Yang,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on kvmarm/next akpm-mm/mm-everything linus/master v6.11-rc5 next-20240823] [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/Yang-Shi/selftests-arm64-add-hugetlb-mte-tests/20240822-024935 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20240821184752.3535276-1-yang%40os.amperecomputing.com patch subject: [v2 PATCH 1/2] hugetlb: arm64: add mte support config: arm64-randconfig-004-20240824 (https://download.01.org/0day-ci/archive/20240826/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 08e5a1de8227512d4774a534b91cb2353cef6284) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240826/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from
mm/gup.c:7:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/gup.c:18:
In file included frominclude/linux/hugetlb.h:798:
Quoted 2 lines
Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock);
Thanks for the report. It is because the config has CONFIG_MTE disabled. I will fix this. But I'd prefer the response from the maintainers then fix all them together.
Quoted 343 lines
| ^
In file included frommm/gup.c:20:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
47 |__mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
49 |NR_ZONE_LRU_BASE+ lru,nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
6 warnings and 1 error generated.
--
In file included frommm/swap.c:17:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/swap.c:26:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
47 |__mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
49 |NR_ZONE_LRU_BASE+ lru,nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included frommm/swap.c:36:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 |
BIT(PG_mte_tagged)|BIT(PG_mte_lock);
| ^
6 warnings and 1 error generated.
--
In file included frommm/shmem.c:28:
In file included frominclude/linux/ramfs.h:5:
In file included frominclude/linux/fs_parser.h:11:
In file included frominclude/linux/fs_context.h:14:
In file included frominclude/linux/security.h:33:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/shmem.c:39:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 |
BIT(PG_mte_tagged)|BIT(PG_mte_lock);
| ^
In file included frommm/shmem.c:58:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 |_calc_vm_trans(flags, MAP_SYNC, VM_SYNC )|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 |_calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE)|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
6 warnings and 1 error generated.
--
In file included frommm/mprotect.c:12:
In file included frominclude/linux/pagewalk.h:5:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/mprotect.c:13:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 |
BIT(PG_mte_tagged)|BIT(PG_mte_lock);
| ^
In file included frommm/mprotect.c:15:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 |_calc_vm_trans(flags, MAP_SYNC, VM_SYNC )|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 |_calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE)|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
In file included frommm/mprotect.c:30:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
47 |__mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
49 |NR_ZONE_LRU_BASE+ lru,nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
8 warnings and 1 error generated.
--
In file included frommm/show_mem.c:8:
In file included frominclude/linux/blkdev.h:9:
In file included frominclude/linux/blk_types.h:10:
In file included frominclude/linux/bvec.h:10:
In file included frominclude/linux/highmem.h:8:
In file included frominclude/linux/cacheflush.h:5:
In file included fromarch/arm64/include/asm/cacheflush.h:11:
In file included frominclude/linux/kgdb.h:19:
In file included frominclude/linux/kprobes.h:28:
In file included frominclude/linux/ftrace.h:13:
In file included frominclude/linux/kallsyms.h:13:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/show_mem.c:12:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 |
BIT(PG_mte_tagged)|BIT(PG_mte_lock);
| ^
4 warnings and 1 error generated.
--
In file included frommm/mremap.c:11:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/mremap.c:12:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
47 |__mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
49 |NR_ZONE_LRU_BASE+ lru,nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included frommm/mremap.c:13:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 |
BIT(PG_mte_tagged)|BIT(PG_mte_lock);
| ^
In file included frommm/mremap.c:16:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 |_calc_vm_trans(flags, MAP_SYNC, VM_SYNC )|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 |_calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE)|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
8 warnings and 1 error generated.
--
In file included frommm/huge_memory.c:8:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/huge_memory.c:14:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 |
BIT(PG_mte_tagged)|BIT(PG_mte_lock);
| ^
In file included frommm/huge_memory.c:19:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
47 |__mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
49 |NR_ZONE_LRU_BASE+ lru,nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included frommm/huge_memory.c:27:
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 |_calc_vm_trans(flags, MAP_SYNC, VM_SYNC )|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 |_calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE)|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
8 warnings and 1 error generated.
--
In file included frommm/vmscan.c:15:
In file included frominclude/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
514 | returnnode_stat_name(NR_LRU_BASE + lru)+ 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 |NR_VM_NUMA_EVENT_ITEMS+
| ~~~~~~~~~~~~~~~~~~~~~~
In file included frommm/vmscan.c:30:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enumnode_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
47 |__mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumlru_list') [-Wenum-enum-conversion]
49 |NR_ZONE_LRU_BASE+ lru,nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included frommm/vmscan.c:42:
In file included frominclude/linux/migrate.h:8:
In file included frominclude/linux/hugetlb.h:798:Quoted 1 line
Quoted 1 line
arch/arm64/include/asm/hugetlb.h:25:28: error: use of undeclared identifier 'PG_mte_lock'25 | BIT(PG_mte_tagged) | BIT(PG_mte_lock); | ^ mm/vmscan.c:401:51: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 401 | size += zone_page_state(zone, NR_ZONE_LRU_BASE + lru); | ~~~~~~~~~~~~~~~~ ^ ~~~ mm/vmscan.c:1729:4: warning: arithmetic between different enumeration types ('enum vm_event_item' and 'enum zone_type') [-Wenum-enum-conversion] 1729 | __count_zid_vm_events(PGSCAN_SKIP, zid, nr_skipped[zid]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/vmstat.h:135:34: note: expanded from macro '__count_zid_vm_events' 135 | __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta) | ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~ mm/vmscan.c:2232:51: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 2232 | inactive = lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru); | ~~~~~~~~~~~ ^ ~~~~~~~~~~~~ mm/vmscan.c:2233:49: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 2233 | active = lruvec_page_state(lruvec, NR_LRU_BASE + active_lru); | ~~~~~~~~~~~ ^ ~~~~~~~~~~ mm/vmscan.c:6247:3: warning: arithmetic between different enumeration types ('enum vm_event_item' and 'enum zone_type') [-Wenum-enum-conversion] 6247 | __count_zid_vm_events(ALLOCSTALL, sc->reclaim_idx, 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/vmstat.h:135:34: note: expanded from macro '__count_zid_vm_events' 135 | __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta) | ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~ 11 warnings and 1 error generated...
vim +/PG_mte_lock +25
arch/arm64/include/asm/hugetlb.h21
22 static inline voidarch_clear_hugetlb_flags(struct folio *folio)
23 {
24 const unsigned longclear_flags=BIT(PG_dcache_clean)|Quoted 1 line
25
BIT(PG_mte_tagged)|BIT(PG_mte_lock);26 27 if (!system_supports_mte()) { 28 clear_bit(PG_dcache_clean, &folio->flags); 29 return; 30 } 31 32 folio->flags &= ~clear_flags; 33 } 34 #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags 35
Quoted 20 lines · Yang Shi
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
Signed-off-by Yang Shi <[email protected]>--- arch/arm64/include/asm/hugetlb.h | 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +- 8 files changed, 90 insertions(+), 10 deletions(-)
Quoted 2 lines
v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.
Ping... Is there any comment on this version?
Thanks,
Yang
Quoted 248 lines
arch/arm64/include/asm/hugetlb.h +10
-1@@ -11,6 +11,7 @@#define __ASM_HUGETLB_H#include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION @@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h);static inline void arch_clear_hugetlb_flags (struct folio *folio) { -clear_bit (PG_dcache_clean, &folio->flags); +const unsigned long clear_flags =BIT (PG_dcache_clean) | +BIT (PG_mte_tagged) |BIT (PG_mte_lock); + +if (!system_supports_mte ()) { +clear_bit (PG_dcache_clean, &folio->flags); +return ; + } + + folio->flags &= ~clear_flags; }#define arch_clear_hugetlb_flags arch_clear_hugetlb_flagsarch/arm64/include/asm/mman.h +2
-1@@ -28,7 +28,8 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)* backed by tags-capable memory. The vm_flags may be overridden by a * filesystem supporting MTE (RAM-based). */ -if (system_supports_mte () && (flags &MAP_ANONYMOUS )) +if (system_supports_mte () && + (flags & (MAP_ANONYMOUS |MAP_HUGETLB )))return VM_MTE_ALLOWED ;return 0 ;arch/arm64/kernel/hibernate.c +7
-0@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn =zone_end_pfn (zone);for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {struct page *page =pfn_to_online_page (pfn); +struct folio *folio;if (!page)continue ; + folio =page_folio (page); + +if (folio_test_hugetlb (folio) && + !page_mte_tagged (&folio->page)) +continue ; +if (!page_mte_tagged (page))continue ;arch/arm64/kernel/mte.c +23
-2@@ -38,7 +38,22 @@ EXPORT_SYMBOL_GPL(mte_async_or_asymm_mode);void mte_sync_tags (pte_t pte,unsigned int nr_pages) {struct page *page =pte_page (pte); -unsigned int i; +struct folio *folio =page_folio (page); +unsigned long i; + +if (folio_test_hugetlb (folio)) { +unsigned long nr =folio_nr_pages (folio); +/* Hugetlb MTE flags are set for head page only */ +if (try_page_mte_tagging (&folio->page)) { +for (i =0 ; i < nr; i++, page++) +mte_clear_page_tags (page_address (page)); +set_page_mte_tagged (&folio->page); + } + +smp_wmb (); + +return ; + }/* if PG_mte_tagged is set, tags have already been initialised */ for (i =0 ; i < nr_pages; i++, page++) {@@ -410,6 +425,7 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,void *maddr;struct page *page =get_user_page_vma_remote (mm, addr, gup_flags, &vma); +struct folio *folio;if (IS_ERR (page)) { err =PTR_ERR (page);@@ -428,7 +444,12 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,put_page (page);break ; } -WARN_ON_ONCE (!page_mte_tagged (page)); + + folio =page_folio (page); +if (folio_test_hugetlb (folio)) +WARN_ON_ONCE (!page_mte_tagged (&folio->page)); +else +WARN_ON_ONCE (!page_mte_tagged (page));/* limit access to the end of the page */ offset =offset_in_page (addr);arch/arm64/kvm/guest.c +13
-3@@ -1050,6 +1050,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,void *maddr;unsigned long num_tags;struct page *page; +struct folio *folio;if (is_error_noslot_pfn (pfn)) { ret = -EFAULT ;@@ -1062,10 +1063,13 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, ret = -EFAULT ; goto out; } + folio =page_folio (page); maddr =page_address (page);if (!write) { -if (page_mte_tagged (page)) +if (page_mte_tagged (page) || + (folio_test_hugetlb (folio) && +page_mte_tagged (&folio->page))) num_tags =mte_copy_tags_to_user (tags, maddr,MTE_GRANULES_PER_PAGE );else @@ -1079,14 +1083,20 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,* __set_ptes() in the VMM but still overriding the * tags, hence ignoring the return value. */ -try_page_mte_tagging (page); +if (folio_test_hugetlb (folio)) +try_page_mte_tagging (&folio->page); +else +try_page_mte_tagging (page); num_tags =mte_copy_tags_from_user (maddr, tags,MTE_GRANULES_PER_PAGE );/* uaccess failed, don't leave stale tags */ if (num_tags !=MTE_GRANULES_PER_PAGE )mte_clear_page_tags (maddr); -set_page_mte_tagged (page); +if (folio_test_hugetlb (folio)) +set_page_mte_tagged (&folio->page); +else +set_page_mte_tagged (page);kvm_release_pfn_dirty (pfn); }arch/arm64/kvm/mmu.c +11
-0@@ -1401,10 +1401,21 @@ static void sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn, {unsigned long i, nr_pages = size >>PAGE_SHIFT ;struct page *page =pfn_to_page (pfn); +struct folio *folio =page_folio (page);if (!kvm_has_mte (kvm))return ; +if (folio_test_hugetlb (folio)) { +/* Hugetlb has MTE flags set on head page only */ +if (try_page_mte_tagging (&folio->page)) { +for (i =0 ; i < nr_pages; i++, page++) +mte_clear_page_tags (page_address (page)); +set_page_mte_tagged (&folio->page); + } +return ; + } +for (i =0 ; i < nr_pages; i++, page++) {if (try_page_mte_tagging (page)) {mte_clear_page_tags (page_address (page));arch/arm64/mm/copypage.c +23
-2@@ -18,6 +18,9 @@ void copy_highpage(struct page *to, struct page *from) {void *kto =page_address (to);void *kfrom =page_address (from); +struct folio *src =page_folio (from); +struct folio *dst =page_folio (to); +unsigned int i, nr_pages;copy_page (kto, kfrom);@@ -27,8 +30,26 @@ void copy_highpage(struct page *to, struct page *from)if (system_supports_mte () &&page_mte_tagged (from)) {/* It's a new page, shouldn't have been tagged yet */ WARN_ON_ONCE (!try_page_mte_tagging (to)); -mte_copy_page_tags (kto, kfrom); -set_page_mte_tagged (to); + +/* Populate tags for all subpages if hugetlb */ +if (folio_test_hugetlb (src)) { +/* +* MTE page flag is just set on the head page of +* hugetlb. If from has MTE flag set, it must be the +* head page. +*/ +VM_BUG_ON (!PageHead (from)); + nr_pages =folio_nr_pages (src); +for (i =0 ; i < nr_pages; i++, to++, from++) { + kto =page_address (to); + kfrom =page_address (from); +mte_copy_page_tags (kto, kfrom); + } +set_page_mte_tagged (&dst->page); + }else { +mte_copy_page_tags (kto, kfrom); +set_page_mte_tagged (to); + } } }EXPORT_SYMBOL (copy_highpage);fs/hugetlbfs/inode.c +1
-1@@ -110,7 +110,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)* way when do_mmap unwinds (may be important on powerpc * and ia64). */ -vm_flags_set (vma,VM_HUGETLB |VM_DONTEXPAND ); +vm_flags_set (vma,VM_HUGETLB |VM_DONTEXPAND |VM_MTE_ALLOWED ); vma->vm_ops = &hugetlb_vm_ops; ret =seal_check_write (info->seals, vma);
Quoted 74 lines · Yang Shi
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
Signed-off-by Yang Shi <[email protected]>--- arch/arm64/include/asm/hugetlb.h | 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +- 8 files changed, 90 insertions(+), 10 deletions(-)v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.arch/arm64/include/asm/hugetlb.h +10
-1@@ -11,6 +11,7 @@#define __ASM_HUGETLB_H#include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION @@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h);static inline void arch_clear_hugetlb_flags (struct folio *folio) { -clear_bit (PG_dcache_clean, &folio->flags); +const unsigned long clear_flags =BIT (PG_dcache_clean) | +BIT (PG_mte_tagged) |BIT (PG_mte_lock); + +if (!system_supports_mte ()) { +clear_bit (PG_dcache_clean, &folio->flags); +return ; + } + + folio->flags &= ~clear_flags; }#define arch_clear_hugetlb_flags arch_clear_hugetlb_flagsarch/arm64/include/asm/mman.h +2
-1@@ -28,7 +28,8 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)* backed by tags-capable memory. The vm_flags may be overridden by a * filesystem supporting MTE (RAM-based). */ -if (system_supports_mte () && (flags &MAP_ANONYMOUS )) +if (system_supports_mte () && + (flags & (MAP_ANONYMOUS |MAP_HUGETLB )))return VM_MTE_ALLOWED ;return 0 ;arch/arm64/kernel/hibernate.c +0
-0@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn =zone_end_pfn (zone);for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {struct page *page =pfn_to_online_page (pfn);
arch/arm64/kernel/hibernate.c static int swsusp_mte_save_tags(void) · line 278
Quoted 10 lines
arch/arm64/kernel/hibernate.c +6
-0+struct folio *folio;if (!page)continue ; + folio =page_folio (page); + +if (folio_test_hugetlb (folio) && + !page_mte_tagged (&folio->page)) +continue ;
Can we have folio_test_mte_tagged() whereby you make sure that only folio_test_hugetlb() uses it for now (VM_WARN_ON_ONCE) and then make sure that nobody uses page_mte_tagged() on hugetlb folios (VM_WARN_ON_ONCE)?
Same for folio_set_mte_tagged() and other functions. We could slap a "hugetlb" into the function names, but maybe in the future we'll be able to use a single flag per folio (I know, it's complicated ...).
Signature · 3 lines
Cheers, David / dhildenb
Quoted 74 lines · David Hildenbrand
Quoted 73 lines · Yang Shi
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
Signed-off-by Yang Shi <[email protected]>---
arch/arm64/include/asm/hugetlb.h| 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +-8 files changed, 90 insertions(+), 10 deletions(-)v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.arch/arm64/include/asm/hugetlb.h +10
-1@@ -11,6 +11,7 @@ #define __ASM_HUGETLB_H #include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION@@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h); static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &folio->flags); + const unsigned long clear_flags = BIT(PG_dcache_clean) | + BIT(PG_mte_tagged) | BIT(PG_mte_lock); + + if (!system_supports_mte()) { + clear_bit(PG_dcache_clean, &folio->flags); + return; + } + + folio->flags &= ~clear_flags; } #define arch_clear_hugetlb_flags arch_clear_hugetlb_flagsdiff --git
a/arch/arm64/include/asm/mman.hb/arch/arm64/include/asm/mman.hindex5966ee4a6154..304dfc499e68100644arch/arm64/include/asm/mman.h +2
-1@@ -28,7 +28,8 @@ static inline unsigned longarch_calc_vm_flag_bits(unsigned long flags) * backed by tags-capable memory. The vm_flags may be overridden by a * filesystem supporting MTE (RAM-based). */ - if (system_supports_mte() && (flags & MAP_ANONYMOUS)) + if (system_supports_mte() && + (flags & (MAP_ANONYMOUS | MAP_HUGETLB))) return VM_MTE_ALLOWED; return 0;arch/arm64/kernel/hibernate.c +1
-0@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn = zone_end_pfn(zone); for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { struct page *page = pfn_to_online_page(pfn); + struct folio *folio; if (!page)
Quoted 8 lines
arch/arm64/kernel/hibernate.c static int swsusp_mte_save_tags(void) · line 278
Quoted 6 lines
arch/arm64/kernel/hibernate.c +4
-0continue; + folio = page_folio(page); + + if (folio_test_hugetlb(folio) && + !page_mte_tagged(&folio->page)) + continue;Can we have
folio_test_mte_tagged()whereby you make sure that onlyfolio_test_hugetlb()uses it for now (VM_WARN_ON_ONCE) and then make sure that nobody usespage_mte_tagged()on hugetlb folios (VM_WARN_ON_ONCE)?
IIUC, you mean something like the below?
bool folio_test_mte_tagged(struct folio *folio)
{
VM_WARN_ON_ONCE(!folio_test_hugetlb(folio));
return test_bit(PG_mte_tagged, &folio->page->flags); }
bool page_mte_tagged(struct page *page)
{
struct folio *folio = page_folio(page);
VM_WARN_ON_ONCE(folio_test_hugetlb(folio));
return test_bit(PG_mte_tagged, &pge->flags);
}
Quoted 2 lines
Same for
folio_set_mte_tagged()and other functions. We could slap a "hugetlb" into the function names, but maybe in the future we'll be able to use a single flag per folio (I know, it's complicated ...).
A single flag per folio should be the future direction, but I haven't done the research so can't tell how complicated it will be.
Quoted 94 lines · Yang Shi
Quoted 81 lines · David Hildenbrand
Quoted 80 lines · Yang Shi
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
Signed-off-by Yang Shi <[email protected]>--- arch/arm64/include/asm/hugetlb.h | 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +- 8 files changed, 90 insertions(+), 10 deletions(-)v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.arch/arm64/include/asm/hugetlb.h +10
-1@@ -11,6 +11,7 @@ #define __ASM_HUGETLB_H #include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION@@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h); static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &folio->flags); + const unsigned long clear_flags = BIT(PG_dcache_clean) | + BIT(PG_mte_tagged) | BIT(PG_mte_lock); + + if (!system_supports_mte()) { + clear_bit(PG_dcache_clean, &folio->flags); + return; + } + + folio->flags &= ~clear_flags; } #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags diff --git a/arch/arm64/include/asm/mman.h
b/arch/arm64/include/asm/mman.h
index5966ee4a6154..304dfc499e68100644arch/arm64/include/asm/mman.h +0
-0@@ -28,7 +28,8 @@ static inline unsigned longarch_calc_vm_flag_bits (unsigned long flags ) * backed by tags-capable memory. The vm_flags may beoverridden by a
* filesystem supporting MTE (RAM-based). */
- if (system_supports_mte()&& (flags &MAP_ANONYMOUS)) + if (system_supports_mte()&&
+ (flags & (MAP_ANONYMOUS|MAP_HUGETLB)))
returnVM_MTE_ALLOWED;
return 0;arch/arm64/kernel/hibernate.c +2
-0@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn = zone_end_pfn(zone); for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { struct page *page = pfn_to_online_page(pfn); + struct folio *folio; if (!page) continue; + folio = page_folio(page); +Quoted 8 lines
arch/arm64/kernel/hibernate.c static int swsusp_mte_save_tags(void) · line 278
Quoted 3 lines
arch/arm64/kernel/hibernate.c +3
-0+ if (folio_test_hugetlb(folio) && + !page_mte_tagged(&folio->page)) + continue;Can we have
folio_test_mte_tagged()whereby you make sure that onlyfolio_test_hugetlb()uses it for now (VM_WARN_ON_ONCE) and then make sure that nobody usespage_mte_tagged()on hugetlb folios (VM_WARN_ON_ONCE)?
Quoted 7 lines
IIUC, you mean something like the below?
bool
folio_test_mte_tagged(struct folio *folio){
VM_WARN_ON_ONCE(!folio_test_hugetlb(folio));return test_bit(PG_mte_tagged, &folio->page->flags);
folio->flags
Quoted 7 lines
}
bool
page_mte_tagged(struct page *page)
{
struct folio *folio =page_folio(page);VM_WARN_ON_ONCE(folio_test_hugetlb(folio));
Yes, but better as
VM_WARN_ON_ONCE(folio_test_hugetlb(page_folio(page)));
Quoted 11 lines
return
test_bit(PG_mte_tagged, &pge->flags);
}Quoted 4 lines
Same for
folio_set_mte_tagged()and other functions. We could slap a "hugetlb" into the function names, but maybe in the future we'll be able to use a single flag per folio (I know, it's complicated ...).A single flag per folio should be the future direction, but I haven't done the research so can't tell how complicated it will be.
There were some discussions on it, and it's tricky. So maybe we should really just have folio_test_hugetlb_mte_tagged() etc. for now
Signature · 3 lines
Cheers, David / dhildenb
Quoted 111 lines · David Hildenbrand
Quoted 94 lines · Yang Shi
Quoted 81 lines · David Hildenbrand
Quoted 80 lines · Yang Shi
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
Signed-off-by Yang Shi <[email protected]>---
arch/arm64/include/asm/hugetlb.h| 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +-8 files changed, 90 insertions(+), 10 deletions(-)v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.arch/arm64/include/asm/hugetlb.h +10
-1@@ -11,6 +11,7 @@ #define __ASM_HUGETLB_H #include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION@@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h); static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &folio->flags); + const unsigned long clear_flags = BIT(PG_dcache_clean) | + BIT(PG_mte_tagged) | BIT(PG_mte_lock); + + if (!system_supports_mte()) { + clear_bit(PG_dcache_clean, &folio->flags); + return; + } + + folio->flags &= ~clear_flags; } #define arch_clear_hugetlb_flags arch_clear_hugetlb_flagsdiff --git
a/arch/arm64/include/asm/mman.hb/arch/arm64/include/asm/mman.h
index5966ee4a6154..304dfc499e68100644arch/arm64/include/asm/mman.h +0
-0@@ -28,7 +28,8 @@ static inline unsigned longarch_calc_vm_flag_bits (unsigned long flags ) * backed by tags-capable memory. The vm_flags may beoverridden by a
* filesystem supporting MTE (RAM-based). */
- if (system_supports_mte()&& (flags &MAP_ANONYMOUS)) + if (system_supports_mte()&&
+ (flags & (MAP_ANONYMOUS|MAP_HUGETLB))) returnVM_MTE_ALLOWED;
return 0;arch/arm64/kernel/hibernate.c +2
-0@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn = zone_end_pfn(zone); for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { struct page *page = pfn_to_online_page(pfn); + struct folio *folio; if (!page) continue; + folio = page_folio(page); +Quoted 8 lines
arch/arm64/kernel/hibernate.c static int swsusp_mte_save_tags(void) · line 278
Quoted 3 lines
arch/arm64/kernel/hibernate.c +3
-0+ if (folio_test_hugetlb(folio) && + !page_mte_tagged(&folio->page)) + continue;Can we have
folio_test_mte_tagged()whereby you make sure that onlyfolio_test_hugetlb()uses it for now (VM_WARN_ON_ONCE) and then make sure that nobody usespage_mte_tagged()on hugetlb folios (VM_WARN_ON_ONCE)?Quoted 7 lines
IIUC, you mean something like the below?
bool
folio_test_mte_tagged(struct folio *folio){ VM_WARN_ON_ONCE(!folio_test_hugetlb(folio));return
test_bit(PG_mte_tagged, &folio->page->flags);
folio->flagsQuoted 6 lines
}
bool
page_mte_tagged(struct page *page)
{
struct folio *folio =page_folio(page);
Quoted 5 lines
Quoted 1 line
VM_WARN_ON_ONCE(folio_test_hugetlb(folio));
Yes, but better as
VM_WARN_ON_ONCE(folio_test_hugetlb(page_folio(page)));
I see. But I think all the call sites for folio_test_mte_tagged() actually need have folio_test_hugetlb() before it. So the warn seems not very useful other than warning on some misuse.
Quoted 6 lines
Quoted 6 lines
return
test_bit(PG_mte_tagged, &pge->flags); }Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Same for
folio_set_mte_tagged()and other functions. We could slap a "hugetlb" into the function names, but maybe in the future we'll be able to use a single flag per folio (I know, it's complicated ...).A single flag per folio should be the future direction, but I haven't done the research so can't tell how complicated it will be.
There were some discussions on it, and it's tricky. So maybe we should really just have
folio_test_hugetlb_mte_tagged()etc. for now
Either w/ hugetlb or w/o hugetlb is fine, I don't have strong opinion on the naming.
Quoted 117 lines · Yang Shi
Quoted 114 lines · David Hildenbrand
Quoted 95 lines · Yang Shi
Quoted 82 lines · David Hildenbrand
Quoted 81 lines · Yang Shi
Enable MTE support for hugetlb.
The MTE page flags will be set on the head page only. When copying hugetlb folio, the tags for all tail pages will be copied when copying head page.
When freeing hugetlb folio, the MTE flags will be cleared.
Signed-off-by Yang Shi <[email protected]>--- arch/arm64/include/asm/hugetlb.h | 11 ++++++++++- arch/arm64/include/asm/mman.h | 3 ++- arch/arm64/kernel/hibernate.c | 7 +++++++ arch/arm64/kernel/mte.c | 25 +++++++++++++++++++++++-- arch/arm64/kvm/guest.c | 16 +++++++++++++--- arch/arm64/kvm/mmu.c | 11 +++++++++++ arch/arm64/mm/copypage.c | 25 +++++++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 +- 8 files changed, 90 insertions(+), 10 deletions(-)v2: * Reimplemented the patch to fix the comments from Catalin.
* Added test cases (patch #2) per Catalin.arch/arm64/include/asm/hugetlb.h +10
-1@@ -11,6 +11,7 @@ #define __ASM_HUGETLB_H #include <asm/cacheflush.h> +#include <asm/mte.h> #include <asm/page.h> #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION@@ -20,7 +21,15 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h); static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &folio->flags); + const unsigned long clear_flags = BIT(PG_dcache_clean) | + BIT(PG_mte_tagged) | BIT(PG_mte_lock); + + if (!system_supports_mte()) { + clear_bit(PG_dcache_clean, &folio->flags); + return; + } + + folio->flags &= ~clear_flags; } #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags diff --git a/arch/arm64/include/asm/mman.h
b/arch/arm64/include/asm/mman.h
index5966ee4a6154..304dfc499e68100644arch/arm64/include/asm/mman.h +0
-0@@ -28,7 +28,8 @@ static inline unsigned longarch_calc_vm_flag_bits (unsigned long flags ) * backed by tags-capable memory. The vm_flags may beoverridden by a
* filesystem supporting MTE (RAM-based). */
- if (system_supports_mte()&& (flags &MAP_ANONYMOUS)) + if (system_supports_mte()&&
+ (flags & (MAP_ANONYMOUS|MAP_HUGETLB)))
returnVM_MTE_ALLOWED;
return 0;arch/arm64/kernel/hibernate.c +2
-0@@ -266,10 +266,17 @@ static int swsusp_mte_save_tags(void) max_zone_pfn = zone_end_pfn(zone); for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { struct page *page = pfn_to_online_page(pfn); + struct folio *folio; if (!page) continue; + folio = page_folio(page); +Quoted 8 lines
arch/arm64/kernel/hibernate.c static int swsusp_mte_save_tags(void) · line 278
Quoted 3 lines
arch/arm64/kernel/hibernate.c +3
-0+ if (folio_test_hugetlb(folio) && + !page_mte_tagged(&folio->page)) + continue;Can we have
folio_test_mte_tagged()whereby you make sure that onlyfolio_test_hugetlb()uses it for now (VM_WARN_ON_ONCE) and then make sure that nobody usespage_mte_tagged()on hugetlb folios (VM_WARN_ON_ONCE)?Quoted 7 lines
IIUC, you mean something like the below?
bool
folio_test_mte_tagged(struct folio *folio){
VM_WARN_ON_ONCE(!folio_test_hugetlb(folio));return
test_bit(PG_mte_tagged, &folio->page->flags);
folio->flagsQuoted 7 lines
}
bool
page_mte_tagged(struct page *page)
{
struct folio *folio =page_folio(page);VM_WARN_ON_ONCE(folio_test_hugetlb(folio));
Quoted 7 lines
Quoted 3 lines
Yes, but better as
VM_WARN_ON_ONCE(folio_test_hugetlb(page_folio(page)));
I see. But I think all the call sites for
folio_test_mte_tagged()actually need havefolio_test_hugetlb()before it. So the warn seems not very useful other than warning on some misuse.
... well, that's the whole reason for them :)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
return
test_bit(PG_mte_tagged, &pge->flags);
}Quoted 4 lines
Same for
folio_set_mte_tagged()and other functions. We could slap a "hugetlb" into the function names, but maybe in the future we'll be able to use a single flag per folio (I know, it's complicated ...).
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
A single flag per folio should be the future direction, but I haven't done the research so can't tell how complicated it will be.
There were some discussions on it, and it's tricky. So maybe we should really just have
folio_test_hugetlb_mte_tagged()etc. for nowEither w/ hugetlb or w/o hugetlb is fine, I don't have strong opinion on the naming.
Let's go with "hugetlb" for now, using it for other large folios is out of sight a bit ... at least right now :)
Signature · 3 lines
Cheers, David / dhildenb