The patch titled Subject: mm: call invalidate_range_end in do_wp_page even for zero pages has been added to the -mm tree. Its filename is mm-wrap-calls-to-set_pte_at_notify-with-invalidate_range_start-and-invalidate_range_end-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Haggai Eran <haggaie@xxxxxxxxxxxx> Subject: mm: call invalidate_range_end in do_wp_page even for zero pages The previous patch "mm: wrap calls to set_pte_at_notify with invalidate_range_start and invalidate_range_end" only called the invalidate_range_end mmu notifier function in do_wp_page when the new_page variable wasn't NULL. This was done in order to only call invalidate_range_end after invalidate_range_start was called. Unfortunately, there are situations where new_page is NULL and invalidate_range_start is called. This caused invalidate_range_start to be called without a matching invalidate_range_end, causing kvm to loop indefinitely on the first page fault. This patch adds a flag variable to do_wp_page that marks whether the invalidate_range_start notifier was called. invalidate_range_end is then called if the flag is true. Reported-by: Jiri Slaby <jslaby@xxxxxxx> Signed-off-by: Haggai Eran <haggaie@xxxxxxxxxxxx> Cc: Andrea Arcangeli <andrea@xxxxxxxxxxxx> Cc: Sagi Grimberg <sagig@xxxxxxxxxxxx> Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> Cc: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxxxxxx> Cc: Or Gerlitz <ogerlitz@xxxxxxxxxxxx> Cc: Haggai Eran <haggaie@xxxxxxxxxxxx> Cc: Shachar Raindel <raindel@xxxxxxxxxxxx> Cc: Liran Liss <liranl@xxxxxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxxxxxxxxxxxxx> Cc: Avi Kivity <avi@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff -puN mm/memory.c~mm-wrap-calls-to-set_pte_at_notify-with-invalidate_range_start-and-invalidate_range_end-fix mm/memory.c --- a/mm/memory.c~mm-wrap-calls-to-set_pte_at_notify-with-invalidate_range_start-and-invalidate_range_end-fix +++ a/mm/memory.c @@ -2529,6 +2529,7 @@ static int do_wp_page(struct mm_struct * struct page *dirty_page = NULL; unsigned long mmun_start; /* For mmu_notifiers */ unsigned long mmun_end; /* For mmu_notifiers */ + bool mmun_called = false; /* For mmu_notifiers */ old_page = vm_normal_page(vma, address, orig_pte); if (!old_page) { @@ -2706,8 +2707,9 @@ gotten: if (mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL)) goto oom_free_new; - mmun_start = address & PAGE_MASK; - mmun_end = (address & PAGE_MASK) + PAGE_SIZE; + mmun_start = address & PAGE_MASK; + mmun_end = (address & PAGE_MASK) + PAGE_SIZE; + mmun_called = true; mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); /* @@ -2776,8 +2778,7 @@ gotten: page_cache_release(new_page); unlock: pte_unmap_unlock(page_table, ptl); - if (new_page) - /* Only call the end notifier if the begin was called. */ + if (mmun_called) mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); if (old_page) { /* _ Patches currently in -mm which might be from haggaie@xxxxxxxxxxxx are linux-next.patch mm-mmu_notifier-have-mmu_notifiers-use-a-global-srcu-so-they-may-safely-schedule.patch mm-mmu_notifier-init-notifier-if-necessary.patch mm-mmu_notifier-make-the-mmu_notifier-srcu-static.patch mm-move-all-mmu-notifier-invocations-to-be-done-outside-the-pt-lock.patch mm-wrap-calls-to-set_pte_at_notify-with-invalidate_range_start-and-invalidate_range_end.patch mm-wrap-calls-to-set_pte_at_notify-with-invalidate_range_start-and-invalidate_range_end-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html