Skip to contentSkip to conversation

arm64/hugetlb: Fix building errors in huge_ptep_clear_flush()

PATCH In review Baolin Wang 4 participants 5 messages May 27, 2022 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/hugetlb: Fix building errors in huge_ptep_clear_flush()

Fix below building errors which was caused by commit ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte") interacting with commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").

Due to the new get_clear_contig() has dropped TLB flush, we should add an explicit TLB flush in huge_ptep_clear_flush() to keep original semantics when changing to use new get_clear_contig().

"
arch/arm64/mm/hugetlbpage.c: In function ‘huge_ptep_clear_flush’:
arch/arm64/mm/hugetlbpage.c:515:9: error: implicit declaration of function ‘get_clear_flush’; did you mean ‘ptep_clear_flush’? [-Werror=implicit-function-declaration]

  515 |  return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
      |         ^~~~~~~~~~~~~~~
      |         ptep_clear_flush

"

---
 arch/arm64/mm/hugetlbpage.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/mm/hugetlbpage.c +4 -1
index 0f0c17dfeb9c..e2a5ec9fdc0d 100644
@@ -507,12 +507,15 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
 {
 	size_t pgsize;
 	int ncontig;
+	pte_t orig_pte;
 
 	if (!pte_cont(READ_ONCE(*ptep)))
 		return ptep_clear_flush(vma, addr, ptep);
 
 	ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize);
-	return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
+	orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, ncontig);
+	flush_tlb_range(vma, addr, addr + pgsize * ncontig);
+	return orig_pte;
 }
 
 static int __init hugetlbpage_init(void)
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Baolin,

Quoted 25 lines · Baolin Wang

Fix below building errors which was caused by commit ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte") interacting with commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").

Due to the new get_clear_contig() has dropped TLB flush, we should add an explicit TLB flush in huge_ptep_clear_flush() to keep original semantics when changing to use new get_clear_contig().

"
arch/arm64/mm/hugetlbpage.c: In function ‘huge_ptep_clear_flush’:
arch/arm64/mm/hugetlbpage.c:515:9: error: implicit declaration of function ‘get_clear_flush’; did you mean ‘ptep_clear_flush’? [-Werror=implicit-function-declaration]

   515 |  return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
       |         ^~~~~~~~~~~~~~~
       |         ptep_clear_flush

"

Quoted 4 lines
---
  arch/arm64/mm/hugetlbpage.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

I ran to the compiling failure either and it would be caused by commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()"). It's worthy to have a "Fixes" tag. With those fixed:

Quoted 12 lines
arch/arm64/mm/hugetlbpage.c +1 -0
index 0f0c17dfeb9c..e2a5ec9fdc0d 100644
@@ -507,12 +507,15 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
  {
  	size_t pgsize;
  	int ncontig;
+	pte_t orig_pte;
 
  	if (!pte_cont(READ_ONCE(*ptep)))

arch/arm64/mm/hugetlbpage.c pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, · line 521

Quoted 10 lines
arch/arm64/mm/hugetlbpage.c +3 -1
  		return ptep_clear_flush(vma, addr, ptep);
 
  	ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize);
-	return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
+	orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, ncontig);
+	flush_tlb_range(vma, addr, addr + pgsize * ncontig);
+	return orig_pte;
  }
 
  static int __init hugetlbpage_init(void)

Thanks,
Gavin

#2 lore raw
Quoted 33 lines · Gavin Shan

Hi Baolin,

Quoted 25 lines · Baolin Wang

Fix below building errors which was caused by commit ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte") interacting with commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").

Due to the new get_clear_contig() has dropped TLB flush, we should add an explicit TLB flush in huge_ptep_clear_flush() to keep original semantics when changing to use new get_clear_contig().

"
arch/arm64/mm/hugetlbpage.c: In function ‘huge_ptep_clear_flush’:
arch/arm64/mm/hugetlbpage.c:515:9: error: implicit declaration of function ‘get_clear_flush’; did you mean ‘ptep_clear_flush’? [-Werror=implicit-function-declaration]
   515 |  return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); |         ^~~~~~~~~~~~~~~
       |         ptep_clear_flush
"

Quoted 4 lines

---
  arch/arm64/mm/hugetlbpage.c | 5 ++++-

  1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 3 lines

I ran to the compiling failure either and it would be caused by commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()"). It's worthy to have a "Fixes" tag. With those fixed:

Thanks for reminding. IMHO, better to add 2 related commits' fix tag. Linus, could you help to add them when applying this patch, or need a resend? Thanks.

Fixes ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte")
Fixes fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").
Quoted 28 lines
Quoted 11 lines
arch/arm64/mm/hugetlbpage.c +1 -0
index 0f0c17dfeb9c..e2a5ec9fdc0d 100644
@@ -507,12 +507,15 @@ pte_t huge_ptep_clear_flush(struct 
 vm_area_struct *vma,
   {
       size_t pgsize;
       int ncontig;
+    pte_t orig_pte;
       if (!pte_cont(READ_ONCE(*ptep)))

arch/arm64/mm/hugetlbpage.c pte_t huge_ptep_clear_flush(struct · line 521

Quoted 10 lines
arch/arm64/mm/hugetlbpage.c +3 -1
           return ptep_clear_flush(vma, addr, ptep);
       ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize);
-    return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
+    orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, 
 ncontig);
+    flush_tlb_range(vma, addr, addr + pgsize * ncontig);
+    return orig_pte;
   }
   static int __init hugetlbpage_init(void)
 

Thanks,
Gavin

Reviewed-by
#3 lore raw
Quoted 36 lines · Baolin Wang
Quoted 33 lines · Gavin Shan

Hi Baolin,

Quoted 29 lines · Baolin Wang

Fix below building errors which was caused by commit ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte") interacting with commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").

Due to the new get_clear_contig() has dropped TLB flush, we should add an explicit TLB flush in huge_ptep_clear_flush() to keep original semantics when changing to use new get_clear_contig().

"
arch/arm64/mm/hugetlbpage.c: In function ‘huge_ptep_clear_flush’:
arch/arm64/mm/hugetlbpage.c:515:9: error: implicit declaration of function ‘get_clear_flush’; did you mean ‘ptep_clear_flush’? [-Werror=implicit-function-declaration]
   515 |  return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); |         ^~~~~~~~~~~~~~~
       |         ptep_clear_flush
"

---
  arch/arm64/mm/hugetlbpage.c | 5 ++++-

  1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 3 lines

I ran to the compiling failure either and it would be caused by commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()"). It's worthy to have a "Fixes" tag. With those fixed:

Thanks for reminding. IMHO, better to add 2 related commits' fix tag. Linus, could you help to add them when applying this patch, or need a resend? Thanks.

Fixes ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte")
Fixes fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").

Although this merge conflict happened in flight, the earlier commit ae07562909f3 came afterwards by which time get_clear_contig() has been added without required TLB flush. Hence seems like 'Fixes:' tag applies to the earlier commit itself.

Nonetheless LGTM.

Quoted 19 lines
Quoted 19 lines
Quoted 14 lines
arch/arm64/mm/hugetlbpage.c +2 -1
index 0f0c17dfeb9c..e2a5ec9fdc0d 100644
@@ -507,12 +507,15 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
   {
       size_t pgsize;
       int ncontig;
+    pte_t orig_pte;
       if (!pte_cont(READ_ONCE(*ptep)))
           return ptep_clear_flush(vma, addr, ptep);
       ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize);
-    return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
+    orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, ncontig);
Quoted 8 lines
Quoted 8 lines

arch/arm64/mm/hugetlbpage.c pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,

Quoted 5 lines
arch/arm64/mm/hugetlbpage.c +2 -0
+    flush_tlb_range(vma, addr, addr + pgsize * ncontig);
+    return orig_pte;
   }
   static int __init hugetlbpage_init(void)
 

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Tested-by Linux Kernel Functional Testing on v1 1/1
#4 lore raw
In reply to Baolin Wang
Quoted 15 lines · Baolin Wang

Fix below building errors which was caused by commit ae07562909f3 ("mm: change huge_ptep_clear_flush() to return the original pte") interacting with commit fb396bb459c1 ("arm64/hugetlb: Drop TLB flush from get_clear_flush()").

Due to the new get_clear_contig() has dropped TLB flush, we should add an explicit TLB flush in huge_ptep_clear_flush() to keep original semantics when changing to use new get_clear_contig().

"
arch/arm64/mm/hugetlbpage.c: In function ‘huge_ptep_clear_flush’:
arch/arm64/mm/hugetlbpage.c:515:9: error: implicit declaration of function ‘get_clear_flush’; did you mean ‘ptep_clear_flush’? [-Werror=implicit-function-declaration]

Quoted 5 lines
  515 |  return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
      |         ^~~~~~~~~~~~~~~
      |         ptep_clear_flush

"

This patch tested on arm, arm64, i386 and x86 with gcc-11 and clang-14.

Quoted 6 lines
Quoted 26 lines
---
 arch/arm64/mm/hugetlbpage.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/mm/hugetlbpage.c +4 -2
index 0f0c17dfeb9c..e2a5ec9fdc0d 100644
@@ -507,12 +507,15 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
 {
        size_t pgsize;
        int ncontig;
+       pte_t orig_pte;
 
        if (!pte_cont(READ_ONCE(*ptep)))
                return ptep_clear_flush(vma, addr, ptep);
 
        ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize);
-       return get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig);
+       orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, ncontig);
+       flush_tlb_range(vma, addr, addr + pgsize * ncontig);
+       return orig_pte;
 }
 
 static int __init hugetlbpage_init(void)
--
Quoted 2 lines

2.27.0

--
Linaro LKFT
https://lkft.linaro.org

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel