The MMU-notifier code is needed only in case we copied a page. In the original code, as the tail call was explicit, we had to handle it as a special case there. However, now that the unlock flow is a separate function, this is not the case. We explicitly call mmu_notifier_invalidate_range_end in wp_page_copy, after finishing all of the unlock logic. This also makes it much easier to see the pairing of mmu_notifier_invalidate_range_start and mmu_notifier_invalidate_range_end in the same function. Signed-off-by: Shachar Raindel <raindel@xxxxxxxxxxxx> --- mm/memory.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 8023cf3..68fab34 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2100,13 +2100,10 @@ static int wp_page_reuse(struct mm_struct *mm, struct vm_area_struct *vma, */ static int wp_page_unlock(struct mm_struct *mm, struct vm_area_struct *vma, pte_t *page_table, spinlock_t *ptl, - unsigned long mmun_start, unsigned long mmun_end, struct page *old_page, int page_copied) __releases(ptl) { pte_unmap_unlock(page_table, ptl); - if (mmun_end > mmun_start) - mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); if (old_page) { /* * Don't let another task, with possibly unlocked vma, @@ -2143,6 +2140,7 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma, struct page *new_page = NULL; pte_t entry; int page_copied = 0; + int ret = 0; const unsigned long mmun_start = address & PAGE_MASK; /* For mmu_notifiers */ const unsigned long mmun_end = mmun_start + PAGE_SIZE; /* For mmu_notifiers */ struct mem_cgroup *memcg; @@ -2238,8 +2236,9 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma, if (new_page) page_cache_release(new_page); - return wp_page_unlock(mm, vma, page_table, ptl, mmun_start, - mmun_end, old_page, page_copied); + ret = wp_page_unlock(mm, vma, page_table, ptl, old_page, page_copied); + mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); + return ret; oom_free_new: page_cache_release(new_page); oom: @@ -2283,7 +2282,6 @@ static int wp_page_shared_vma(struct mm_struct *mm, struct vm_area_struct *vma, if (!pte_same(*page_table, orig_pte)) { unlock_page(old_page); return wp_page_unlock(mm, vma, page_table, ptl, - 0, 0, old_page, 0); } @@ -2352,7 +2350,6 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma, if (!pte_same(*page_table, orig_pte)) { unlock_page(old_page); return wp_page_unlock(mm, vma, page_table, ptl, - 0, 0, old_page, 0); } page_cache_release(old_page); -- 1.7.11.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>