The patch titled Subject: uprobe-use-original-page-when-all-uprobes-are-removed-v2 has been added to the -mm tree. Its filename is uprobe-use-original-page-when-all-uprobes-are-removed-v2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/uprobe-use-original-page-when-all-uprobes-are-removed-v2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/uprobe-use-original-page-when-all-uprobes-are-removed-v2.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/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Song Liu <songliubraving@xxxxxx> Subject: uprobe-use-original-page-when-all-uprobes-are-removed-v2 Link: http://lkml.kernel.org/r/20190730193100.2295258-1-songliubraving@xxxxxx Signed-off-by: Song Liu <songliubraving@xxxxxx> Suggested-by: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Matthew Wilcox <matthew.wilcox@xxxxxxxxxx> Cc: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> Cc: Srikar Dronamraju <srikar@xxxxxxxxxxxxxxxxxx> Cc: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx> Cc: William Kucharski <william.kucharski@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/events/uprobes.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/kernel/events/uprobes.c~uprobe-use-original-page-when-all-uprobes-are-removed-v2 +++ a/kernel/events/uprobes.c @@ -192,7 +192,9 @@ static int __replace_page(struct vm_area page_add_new_anon_rmap(new_page, vma, addr, false); mem_cgroup_commit_charge(new_page, memcg, false, false); lru_cache_add_active_or_unevictable(new_page, vma); - } + } else + /* no new page, just dec_mm_counter for old_page */ + dec_mm_counter(mm, MM_ANONPAGES); if (!PageAnon(old_page)) { dec_mm_counter(mm, mm_counter_file(old_page)); @@ -496,6 +498,10 @@ retry: ref_ctr_updated = 1; } + ret = 0; + if (!is_register && !PageAnon(old_page)) + goto put_old; + ret = anon_vma_prepare(vma); if (ret) goto put_old; @@ -509,11 +515,12 @@ retry: copy_highpage(new_page, old_page); copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); - /* try orig_page only for unregister and anonymous old_page */ - if (!is_register && PageAnon(old_page)) { + if (!is_register) { struct page *orig_page; pgoff_t index; + VM_BUG_ON_PAGE(!PageAnon(old_page), old_page); + index = vaddr_to_offset(vma, vaddr & PAGE_MASK) >> PAGE_SHIFT; orig_page = find_get_page(vma->vm_file->f_inode->i_mapping, index); @@ -524,9 +531,6 @@ retry: /* let go new_page */ put_page(new_page); new_page = NULL; - - /* dec_mm_counter for old_page */ - dec_mm_counter(mm, MM_ANONPAGES); } put_page(orig_page); } _ Patches currently in -mm which might be from songliubraving@xxxxxx are mm-move-memcmp_pages-and-pages_identical.patch uprobe-use-original-page-when-all-uprobes-are-removed.patch uprobe-use-original-page-when-all-uprobes-are-removed-v2.patch mm-thp-introduce-foll_split_pmd.patch uprobe-use-foll_split_pmd-instead-of-foll_split.patch