On 07/25, Song Liu wrote: > > I guess I know the case now. We can probably avoid this with an simple > check for old_page == new_page? better yet, I think we can check PageAnon(old_page) and avoid the unnecessary __replace_page() in this case. See the patch below. Anyway, why __replace_page() needs to lock both pages? This doesn't look nice even if it were correct. I think it can do lock_page(old_page) later. Oleg. --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -488,6 +488,10 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, 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;