From: Gerald Schaefer A cow break on a hugetlbfs page with page_count > 1 will set a new pte with set_huge_pte_at(), w/o any tlb flush operation. The old pte will remain in the tlb and subsequent write access to the page will result in a page fault loop, for as long as it may take until the tlb is flushed from somewhere else. This patch introduces an architecture-specific huge_ptep_clear_flush() function, which is called before the the set_huge_pte_at() in hugetlb_cow(). Cc: Andi Kleen Cc: David S. Miller Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Paul Mackerras Cc: Paul Mundt Cc: Thomas Gleixner Cc: Tony Luck Signed-off-by: Gerald Schaefer Signed-off-by: Martin Schwidefsky --- include/linux/hugetlb.h | 4 ++++ mm/hugetlb.c | 1 + 2 files changed, 5 insertions(+) Index: quilt-2.6/include/linux/hugetlb.h =================================================================== --- quilt-2.6.orig/include/linux/hugetlb.h +++ quilt-2.6/include/linux/hugetlb.h @@ -80,6 +80,10 @@ static inline int prepare_hugepage_range int prepare_hugepage_range(unsigned long addr, unsigned long len); #endif +#ifndef ARCH_HAS_HUGEPAGE_CLEAR_FLUSH +#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0) +#endif + #ifndef ARCH_HAS_SETCLEAR_HUGE_PTE #define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte) #define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep) Index: quilt-2.6/mm/hugetlb.c =================================================================== --- quilt-2.6.orig/mm/hugetlb.c +++ quilt-2.6/mm/hugetlb.c @@ -864,6 +864,7 @@ static int hugetlb_cow(struct mm_struct ptep = huge_pte_offset(mm, address & HPAGE_MASK); if (likely(pte_same(*ptep, pte))) { /* Break COW */ + huge_ptep_clear_flush(vma, address, ptep); set_huge_pte_at(mm, address, ptep, make_huge_pte(vma, new_page, 1)); /* Make the old page be freed below */ -- blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/