linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hugetlb: clear huge pte during flush function on mips platform
@ 2020-06-29 13:15 bibo mao
  2020-06-29 13:15 ` [PATCH 2/2] hugetlb: use lightweight tlb flush when update huge tlb on mips bibo mao
  2021-05-11 21:03 ` [PATCH 1/2] hugetlb: clear huge pte during flush function on mips platform Thomas Bogendoerfer
  0 siblings, 2 replies; 3+ messages in thread
From: bibo mao @ 2020-06-29 13:15 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Anshuman Khandual, Andrew Morton, Mike Kravetz
  Cc: linux-mips, linux-kernel, linux-mm, Bibo Mao

From: Bibo Mao <maobibo@loongson.cn>

If multiple threads are accessing the same huge page at the same
time, hugetlb_cow will be called if one thread write the COW huge
page. And function huge_ptep_clear_flush is called to notify other
threads to clear the huge pte tlb entry. The other threads clear
the huge pte tlb entry and reload it from page table, the reload
huge pte entry may be old.

This patch fixes this issue on mips platform, and it clears huge
pte entry before notifying other threads to flush current huge
page entry, it is similar with other architectures.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 arch/mips/include/asm/hugetlb.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h
index 10e3be87..c214440 100644
--- a/arch/mips/include/asm/hugetlb.h
+++ b/arch/mips/include/asm/hugetlb.h
@@ -46,7 +46,13 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
 					 unsigned long addr, pte_t *ptep)
 {
-	flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma)));
+	/*
+	 * clear the huge pte entry firstly, so that the other smp threads will
+	 * not get old pte entry after finishing flush_tlb_page and before
+	 * setting new huge pte entry
+	 */
+	huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
+	flush_tlb_page(vma, addr);
 }
 
 #define __HAVE_ARCH_HUGE_PTE_NONE
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-11 21:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 13:15 [PATCH 1/2] hugetlb: clear huge pte during flush function on mips platform bibo mao
2020-06-29 13:15 ` [PATCH 2/2] hugetlb: use lightweight tlb flush when update huge tlb on mips bibo mao
2021-05-11 21:03 ` [PATCH 1/2] hugetlb: clear huge pte during flush function on mips platform Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).