Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hugetlb: clear huge pte during flush function on mips platform

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>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Bibo Mao and committed by
Thomas Bogendoerfer
33ae8f80 9fa996c5

+7 -1
+7 -1
arch/mips/include/asm/hugetlb.h
··· 46 46 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, 47 47 unsigned long addr, pte_t *ptep) 48 48 { 49 - flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma))); 49 + /* 50 + * clear the huge pte entry firstly, so that the other smp threads will 51 + * not get old pte entry after finishing flush_tlb_page and before 52 + * setting new huge pte entry 53 + */ 54 + huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); 55 + flush_tlb_page(vma, addr); 50 56 } 51 57 52 58 #define __HAVE_ARCH_HUGE_PTE_NONE