hugetlbfs: add MTE support
Subsystems (4)
PATCH 1/1 hugetlbfs: add MTE support
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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
Andrew Morton
maintainerQuoted 6 lines · On Tue, 25 Jun 2024 16:37:17 -0700 Yang Shi <[email protected]> wrote:
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) · line 116
Quoted 8 lines
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);
How thoroughly has this been tested?
Can we expect normal linux-next testing to exercise this, or must testers make special arangements to get the coverage?
Quoted 16 lines · Andrew Morton
Quoted 13 lines · On Tue, 25 Jun 2024 16:37:17 -0700 Yang Shi <[email protected]> wrote:
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
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;
Quoted 6 lines
fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) · line 116
Quoted 1 line
fs/hugetlbfs/inode.c +0
-0ret =seal_check_write (info->seals, vma);How thoroughly has this been tested?
Can we expect normal linux-next testing to exercise this, or must testers make special arangements to get the coverage?
It requires special arrangements. This needs hardware support and custom-patched QEMU. We did in-house test on AmpereOne platform with patched QEMU 8.1.
Quoted 1 line
Quoted 22 lines · Yang Shi
Quoted 20 lines · Andrew Morton
Quoted 6 lines · On Tue, 25 Jun 2024 16:37:17 -0700 Yang Shi <[email protected]> wrote:
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) · line 116
Quoted 8 lines
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);How thoroughly has this been tested?
Quoted 6 lines
Quoted 2 lines
Can we expect normal linux-next testing to exercise this, or must testers make special arangements to get the coverage?
It requires special arrangements. This needs hardware support and custom-patched QEMU. We did in-house test on AmpereOne platform with patched QEMU 8.1.
To correct, custom-patched QEMU is not required for a minimum test. But a special test program is definitely needed. We used custom-patched QEMU to test VM backed by hugetlbfs with MTE enabled.
Quoted 2 lines
Quoted 2 lines
Catalin Marinas
maintainerQuoted 13 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/hugetlbfs/inode.c +0
-0
fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) · line 114
Quoted 6 lines
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;
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no arch_clear_hugetlb_flags() implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with the folio_copy() -> copy_highpage() which expects the PG_arch_* flags on each individual page. The alternative was for arch_clear_hugetlb_flags() to iterate over all the pages in a folio.
I'd also like to see some tests added to tools/testing/selftest/arm64/mte to exercise MAP_HUGETLB with PROT_MTE:
write/read tags, a series of mman+munmap (mostly to check if old page flags are still around), force some copy on write. I don't think we should merge the patch without proper tests.
An untested hunk on top of your changes:
arch/arm64/include/asm/hugetlb.h +13 -1
@@ -20,7 +20,19 @@ 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); +unsigned long i, nr_pages =folio_nr_pages (folio); +const unsigned long clear_flags =BIT (PG_dcache_clean) | +BIT (PG_arch_2) |BIT (PG_arch_3); + +if (!system_supports_mte ()) { +clear_bit (PG_dcache_clean, &folio->flags); +return ; + } + +for (i =0 ; i < nr_pages; i++) { +struct page *page =folio_page (folio, i); + page->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 ;
Signature · 1 line
Catalin
Quoted 21 lines · Catalin Marinas
Quoted 13 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/hugetlbfs/inode.c +0
-0fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) · line 114
Quoted 6 lines
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;
Quoted 7 lines
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.
This would likely also add a blocker for ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP on arm64 (no idea if there are now ways to move forward with that now, or if we are still not sure if we can actually add support), correct?
Signature · 3 lines
Cheers, David / dhildenb
Quoted 31 lines · David Hildenbrand
Quoted 22 lines · Catalin Marinas
Quoted 13 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>---
fs/hugetlbfs/inode.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/hugetlbfs/inode.c +0
-0fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file · line 115
Quoted 7 lines
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;Quoted 7 lines
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.
Quoted 1 line
This would likely also add a blocker for
ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAPon arm64 (no idea if there are now ways to move forward with that now, or if we are still not sure if we can actually add support), correct?
IIUC, it is not. We just need to guarantee each subpage has PG_mte_tagged flag and allocated tags. The HVO just maps the 7 vmemmap pages for sub pages to the first page, they still see the flag and the space for tag is not impacted, right? Did I miss something?
Quoted 2 lines
Quoted 39 lines · Yang Shi
Quoted 31 lines · David Hildenbrand
Quoted 22 lines · Catalin Marinas
Quoted 13 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/hugetlbfs/inode.c +0
-0fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file · line 115
Quoted 7 lines
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;Quoted 7 lines
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.Quoted 4 lines
This would likely also add a blocker for
ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAPon arm64 (no idea if there are now ways to move forward with that now, or if we are still not sure if we can actually add support), correct?
Quoted 4 lines
IIUC, it is not. We just need to guarantee each subpage has
PG_mte_taggedflag and allocated tags. The HVO just maps the 7 vmemmap pages for sub pages to the first page, they still see the flag and the space for tag is not impacted, right? Did I miss something?
In the R/O vmemmap optimization we won't be able to modify the flags of the double-mapped vmemmap pages via the double mappings.
Of course, we could find HVO-specific ways to only modify the flags of the first vmemmap page, but it does sound wrong ...
Really, the question is if we can have a per-folio flag for hugetlb instead and avoid all that?
Signature · 3 lines
Cheers, David / dhildenb
Catalin Marinas
maintainerQuoted 43 lines · David Hildenbrand
Quoted 37 lines · Yang Shi
Quoted 31 lines · David Hildenbrand
Quoted 22 lines · Catalin Marinas
Quoted 13 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/hugetlbfs/inode.c +0
-0fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file · line 115
Quoted 7 lines
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;Quoted 7 lines
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.Quoted 4 lines
This would likely also add a blocker for
ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAPon arm64 (no idea if there are now ways to move forward with that now, or if we are still not sure if we can actually add support), correct?Quoted 4 lines
IIUC, it is not. We just need to guarantee each subpage has
PG_mte_taggedflag and allocated tags. The HVO just maps the 7 vmemmap pages for sub pages to the first page, they still see the flag and the space for tag is not impacted, right? Did I miss something?
Quoted 8 lines
In the R/O vmemmap optimization we won't be able to modify the flags of the double-mapped vmemmap pages via the double mappings.
Of course, we could find HVO-specific ways to only modify the flags of the first vmemmap page, but it does sound wrong ...
Really, the question is if we can have a per-folio flag for hugetlb instead and avoid all that?
I think it is possible and I have some half-baked changes but got distracted and never completed. The only issue I came across was folio_copy() calling copy_highpage() on individual pages that did not have the original PG_mte_tagged (PG_arch_2) flag. To avoid some races, we also use PG_mte_lock (PG_arch_3) as some form of locking but for optimisation we don't clear this flag after copying the tags and setting PG_mte_tagged. So doing the checks on the head page only confuses the tail page copying.
Even if we use PG_arch_3 as a proper lock bit and clear it after tag copying, I'll need to check whether this can race with any mprotect(PROT_MTE) that could cause losing tags or leaking tags (not initialising the pages). set_pte_at() relies on the PG_mte_tagged flag to decide whether to initialise the tags. The arm64 hugetlbfs supports contiguous ptes, so we'd get multiple set_pte_at() calls.
Anyway, I think with some care it is doable, I just did not have the time, nor did I see anyone asking for such feature until now.
Signature · 1 line
Catalin
Quoted 19 lines · Catalin Marinas
Quoted 18 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>--- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)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 );
Quoted 8 lines
fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) · line 114
Quoted 1 line
fs/hugetlbfs/inode.c +0
-0vma->vm_ops = &hugetlb_vm_ops;Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.
Thanks for pointing this out. I did miss this point. I took a quick look at when the PG_ flags are set. IIUC, it is set by post_alloc_hook() for order-0 anonymous folio (clearing page and tags) and set_ptes() for others (just clear tags), for example, THP and hugetlb.
I can see THP does set the PG_mte_tagged flag for each sub pages. But it seems it does not do it for hugetlb if I read the code correctly. The call path is:
hugetlb_fault() ->
hugetlb_no_page->
set_huge_pte_at ->
__set_ptes() ->
__sync_cache_and_tags() ->
The __set_ptes() is called in a loop:
if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize) __set_ptes(mm, addr, ptep, pte, 1); return;
}
The ncontig and pgsize are returned by num_contig_ptes(). For example, 2M hugetlb, ncontig is 1 and pgsize is 2M IIUC. So it means actually just the head page has PG_mte_tagged set. If so the copy_highpage() will just copy the old head page's flag to the new head page, and the tag. All the sub pages don't have PG_mte_tagged set.
Is it expected behavior? I'm supposed we need tags for every sub pages too, right?
Quoted 39 lines
I'd also like to see some tests added to
tools/testing/selftest/arm64/mteto exerciseMAP_HUGETLBwithPROT_MTE:
write/read tags, a series of mman+munmap (mostly to check if old page flags are still around), force some copy on write. I don't think we should merge the patch without proper tests.An untested hunk on top of your changes:
arch/arm64/include/asm/hugetlb.h +13
-1@@ -20,7 +20,19 @@ 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); +unsigned long i, nr_pages =folio_nr_pages (folio); +const unsigned long clear_flags =BIT (PG_dcache_clean) | +BIT (PG_arch_2) |BIT (PG_arch_3); + +if (!system_supports_mte ()) { +clear_bit (PG_dcache_clean, &folio->flags); +return ; + } + +for (i =0 ; i < nr_pages; i++) { +struct page *page =folio_page (folio, i); + page->flags &= ~clear_flags; + } }#define arch_clear_hugetlb_flags arch_clear_hugetlb_flagsarch/arm64/include/asm/mman.h +0
-0
arch/arm64/include/asm/mman.h static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags) · line 33
Quoted 7 lines
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 ;
Do we really need this change? IIRC, the mmap_region() will call hugetlbfs's mmap and set VM_MTE_ALLOWED in vma->vm_flags, then update vma->vm_page_prot with the new vma->vm_flags.
If this is needed, MTE for tmpfs won't work, right?
Quoted 3 lines
arch/arm64/include/asm/mman.h +0
-0return 0 ;
Quoted 51 lines · Yang Shi
Quoted 20 lines · Catalin Marinas
Quoted 19 lines · Yang Shi
MTE can be supported on ram based filesystem. It is supported on tmpfs. There is use case to use MTE on hugetlbfs as well, adding MTE support.
Signed-off-by Yang Shi <[email protected]>---
fs/hugetlbfs/inode.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)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);Quoted 8 lines
fs/hugetlbfs/inode.c static int hugetlbfs_file_mmap(struct file · line 115
Quoted 1 line
fs/hugetlbfs/inode.c +0
-0vma->vm_ops = &hugetlb_vm_ops;Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.Thanks for pointing this out. I did miss this point. I took a quick look at when the
PG_flags are set. IIUC, it is set bypost_alloc_hook()for order-0 anonymous folio (clearing page and tags) andset_ptes()for others (just clear tags), for example, THP and hugetlb.I can see THP does set the
PG_mte_taggedflag for each sub pages. But it seems it does not do it for hugetlb if I read the code correctly. The call path is:
hugetlb_fault()->
hugetlb_no_page->
set_huge_pte_at->
__set_ptes()->
__sync_cache_and_tags()->The
__set_ptes()is called in a loop:if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)__set_ptes(mm, addr, ptep, pte, 1); return;
}
Quoted 4 lines
The ncontig and pgsize are returned by
num_contig_ptes(). For example, 2M hugetlb, ncontig is 1 and pgsize is 2M IIUC. So it means actually just the head page hasPG_mte_taggedset. If so thecopy_highpage()will just copy the old head page's flag to the new head page, and the tag. All the sub pages don't havePG_mte_taggedset.Is it expected behavior? I'm supposed we need tags for every sub pages too, right?
We should need something like the below to have tags and page flag set up for each sub page:
arch/arm64/mm/hugetlbpage.c +0 -0
@@ -228,9 +228,12 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
int ncontig;
unsigned long pfn, dpfn;
pgprot_t hugeprot;
+ unsigned long nr = sz >> PAGE_SHIFT;
ncontig = num_contig_ptes(sz, &pgsize);
+ __sync_cache_and_tags(pte, nr);
+
if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize) __set_ptes(mm, addr, ptep, pte, 1);
Quoted 55 lines
Quoted 39 lines
I'd also like to see some tests added to
tools/testing/selftest/arm64/mteto exerciseMAP_HUGETLBwithPROT_MTE:
write/read tags, a series of mman+munmap (mostly to check if old page flags are still around), force some copy on write. I don't think we should merge the patch without proper tests.An untested hunk on top of your changes:
arch/arm64/include/asm/hugetlb.h +13
-1@@ -20,7 +20,19 @@ 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); + unsigned long i, nr_pages = folio_nr_pages(folio); + const unsigned long clear_flags = BIT(PG_dcache_clean) | + BIT(PG_arch_2) | BIT(PG_arch_3); + + if (!system_supports_mte()) { + clear_bit(PG_dcache_clean, &folio->flags); + return; + } + + for (i = 0; i < nr_pages; i++) { + struct page *page = folio_page(folio, i); + page->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 static inline unsigned long · line 34
Quoted 8 lines
arch/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;Do we really need this change? IIRC, the
mmap_region()will call hugetlbfs's mmap and setVM_MTE_ALLOWEDinvma->vm_flags, then updatevma->vm_page_protwith the newvma->vm_flags.If this is needed, MTE for tmpfs won't work, right?
Quoted 2 lines
arch/arm64/include/asm/mman.h +0
-0return 0;
Catalin Marinas
maintainerQuoted 63 lines · Yang Shi
Quoted 33 lines · Yang Shi
Quoted 7 lines · Catalin Marinas
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.Thanks for pointing this out. I did miss this point. I took a quick look at when the
PG_flags are set. IIUC, it is set bypost_alloc_hook()for order-0 anonymous folio (clearing page and tags) andset_ptes()for others (just clear tags), for example, THP and hugetlb.I can see THP does set the
PG_mte_taggedflag for each sub pages. But it seems it does not do it for hugetlb if I read the code correctly. The call path is:
hugetlb_fault()->
hugetlb_no_page->
set_huge_pte_at->
__set_ptes()->
__sync_cache_and_tags()->The
__set_ptes()is called in a loop:if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)__set_ptes(mm, addr, ptep, pte, 1); return;
}Quoted 8 lines
The ncontig and pgsize are returned by
num_contig_ptes(). For example, 2M hugetlb, ncontig is 1 and pgsize is 2M IIUC. So it means actually just the head page hasPG_mte_taggedset. If so thecopy_highpage()will just copy the old head page's flag to the new head page, and the tag. All the sub pages don't havePG_mte_taggedset.Is it expected behavior? I'm supposed we need tags for every sub pages too, right?
We should need something like the below to have tags and page flag set up for each sub page:
arch/arm64/mm/hugetlbpage.c +3
-0@@ -228,9 +228,12 @@ void set_huge_pte_at(struct mm_struct *mm, unsignedlong addr, int ncontig; unsigned long pfn, dpfn; pgprot_t hugeprot; + unsigned long nr = sz >> PAGE_SHIFT; ncontig = num_contig_ptes(sz, &pgsize); + __sync_cache_and_tags(pte, nr); + if (!pte_present(pte)) { for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)
Quoted 1 line
__set_ptes(mm, addr, ptep, pte, 1);
We only need this for the last loop when we have a present pte. I'd also avoid calling __set_ptes(...., 1) if we call the __sync_cache_and_tags() here already. Basically just unroll __set_ptes() in set_huge_pte_at() and call __set_pte() directly.
It might be better to convert those page flag checks to only happen on the head page. My stashed changes from over a year ago (before we had more folio conversions) below. However, as I mentioned, I got stuck on folio_copy() which also does a cond_resched() between copy_highpage().
---------8<--------------------------------
arch/arm64/kernel/mte.c +13 -10
@@ -49,7 +49,9 @@ static void mte_sync_page_tags(struct page *page, pte_t old_pte,return ;if (try_page_mte_tagging (page)) { -mte_clear_page_tags (page_address (page)); +unsigned long i, nr_pages =compound_nr (page); +for (i =0 ; i < nr_pages; i++) +mte_clear_page_tags (page_address (page + i));set_page_mte_tagged (page); } }
@@ -57,22 +59,23 @@ static void mte_sync_page_tags(struct page *page, pte_t old_pte,void mte_sync_tags (pte_t old_pte,pte_t pte) {struct page *page =pte_page (pte); -long i, nr_pages =compound_nr (page); -bool check_swap = nr_pages ==1 ; +bool check_swap = !PageCompound (page);bool pte_is_tagged =pte_tagged (pte);/* Early out if there's nothing to do */ if (!check_swap && !pte_is_tagged)return ; +/* +* HugeTLB pages are always fully mapped, so only setting head page's +* PG_mte_* flags is enough. +*/ +if (PageHuge (page)) + page =compound_head (page); +/* if PG_mte_tagged is set, tags have already been initialised */ -for (i =0 ; i < nr_pages; i++, page++) { -if (!page_mte_tagged (page)) { -mte_sync_page_tags (page, old_pte, check_swap, - pte_is_tagged); -set_page_mte_tagged (page); - } - } +if (!page_mte_tagged (page)) +mte_sync_page_tags (page, old_pte, check_swap, pte_is_tagged);/* ensure the tags are visible before the PTE is set */ smp_wmb ();
arch/arm64/kvm/guest.c +1 -1
@@ -1079,7 +1079,7 @@ long kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,/* uaccess failed, don't leave stale tags */ if (num_tags !=MTE_GRANULES_PER_PAGE ) -mte_clear_page_tags (page); +mte_clear_page_tags (page_address (page));set_page_mte_tagged (page);kvm_release_pfn_dirty (pfn);
arch/arm64/kvm/mmu.c +4 -5
@@ -1173,11 +1173,10 @@ static void sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn,if (!kvm_has_mte (kvm))return ; -for (i =0 ; i < nr_pages; i++, page++) { -if (try_page_mte_tagging (page)) { -mte_clear_page_tags (page_address (page)); -set_page_mte_tagged (page); - } +if (try_page_mte_tagging (page)) { +for (i =0 ; i < nr_pages; i++) +mte_clear_page_tags (page_address (page + i)); +set_page_mte_tagged (page); } }
Signature · 1 line
Catalin
Quoted 68 lines · Catalin Marinas
Quoted 61 lines · Yang Shi
Quoted 32 lines · Yang Shi
Quoted 7 lines · Catalin Marinas
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.Thanks for pointing this out. I did miss this point. I took a quick look at when the
PG_flags are set. IIUC, it is set bypost_alloc_hook()for order-0 anonymous folio (clearing page and tags) andset_ptes()for others (just clear tags), for example, THP and hugetlb.I can see THP does set the
PG_mte_taggedflag for each sub pages. But it seems it does not do it for hugetlb if I read the code correctly. The call path is:
hugetlb_fault()->
hugetlb_no_page->
set_huge_pte_at->
__set_ptes()->
__sync_cache_and_tags()->The
__set_ptes()is called in a loop:if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)__set_ptes(mm, addr, ptep, pte, 1); return;
}Quoted 8 lines
The ncontig and pgsize are returned by
num_contig_ptes(). For example, 2M hugetlb, ncontig is 1 and pgsize is 2M IIUC. So it means actually just the head page hasPG_mte_taggedset. If so thecopy_highpage()will just copy the old head page's flag to the new head page, and the tag. All the sub pages don't havePG_mte_taggedset.Is it expected behavior? I'm supposed we need tags for every sub pages too, right?
We should need something like the below to have tags and page flag set up for each sub page:
arch/arm64/mm/hugetlbpage.c +3
-0@@ -228,9 +228,12 @@ void set_huge_pte_at(struct mm_struct *mm, unsignedlong addr, int ncontig; unsigned long pfn, dpfn; pgprot_t hugeprot; + unsigned long nr = sz >> PAGE_SHIFT; ncontig = num_contig_ptes(sz, &pgsize); + __sync_cache_and_tags(pte, nr); + if (!pte_present(pte)) { for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)Quoted 1 line
__set_ptes(mm, addr, ptep, pte, 1);We only need this for the last loop when we have a present pte. I'd also avoid calling
__set_ptes(...., 1)if we call the__sync_cache_and_tags()here already. Basically just unroll__set_ptes()inset_huge_pte_at()and call__set_pte()directly.
Quoted 4 lines
It might be better to convert those page flag checks to only happen on the head page. My stashed changes from over a year ago (before we had more folio conversions) below. However, as I mentioned, I got stuck on
folio_copy()which also does acond_resched()betweencopy_highpage().
We can have the page flags set for head only for hugetlb page. For copy_highpage(), we should be able to do something like the below:
if page_is_head && page_is_hugetlb && page_has_mte_tagged set page_mte_tagged flags
copy tags for all sub pages
else // <-- tail page or non-hugetlb page
current copy_highpage implementation
The hugetlb folio can't go away under us since migration path should pin it so the status of folio is stable. The preemption caused by cond_resched() should be fine too due to the pin and the page table entry keeps being migration entry until migration is done, so every one should just see migration entry and wait for migration is done.
The other concerned user of copy_highpage() is uprobe, but it also pins the page then doing copy and it is called with holding write mmap_lock.
IIUC, it should work if I don't miss something. This also should have no impact on HVO. The overhead for other users of copy_highpage() should be also acceptable.
Quoted 84 lines
---------8<--------------------------------
arch/arm64/kernel/mte.c +13
-10@@ -49,7 +49,9 @@ static void mte_sync_page_tags(struct page *page, pte_t old_pte,return ;if (try_page_mte_tagging (page)) { -mte_clear_page_tags (page_address (page)); +unsigned long i, nr_pages =compound_nr (page); +for (i =0 ; i < nr_pages; i++) +mte_clear_page_tags (page_address (page + i));set_page_mte_tagged (page); } }@@ -57,22 +59,23 @@ static void mte_sync_page_tags(struct page *page, pte_t old_pte,void mte_sync_tags (pte_t old_pte,pte_t pte) {struct page *page =pte_page (pte); -long i, nr_pages =compound_nr (page); -bool check_swap = nr_pages ==1 ; +bool check_swap = !PageCompound (page);bool pte_is_tagged =pte_tagged (pte);/* Early out if there's nothing to do */ if (!check_swap && !pte_is_tagged)return ; +/* +* HugeTLB pages are always fully mapped, so only setting head page's +* PG_mte_* flags is enough. +*/ +if (PageHuge (page)) + page =compound_head (page); +/* if PG_mte_tagged is set, tags have already been initialised */ -for (i =0 ; i < nr_pages; i++, page++) { -if (!page_mte_tagged (page)) { -mte_sync_page_tags (page, old_pte, check_swap, - pte_is_tagged); -set_page_mte_tagged (page); - } - } +if (!page_mte_tagged (page)) +mte_sync_page_tags (page, old_pte, check_swap, pte_is_tagged);/* ensure the tags are visible before the PTE is set */ smp_wmb ();arch/arm64/kvm/guest.c +1
-1@@ -1079,7 +1079,7 @@ long kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,/* uaccess failed, don't leave stale tags */ if (num_tags !=MTE_GRANULES_PER_PAGE ) -mte_clear_page_tags (page); +mte_clear_page_tags (page_address (page));set_page_mte_tagged (page);kvm_release_pfn_dirty (pfn);arch/arm64/kvm/mmu.c +4
-5@@ -1173,11 +1173,10 @@ static void sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn,if (!kvm_has_mte (kvm))return ; -for (i =0 ; i < nr_pages; i++, page++) { -if (try_page_mte_tagging (page)) { -mte_clear_page_tags (page_address (page)); -set_page_mte_tagged (page); - } +if (try_page_mte_tagging (page)) { +for (i =0 ; i < nr_pages; i++) +mte_clear_page_tags (page_address (page + i)); +set_page_mte_tagged (page); } }
Quoted 72 lines · Yang Shi
Quoted 69 lines · Catalin Marinas
Quoted 56 lines · Yang Shi
Quoted 32 lines · Yang Shi
Quoted 7 lines · Catalin Marinas
Last time I checked, about a year ago, this was not sufficient. One issue is that there's no
arch_clear_hugetlb_flags()implemented by your patch, leaving PG_arch_{2,3} set on a page. The other issue was that I initially tried to do this only on the head page but this did not go well with thefolio_copy()->copy_highpage()which expects the PG_arch_* flags on each individual page. The alternative was forarch_clear_hugetlb_flags()to iterate over all the pages in a folio.Thanks for pointing this out. I did miss this point. I took a quick look at when the
PG_flags are set. IIUC, it is set bypost_alloc_hook()for order-0 anonymous folio (clearing page and tags) andset_ptes()for others (just clear tags), for example, THP and hugetlb.I can see THP does set the
PG_mte_taggedflag for each sub pages. But it seems it does not do it for hugetlb if I read the code correctly. The call path is:
hugetlb_fault()->
hugetlb_no_page->
set_huge_pte_at->
__set_ptes()->
__sync_cache_and_tags()->The
__set_ptes()is called in a loop:if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)__set_ptes(mm, addr, ptep, pte, 1); return;
}Quoted 8 lines
The ncontig and pgsize are returned by
num_contig_ptes(). For example, 2M hugetlb, ncontig is 1 and pgsize is 2M IIUC. So it means actually just the head page hasPG_mte_taggedset. If so thecopy_highpage()will just copy the old head page's flag to the new head page, and the tag. All the sub pages don't havePG_mte_taggedset.Is it expected behavior? I'm supposed we need tags for every sub pages too, right?
We should need something like the below to have tags and page flag set up for each sub page:
arch/arm64/mm/hugetlbpage.c +0
-0@@ -228,9 +228,12 @@ void set_huge_pte_at(struct mm_struct *mm,unsigned
long addr,
int ncontig;
unsigned long pfn, dpfn;
pgprot_thugeprot;
+ unsigned long nr = sz >>PAGE_SHIFT;Quoted 7 lines
ncontig =
num_contig_ptes(sz, &pgsize);+
__sync_cache_and_tags(pte, nr);
+
if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)__set_ptes(mm, addr, ptep, pte, 1);We only need this for the last loop when we have a present pte. I'd also avoid calling
__set_ptes(...., 1)if we call the__sync_cache_and_tags()here already. Basically just unroll__set_ptes()inset_huge_pte_at()and call__set_pte()directly.
Quoted 5 lines
Quoted 4 lines
It might be better to convert those page flag checks to only happen on the head page. My stashed changes from over a year ago (before we had more folio conversions) below. However, as I mentioned, I got stuck on
folio_copy()which also does acond_resched()betweencopy_highpage().
Ping...
Does this make sense and sound good? If is is good, I will try to implement it.
Quoted 96 lines
We can have the page flags set for head only for hugetlb page. For
copy_highpage(), we should be able to do something like the below:if
page_is_head&&page_is_hugetlb&&page_has_mte_taggedsetpage_mte_taggedflags
copy tags for all sub pages
else // <-- tail page or non-hugetlb page
currentcopy_highpageimplementationThe hugetlb folio can't go away under us since migration path should pin it so the status of folio is stable. The preemption caused by
cond_resched()should be fine too due to the pin and the page table entry keeps being migration entry until migration is done, so every one should just see migration entry and wait for migration is done.The other concerned user of
copy_highpage()is uprobe, but it also pins the page then doing copy and it is called with holding writemmap_lock.IIUC, it should work if I don't miss something. This also should have no impact on HVO. The overhead for other users of
copy_highpage()should be also acceptable.Quoted 80 lines
---------8<--------------------------------
arch/arm64/kernel/mte.c +4
-3@@ -49,7 +49,9 @@ static void mte_sync_page_tags(struct page *page,pte_t old_pte, return; if (try_page_mte_tagging(page)) { - mte_clear_page_tags(page_address(page)); + unsigned long i, nr_pages = compound_nr(page); + for (i = 0; i < nr_pages; i++) + mte_clear_page_tags(page_address(page + i)); set_page_mte_tagged(page); } }@@ -57,22 +59,23 @@ static void mte_sync_page_tags(struct page *page,pte_t old_pte, void mte_sync_tags(pte_t old_pte, pte_t pte) { struct page *page = pte_page(pte); - long i, nr_pages = compound_nr(page); - bool check_swap = nr_pages == 1; + bool check_swap = !PageCompound(page); bool pte_is_tagged = pte_tagged(pte); /* Early out if there's nothing to do */ if (!check_swap && !pte_is_tagged) return;+ /*
+ * HugeTLB pages are always fully mapped, so only setting head page's
+ * PG_mte_* flags is enough.
+ */
+ if (PageHuge(page))
+ page =compound_head(page);
+
/* ifPG_mte_taggedis set, tags have already been initialised */ - for (i = 0; i <nr_pages; i++, page++) {
- if (!page_mte_tagged(page)) {
- mte_sync_page_tags(page,old_pte,check_swap,
-pte_is_tagged);
-set_page_mte_tagged(page);
- }
- }
+ if (!page_mte_tagged(page))
+mte_sync_page_tags(page, old_pte, check_swap, pte_is_tagged); /* ensure the tags are visible before the PTE is set */smp_wmb();arch/arm64/kvm/guest.c +1
-1@@ -1079,7 +1079,7 @@ long kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, /* uaccess failed, don't leave stale tags */ if (num_tags != MTE_GRANULES_PER_PAGE) - mte_clear_page_tags(page); + mte_clear_page_tags(page_address(page)); set_page_mte_tagged(page); kvm_release_pfn_dirty(pfn);arch/arm64/kvm/mmu.c +4
-4@@ -1173,11 +1173,10 @@ static void sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn, if (!kvm_has_mte(kvm)) return; - for (i = 0; i < nr_pages; i++, page++) { - if (try_page_mte_tagging(page)) { - mte_clear_page_tags(page_address(page)); - set_page_mte_tagged(page); - } + if (try_page_mte_tagging(page)) { + for (i = 0; i < nr_pages; i++) + mte_clear_page_tags(page_address(page + i)); + set_page_mte_tagged(page); } }
Catalin Marinas
maintainerSorry for the delay (holidays etc.)
Quoted 6 lines · Yang Shi
Quoted 4 lines · Catalin Marinas
It might be better to convert those page flag checks to only happen on the head page. My stashed changes from over a year ago (before we had more folio conversions) below. However, as I mentioned, I got stuck on
folio_copy()which also does acond_resched()betweencopy_highpage().
Quoted 8 lines
We can have the page flags set for head only for hugetlb page. For
copy_highpage(), we should be able to do something like the below:if
page_is_head&&page_is_hugetlb&&page_has_mte_taggedsetpage_mte_taggedflags
copy tags for all sub pages
else // <-- tail page or non-hugetlb page
currentcopy_highpageimplementation
Ah, so you want in the first copy_highpage() for the head page to populate the tags for the tail pages. I guess this would work.
Quoted 5 lines
The hugetlb folio can't go away under us since migration path should pin it so the status of folio is stable. The preemption caused by
cond_resched()should be fine too due to the pin and the page table entry keeps being migration entry until migration is done, so every one should just see migration entry and wait for migration is done.
Yeah, I don't see those pages going away, otherwise folio_copy() would corrupt data.
Quoted 6 lines
The other concerned user of
copy_highpage()is uprobe, but it also pins the page then doing copy and it is called with holding writemmap_lock.IIUC, it should work if I don't miss something. This also should have no impact on HVO. The overhead for other users of
copy_highpage()should be also acceptable.
I also think so. We also have the copy_user_highpage() on arm64 that calls copy_highpage() but I think that's also safe.
Signature · 1 line
Catalin
Quoted 11 lines · Catalin Marinas
Sorry for the delay (holidays etc.)
Quoted 8 lines · Yang Shi
Quoted 4 lines · Catalin Marinas
It might be better to convert those page flag checks to only happen on the head page. My stashed changes from over a year ago (before we had more folio conversions) below. However, as I mentioned, I got stuck on
folio_copy()which also does acond_resched()betweencopy_highpage().We can have the page flags set for head only for hugetlb page. For
copy_highpage(), we should be able to do something like the below:
Quoted 7 lines
Quoted 5 lines
if
page_is_head&&page_is_hugetlb&&page_has_mte_tagged
setpage_mte_taggedflags
copy tags for all sub pages
else // <-- tail page or non-hugetlb page
currentcopy_highpageimplementationAh, so you want in the first
copy_highpage()for the head page to populate the tags for the tail pages. I guess this would work.
Yes, because we know the order of hugetlb page so we know how many tail pages we need populate tags for.
A deeper look showed this may be the only way to do it (if we want to have mte page flag for head only) because process_huge_page() may starting copy from the middle of huge page to have hot sub pages in cache. The process_huge_page() is used by hugetlb fork and COW. I think it is safe to do so in fork and COW path too since the destination hugetlb page won't be seen by the users until fork or COW fault is done.
Quoted 9 lines
Quoted 6 lines
The hugetlb folio can't go away under us since migration path should pin it so the status of folio is stable. The preemption caused by
cond_resched()should be fine too due to the pin and the page table entry keeps being migration entry until migration is done, so every one should just see migration entry and wait for migration is done.Yeah, I don't see those pages going away, otherwise
folio_copy()would corrupt data.
Quoted 8 lines
Quoted 6 lines
The other concerned user of
copy_highpage()is uprobe, but it also pins the page then doing copy and it is called with holding writemmap_lock.IIUC, it should work if I don't miss something. This also should have no impact on HVO. The overhead for other users of
copy_highpage()should be also acceptable.I also think so. We also have the
copy_user_highpage()on arm64 that callscopy_highpage()but I think that's also safe.
Yes, it is used by fork and COW fault by hugetlb.